1.移除ACCESS_MOCK_LOCATION 权限
2.MMKV启用AES-256加密保存 3.修复导出组件和 Deep Links的处理建议 4.加入混淆代码 5.删除蓝牙透传RAW TCP(socket)
This commit is contained in:
@@ -0,0 +1,221 @@
|
||||
# ============================================================
|
||||
# baselibrary 库模块 consumer-rules.pro
|
||||
# 传递给依赖本库的 App 模块的混淆规则(必须存在!)
|
||||
# build.gradle -> defaultConfig -> consumerProguardFiles "consumer-rules.pro"
|
||||
# ============================================================
|
||||
|
||||
# 保留注解、泛型签名、运行时注解(网络层反射核心属性)
|
||||
-keepattributes Signature,*Annotation*,AnnotationDefault,RuntimeVisibleAnnotations,RuntimeVisibleParameterAnnotations,InnerClasses,EnclosingMethod
|
||||
|
||||
# ==============================
|
||||
# BaseNetworkApi:反射获取实际 Service 类型的泛型基类(核心!)
|
||||
# 修复:java.lang.Class cannot be cast to java.lang.reflect.ParameterizedType
|
||||
# ==============================
|
||||
-keep class com.abbidot.baselibrary.network.base.BaseNetworkApi { *; }
|
||||
-keep class * extends com.abbidot.baselibrary.network.base.BaseNetworkApi { *; }
|
||||
# 关键:保留所有继承 BaseNetworkApi 的子类的父类泛型参数声明(防止 R8 擦除 actualTypeArguments)
|
||||
-keep,allowshrinking class * extends com.abbidot.baselibrary.network.base.BaseNetworkApi {
|
||||
<init>(...);
|
||||
}
|
||||
-keepclassmembers class * extends com.abbidot.baselibrary.network.base.BaseNetworkApi {
|
||||
<fields>;
|
||||
<methods>;
|
||||
}
|
||||
# 保留 IService 接口
|
||||
-keep interface com.abbidot.baselibrary.network.base.IService { *; }
|
||||
|
||||
# ==============================
|
||||
# BaseResponse<T>:所有网络响应的泛型基类(Gson 反序列化依赖)
|
||||
# ==============================
|
||||
-keep class com.abbidot.baselibrary.network.base.BaseResponse { *; }
|
||||
# 保持所有 BaseResponse 子类的泛型签名不被擦除
|
||||
-keepclassmembers class * extends com.abbidot.baselibrary.network.base.BaseResponse {
|
||||
<fields>;
|
||||
<init>(...);
|
||||
}
|
||||
|
||||
# ==============================
|
||||
# Gson TypeAdapter:StringNullAdapter / DoubleDefault0Adapter
|
||||
# 通过 GsonBuilder.registerTypeAdapter 反射实例化
|
||||
# ==============================
|
||||
-keep class com.abbidot.baselibrary.network.interceptor.StringNullAdapter { *; }
|
||||
-keep class com.abbidot.baselibrary.network.interceptor.DoubleDefault0Adapter { *; }
|
||||
-keepclassmembers class com.abbidot.baselibrary.network.interceptor.StringNullAdapter {
|
||||
<init>();
|
||||
}
|
||||
-keepclassmembers class com.abbidot.baselibrary.network.interceptor.DoubleDefault0Adapter {
|
||||
<init>();
|
||||
}
|
||||
|
||||
# ==============================
|
||||
# OkHttp Interceptor:CommonRequestInterceptor / CommonResponseInterceptor
|
||||
# ==============================
|
||||
-keep class com.abbidot.baselibrary.network.interceptor.CommonRequestInterceptor { *; }
|
||||
-keep class com.abbidot.baselibrary.network.interceptor.CommonResponseInterceptor { *; }
|
||||
-keepclassmembers class com.abbidot.baselibrary.network.interceptor.CommonRequestInterceptor {
|
||||
<init>();
|
||||
}
|
||||
-keepclassmembers class com.abbidot.baselibrary.network.interceptor.CommonResponseInterceptor {
|
||||
<init>();
|
||||
}
|
||||
|
||||
# ==============================
|
||||
# 异常类(反射抛出时需保留类名)
|
||||
# ==============================
|
||||
-keep class com.abbidot.baselibrary.network.exception.** { *; }
|
||||
|
||||
# ==============================
|
||||
# Retrofit 3.0 / OkHttp 5(Kotlin-first 新版本,额外加固规则)
|
||||
# ==============================
|
||||
-keep,allowobfuscation,allowshrinking interface retrofit2.Call
|
||||
-keep,allowobfuscation,allowshrinking class retrofit2.Response
|
||||
-keep,allowobfuscation,allowshrinking class kotlin.coroutines.Continuation
|
||||
-keep,allowobfuscation,allowshrinking class retrofit2.KotlinExtensions
|
||||
# 所有带 Retrofit http 注解的接口方法必须保留(用于动态代理反射)
|
||||
-if interface * { @retrofit2.http.* <methods>; }
|
||||
-keep,allowobfuscation interface * { <methods>; }
|
||||
# OkHttp 5 消除内部平台警告
|
||||
-dontwarn okhttp3.internal.platform.**
|
||||
-dontwarn org.conscrypt.**
|
||||
-dontwarn org.bouncycastle.**
|
||||
-dontwarn org.openjsse.**
|
||||
-dontwarn org.codehaus.mojo.animal_sniffer.*
|
||||
|
||||
# ==============================
|
||||
# Gson(配合 Retrofit 3.0 converter-gson 使用)
|
||||
# ==============================
|
||||
-keep class com.google.gson.** { *; }
|
||||
-dontwarn com.google.gson.**
|
||||
# TypeToken 匿名内部类的泛型签名必须保留
|
||||
-keep class com.google.gson.reflect.TypeToken { *; }
|
||||
-keep class * extends com.google.gson.reflect.TypeToken { *; }
|
||||
-keepclassmembers class * extends com.google.gson.reflect.TypeToken {
|
||||
<init>(...);
|
||||
java.lang.reflect.Type getType();
|
||||
}
|
||||
-keepnames class com.google.gson.internal.** { *; }
|
||||
# SerializedName / Expose 注解字段保留
|
||||
-keepclassmembers,allowshrinking,allowobfuscation class * {
|
||||
@com.google.gson.annotations.SerializedName <fields>;
|
||||
@com.google.gson.annotations.Expose <fields>;
|
||||
}
|
||||
|
||||
# ==============================
|
||||
# 自定义 View / LayoutInflater 反射构造函数保留
|
||||
# 所有通过 XML inflate 的自定义 View 必须保留 (Context, AttributeSet) 构造
|
||||
# ==============================
|
||||
-keepclassmembers class * extends android.view.View {
|
||||
public <init>(android.content.Context, android.util.AttributeSet);
|
||||
public <init>(android.content.Context, android.util.AttributeSet, int);
|
||||
public <init>(android.content.Context, android.util.AttributeSet, int, int);
|
||||
void set*(***);
|
||||
*** get*();
|
||||
}
|
||||
-keepclassmembers class * extends android.view.ViewGroup {
|
||||
public <init>(android.content.Context, android.util.AttributeSet);
|
||||
public <init>(android.content.Context, android.util.AttributeSet, int);
|
||||
public <init>(android.content.Context, android.util.AttributeSet, int, int);
|
||||
}
|
||||
# baselibrary 内部自定义 View
|
||||
-keep class com.abbidot.baselibrary.widget.** { *; }
|
||||
-keepclassmembers class com.abbidot.baselibrary.widget.** {
|
||||
public <init>(...);
|
||||
<fields>;
|
||||
<methods>;
|
||||
}
|
||||
|
||||
# ==============================
|
||||
# 常量类(EventName/ConState/MMKVKey 等):伴生对象 const val 虽被 inline,但类名/成员名保留方便反射查找
|
||||
# ==============================
|
||||
-keep class com.abbidot.baselibrary.constant.** { *; }
|
||||
-keepclassmembers class com.abbidot.baselibrary.constant.** {
|
||||
<fields>;
|
||||
<methods>;
|
||||
public static final *;
|
||||
}
|
||||
|
||||
# ==============================
|
||||
# XEventBus 事件总线(核心:发送/接收/观察者包装类必须保留)
|
||||
# ==============================
|
||||
-keep class com.abbidot.baselibrary.eventbus.** { *; }
|
||||
-keep class com.abbidot.baselibrary.eventbus.core.** { *; }
|
||||
-keepclassmembers class * {
|
||||
@com.abbidot.baselibrary.constant.EventName <fields>;
|
||||
}
|
||||
|
||||
# ==============================
|
||||
# BaseRecyclerAdapter 列表适配器和 ViewHolder
|
||||
# ==============================
|
||||
-keep class com.abbidot.baselibrary.list.** { *; }
|
||||
-keepclassmembers class com.abbidot.baselibrary.list.** {
|
||||
public <init>(...);
|
||||
<fields>;
|
||||
<methods>;
|
||||
}
|
||||
|
||||
# ==============================
|
||||
# baselibrary.util:AppUtils/LogUtil/MMKVUtil/Utils(双重保险:app 模块里也写了一份)
|
||||
# ==============================
|
||||
-keep class com.abbidot.baselibrary.util.** { *; }
|
||||
-keepclassmembers class com.abbidot.baselibrary.util.** {
|
||||
public <init>(...);
|
||||
<fields>;
|
||||
<methods>;
|
||||
}
|
||||
|
||||
# ==============================
|
||||
# Parcelable / kotlinx-parcelize:跨模块 Intent 传值必备
|
||||
# ==============================
|
||||
# 注意:@Parcelize 是 SOURCE/BINARY 级编译期注解,运行时不存在,禁止写 -keep @kotlinx.parcelize.Parcelize
|
||||
-keep class * implements android.os.Parcelable { *; }
|
||||
-keepclassmembers class * implements android.os.Parcelable {
|
||||
public static final android.os.Parcelable$Creator *;
|
||||
public static final android.os.Parcelable$ClassLoaderCreator *;
|
||||
<init>(android.os.Parcel);
|
||||
<init>(android.os.Parcel, java.lang.ClassLoader);
|
||||
void writeToParcel(android.os.Parcel, int);
|
||||
int describeContents();
|
||||
}
|
||||
# kotlin-parcelize 运行时生成的内部辅助类($Creator、$Parceler)
|
||||
-keep class **$Creator { *; }
|
||||
-keep class **$Parceler { *; }
|
||||
-keepclassmembers class **$Creator { <fields>; <methods>; }
|
||||
-keepclassmembers class **$Parceler { <fields>; <methods>; }
|
||||
-dontwarn kotlinx.parcelize.**
|
||||
|
||||
# ==============================
|
||||
# ViewModel:跨模块 by viewModels() 反射创建
|
||||
# ==============================
|
||||
-keep class * extends androidx.lifecycle.ViewModel { *; }
|
||||
-keepclassmembers class * extends androidx.lifecycle.ViewModel {
|
||||
public <init>(...);
|
||||
protected <init>(...);
|
||||
<fields>;
|
||||
<methods>;
|
||||
}
|
||||
|
||||
# ==============================
|
||||
# Kotlin 协程 / suspend 函数:Continuation 签名不被擦除
|
||||
# ==============================
|
||||
-keep class kotlin.coroutines.Continuation { *; }
|
||||
-keep class kotlin.coroutines.intrinsics.** { *; }
|
||||
-keep class kotlinx.coroutines.** { *; }
|
||||
-dontwarn kotlinx.coroutines.**
|
||||
-dontwarn kotlin.coroutines.**
|
||||
|
||||
# ==============================
|
||||
# Kotlin 伴生对象 / 单例 INSTANCE:EventName.Companion / ConState.Companion 等
|
||||
# ==============================
|
||||
-keepclassmembers class **$Companion {
|
||||
<fields>;
|
||||
<methods>;
|
||||
public static final *;
|
||||
static *;
|
||||
}
|
||||
-keep class **$Companion { *; }
|
||||
-keepclassmembers class * {
|
||||
public static final ** INSTANCE;
|
||||
public static final ** Companion;
|
||||
public static ** getINSTANCE();
|
||||
public static ** getCompanion();
|
||||
}
|
||||
|
||||
84
baselibrary/proguard-rules.pro
vendored
84
baselibrary/proguard-rules.pro
vendored
@@ -1,21 +1,69 @@
|
||||
# Add project specific ProGuard rules here.
|
||||
# You can control the set of applied configuration files using the
|
||||
# proguardFiles setting in build.gradle.
|
||||
#
|
||||
# For more details, see
|
||||
# http://developer.android.com/guide/developing/tools/proguard.html
|
||||
# ============================================================
|
||||
# baselibrary 库模块自身的混淆规则(仅当 baselibrary 的 minifyEnabled=true 时生效)
|
||||
# 注意:对 App 模块生效的规则写在 consumer-rules.pro 中
|
||||
# ============================================================
|
||||
|
||||
# If your project uses WebView with JS, uncomment the following
|
||||
# and specify the fully qualified class name to the JavaScript interface
|
||||
# class:
|
||||
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
|
||||
# public *;
|
||||
#}
|
||||
# 保留注解、泛型签名、运行时注解(网络层反射核心属性)
|
||||
-keepattributes Signature,*Annotation*,AnnotationDefault,RuntimeVisibleAnnotations,RuntimeVisibleParameterAnnotations,InnerClasses,EnclosingMethod
|
||||
|
||||
# Uncomment this to preserve the line number information for
|
||||
# debugging stack traces.
|
||||
#-keepattributes SourceFile,LineNumberTable
|
||||
# BaseNetworkApi 反射泛型基类
|
||||
-keep class com.abbidot.baselibrary.network.base.BaseNetworkApi { *; }
|
||||
-keep class * extends com.abbidot.baselibrary.network.base.BaseNetworkApi { *; }
|
||||
-keep interface com.abbidot.baselibrary.network.base.IService { *; }
|
||||
|
||||
# If you keep the line number information, uncomment this to
|
||||
# hide the original source file name.
|
||||
#-renamesourcefileattribute SourceFile
|
||||
# BaseResponse<T> 网络响应泛型基类
|
||||
-keep class com.abbidot.baselibrary.network.base.BaseResponse { *; }
|
||||
|
||||
# Gson TypeAdapter
|
||||
-keep class com.abbidot.baselibrary.network.interceptor.StringNullAdapter { *; }
|
||||
-keep class com.abbidot.baselibrary.network.interceptor.DoubleDefault0Adapter { *; }
|
||||
|
||||
# OkHttp Interceptor
|
||||
-keep class com.abbidot.baselibrary.network.interceptor.CommonRequestInterceptor { *; }
|
||||
-keep class com.abbidot.baselibrary.network.interceptor.CommonResponseInterceptor { *; }
|
||||
|
||||
# 异常类
|
||||
-keep class com.abbidot.baselibrary.network.exception.** { *; }
|
||||
|
||||
# 公共工具类(反射用到的保留)
|
||||
-keep class com.abbidot.baselibrary.util.** { *; }
|
||||
-keep class com.abbidot.baselibrary.constant.** { *; }
|
||||
|
||||
# EventBus
|
||||
-keep class com.abbidot.baselibrary.eventbus.** { *; }
|
||||
|
||||
# RecyclerView 公共基类
|
||||
-keep class com.abbidot.baselibrary.list.** { *; }
|
||||
|
||||
# Retrofit + Gson + OkHttp
|
||||
-keep,allowobfuscation,allowshrinking interface retrofit2.Call
|
||||
-keep,allowobfuscation,allowshrinking class retrofit2.Response
|
||||
-keep,allowobfuscation,allowshrinking class kotlin.coroutines.Continuation
|
||||
-if interface * { @retrofit2.http.* <methods>; }
|
||||
-keep,allowobfuscation interface * { <methods>; }
|
||||
-keep class com.google.gson.** { *; }
|
||||
-keep class com.google.gson.reflect.TypeToken { *; }
|
||||
-keep class * extends com.google.gson.reflect.TypeToken { *; }
|
||||
-dontwarn okhttp3.internal.platform.**
|
||||
-dontwarn org.conscrypt.**
|
||||
-dontwarn org.bouncycastle.**
|
||||
-dontwarn org.openjsse.**
|
||||
-dontwarn org.codehaus.mojo.animal_sniffer.*
|
||||
-dontwarn com.google.gson.**
|
||||
|
||||
# ==============================
|
||||
# 自定义 View / LayoutInflater 反射构造函数保留
|
||||
# ==============================
|
||||
-keepclassmembers class * extends android.view.View {
|
||||
public <init>(android.content.Context, android.util.AttributeSet);
|
||||
public <init>(android.content.Context, android.util.AttributeSet, int);
|
||||
public <init>(android.content.Context, android.util.AttributeSet, int, int);
|
||||
void set*(***);
|
||||
*** get*();
|
||||
}
|
||||
-keepclassmembers class * extends android.view.ViewGroup {
|
||||
public <init>(android.content.Context, android.util.AttributeSet);
|
||||
public <init>(android.content.Context, android.util.AttributeSet, int);
|
||||
public <init>(android.content.Context, android.util.AttributeSet, int, int);
|
||||
}
|
||||
-keep class com.abbidot.baselibrary.widget.** { *; }
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package com.abbidot.baselibrary.util
|
||||
|
||||
import android.util.Log
|
||||
import java.util.*
|
||||
import java.util.Locale
|
||||
|
||||
/**
|
||||
*Created by .yzq on 2021/11/3/003.
|
||||
|
||||
@@ -30,7 +30,7 @@ class Utils {
|
||||
|
||||
//HTTP请求加密key
|
||||
var SECRET_KEY = ""
|
||||
val CARD_RSA_KEY="MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAofuJbnkwyF7SWg3eRadSYT+ttfHN+CUmCzH0WW1EWTUQOG+01Nv8ux+UJUlxbZA2X7959Et/+VKE03+4OY0/26dlgkROMlXCUnzsucuaoHW+9whGi6xklRZrDLi22QBae/8XV1YDEU2vfYXtcvwf66J0t+bRIhGytQUZvUrL7OEaAHvwJU0QwCy3wQGWcCgSkPpDruIe4ar19iZMleE+BdPGIfKfVdPvWFls63g1eMFECb8F9zN6ydGTCvlqvx/4gfDuFQnF+JuTSre8euSpTRTQn/Q0s3K6KiROVcAYCqDW6cKxNUr2ha1C9ZFxMws9C0qhx5wYzfSlIjFthPC1qwIDAQAB"
|
||||
var CARD_RSA_KEY = ""
|
||||
const val DATE_FORMAT_PATTERN_CN = "yyyy-MM-dd"
|
||||
const val DATE_FORMAT_PATTERN_CN2 = "yyyy-MM-dd HH:mm:ss"
|
||||
const val DATE_FORMAT_PATTERN_CN3 = "yyyy/MM/dd HH:mm:ss"
|
||||
|
||||
Reference in New Issue
Block a user