补充混淆规则
This commit is contained in:
146
FastBleLib/consumer-rules.pro
Normal file
146
FastBleLib/consumer-rules.pro
Normal file
@@ -0,0 +1,146 @@
|
||||
# ============================================================
|
||||
# FastBleLib 库模块 consumer-rules.pro(传递给依赖本库的 App 模块)
|
||||
# 库的实际包名:com.clj.fastble(namespace)
|
||||
# 要求:完全不混淆,关键系统回调必须 100% 保留
|
||||
# 问题根因:BleManager.getInstance().isConnected(mac) 执行不正常
|
||||
# → 因为 Parcelable CREATOR / 系统 BluetoothGattCallback 覆写方法
|
||||
# / Handler 内部类 handleMessage / 枚举 / 静态 Holder 单例 被 R8 优化
|
||||
# ============================================================
|
||||
|
||||
# -------------- 核心类 keep(基础包) --------------
|
||||
-keep class com.clj.fastble.** { *; }
|
||||
-keepclassmembers class com.clj.fastble.** {
|
||||
public <init>(...);
|
||||
protected <init>(...);
|
||||
<fields>;
|
||||
<methods>;
|
||||
}
|
||||
|
||||
# -------------- Parcelable 强化规则(核心:BleDevice / BleConnectStateParameter 等) --------------
|
||||
# 解决:跨 Binder 传递 BleDevice 时反序列化失败,getMac() 返回 null,导致 equals(mac) 永远 false
|
||||
-keep class * implements android.os.Parcelable {
|
||||
public static final android.os.Parcelable$Creator *;
|
||||
public static final android.os.Parcelable$ClassLoaderCreator *;
|
||||
public <init>(android.os.Parcel);
|
||||
public <init>(android.os.Parcel, java.lang.ClassLoader);
|
||||
public void writeToParcel(android.os.Parcel, int);
|
||||
public int describeContents();
|
||||
}
|
||||
# 针对 FastBle 自己的 Parcelable 类再单独声明一次,优先匹配
|
||||
# 说明:因为上面已经 -keep class com.clj.fastble.** { *; },所以这些类所有成员已全量保留
|
||||
# 这里只做显式声明(防止 outer keep 失效时的兜底)
|
||||
-keep class com.clj.fastble.data.BleDevice { *; }
|
||||
-keep class com.clj.fastble.data.BleConnectStateParameter { *; }
|
||||
-keep class com.clj.fastble.data.BleScanState { *; }
|
||||
|
||||
# -------------- 系统蓝牙回调覆写方法(最关键!Binder 回调触发必须保留原签名) --------------
|
||||
# 解决:onConnectionStateChange / onServicesDiscovered 等系统回调不触发 → 无法 addBleBluetooth → 列表为空 → isConnected() 永远 false
|
||||
# 所有 extends BluetoothGattCallback(BleBluetooth.coreGattCallback 匿名内部类继承它)
|
||||
-keepclassmembers class * extends android.bluetooth.BluetoothGattCallback {
|
||||
public *;
|
||||
protected *;
|
||||
void onConnectionStateChange(...);
|
||||
void onServicesDiscovered(...);
|
||||
void onCharacteristicRead(...);
|
||||
void onCharacteristicWrite(...);
|
||||
void onCharacteristicChanged(...);
|
||||
void onDescriptorRead(...);
|
||||
void onDescriptorWrite(...);
|
||||
void onReliableWriteCompleted(...);
|
||||
void onReadRemoteRssi(...);
|
||||
void onMtuChanged(...);
|
||||
void onPhyUpdate(...);
|
||||
void onPhyRead(...);
|
||||
void onServiceChanged(...);
|
||||
}
|
||||
# 所有 implements BluetoothAdapter.LeScanCallback(BleScanPresenter 实现它,老版扫描回调)
|
||||
-keepclassmembers class * implements android.bluetooth.BluetoothAdapter$LeScanCallback {
|
||||
void onLeScan(...);
|
||||
}
|
||||
# 所有 extends android.bluetooth.le.ScanCallback(Android 5.0+ 新版扫描 API,万一用到)
|
||||
-keepclassmembers class * extends android.bluetooth.le.ScanCallback {
|
||||
void onScanResult(...);
|
||||
void onBatchScanResults(...);
|
||||
void onScanFailed(...);
|
||||
}
|
||||
|
||||
# -------------- Handler 内部类 handleMessage(系统 Handler.Callback 机制触发) --------------
|
||||
# 解决:MainHandler / ScanHandler 的 handleMessage 被混淆 → 消息不处理 → 连接流程卡死
|
||||
-keepclassmembers class * extends android.os.Handler {
|
||||
public void handleMessage(android.os.Message);
|
||||
protected void handleMessage(android.os.Message);
|
||||
void handleMessage(...);
|
||||
}
|
||||
|
||||
# -------------- 枚举类保留(BleScanState、LastState 内部枚举) --------------
|
||||
# 解决:枚举 values() / valueOf() / ordinal() 被优化 → 状态判断错误
|
||||
-keepclassmembers enum * {
|
||||
public static **[] values();
|
||||
public static ** valueOf(java.lang.String);
|
||||
public static ** valueOf(java.lang.Class, java.lang.String);
|
||||
}
|
||||
-keep enum com.clj.fastble.** { *; }
|
||||
-keepclassmembers enum com.clj.fastble.** { *; }
|
||||
# 显式保留 BleBluetooth.LastState 内部枚举
|
||||
-keep class com.clj.fastble.bluetooth.BleBluetooth$LastState { *; }
|
||||
|
||||
# -------------- 静态 Holder 单例模式(BleManager / BleScanner 单例) --------------
|
||||
# 解决:R8 full mode 对 private static 内部类做特殊优化,导致单例失效,多次 init 覆盖
|
||||
-keep class com.clj.fastble.BleManager$BleManagerHolder { *; }
|
||||
-keepclassmembers class com.clj.fastble.BleManager$BleManagerHolder {
|
||||
static com.clj.fastble.BleManager sBleManager;
|
||||
<init>(...);
|
||||
}
|
||||
-keep class com.clj.fastble.scan.BleScanner$BleScannerHolder { *; }
|
||||
-keepclassmembers class com.clj.fastble.scan.BleScanner$BleScannerHolder {
|
||||
static com.clj.fastble.scan.BleScanner sBleScanner;
|
||||
<init>(...);
|
||||
}
|
||||
|
||||
# -------------- 内部类 + 匿名内部类(禁止类合并,保留外部类引用) --------------
|
||||
# 解决:R8 做 class merging,把 BleBluetooth$1(coreGattCallback 匿名类)合并到外层,导致 Binder 回调找不到
|
||||
-keepattributes InnerClasses,EnclosingMethod,Signature,*Annotation*,RuntimeVisibleAnnotations,RuntimeVisibleParameterAnnotations,Exceptions
|
||||
-keep class com.clj.fastble.**$* { *; }
|
||||
-keepclassmembers class com.clj.fastble.**$* {
|
||||
<init>(...);
|
||||
<fields>;
|
||||
<methods>;
|
||||
}
|
||||
|
||||
# -------------- 反射支持(BleBluetooth.refreshDeviceCache() 反射调用 BluetoothGatt#refresh) --------------
|
||||
# 说明:
|
||||
# - java.lang.reflect.* / android.bluetooth.BluetoothGatt 均为 Android 系统框架类,R8 不会修改/混淆/优化系统类
|
||||
# - BluetoothGatt#refresh() 是 @hide 隐藏 API,编译期 SDK(android.jar)中不存在,故无需也无法 keep
|
||||
# - 运行时反射 Class.getMethod("refresh") 可正常查找系统 ROM 中的真实方法,不受 ProGuard/R8 影响
|
||||
# - 因此这里不需要写任何 -keep 规则,仅保留 -dontwarn 防止反射类的警告
|
||||
-dontwarn java.lang.reflect.**
|
||||
-dontwarn android.bluetooth.BluetoothGatt
|
||||
|
||||
# -------------- 回调接口保留(动态代理/反射查找可能用到) --------------
|
||||
-keep interface com.clj.fastble.callback.** { *; }
|
||||
-keepclassmembers interface com.clj.fastble.callback.** { <methods>; }
|
||||
-keep class * implements com.clj.fastble.callback.BleGattCallback { *; }
|
||||
-keep class * implements com.clj.fastble.callback.BleScanCallback { *; }
|
||||
-keep class * implements com.clj.fastble.callback.BleScanAndConnectCallback { *; }
|
||||
-keep class * implements com.clj.fastble.callback.BleNotifyCallback { *; }
|
||||
-keep class * implements com.clj.fastble.callback.BleWriteCallback { *; }
|
||||
-keep class * implements com.clj.fastble.callback.BleReadCallback { *; }
|
||||
-keep class * implements com.clj.fastble.callback.BleIndicateCallback { *; }
|
||||
-keep class * implements com.clj.fastble.callback.BleRssiCallback { *; }
|
||||
-keep class * implements com.clj.fastble.callback.BleMtuChangedCallback { *; }
|
||||
|
||||
# -------------- 关键核心类额外 keep(单例、控制器) --------------
|
||||
# 说明:BluetoothBLEManager 类不存在于当前 FastBle 代码中,已移除(之前是误加的)
|
||||
-keep class com.clj.fastble.BleManager { *; }
|
||||
-keep class com.clj.fastble.bluetooth.BleBluetooth { *; }
|
||||
-keep class com.clj.fastble.bluetooth.MultipleBluetoothController { *; }
|
||||
-keep class com.clj.fastble.bluetooth.BleConnector { *; }
|
||||
-keep class com.clj.fastble.scan.BleScanner { *; }
|
||||
-keep class com.clj.fastble.scan.BleScanPresenter { *; }
|
||||
-keep class com.clj.fastble.scan.BleScanRuleConfig { *; }
|
||||
-keep class com.clj.fastble.data.BleMsg { *; }
|
||||
-keep class com.clj.fastble.utils.BleLog { *; }
|
||||
|
||||
-dontwarn com.clj.fastble.**
|
||||
-dontwarn android.bluetooth.**
|
||||
-dontwarn java.lang.reflect.**
|
||||
45
easyPhotos/consumer-rules.pro
Normal file
45
easyPhotos/consumer-rules.pro
Normal file
@@ -0,0 +1,45 @@
|
||||
# ============================================================
|
||||
# easyPhotos 库模块 consumer-rules.pro(传递给 App)
|
||||
# 库实际包名:com.huantansheng.easyphotos(namespace)
|
||||
# 要求:完全不混淆,包括其依赖的第三方库
|
||||
# ============================================================
|
||||
|
||||
# 保留整个库包
|
||||
-keep class com.huantansheng.easyphotos.** { *; }
|
||||
-keepclassmembers class com.huantansheng.easyphotos.** {
|
||||
public <init>(...);
|
||||
<fields>;
|
||||
<methods>;
|
||||
}
|
||||
# 依赖的子采样缩放图片 View
|
||||
-keep class com.davemorrissey.labs.subscaleview.** { *; }
|
||||
-keepclassmembers class com.davemorrissey.labs.subscaleview.** {
|
||||
public <init>(android.content.Context, android.util.AttributeSet);
|
||||
public <init>(android.content.Context, android.util.AttributeSet, int);
|
||||
<fields>;
|
||||
<methods>;
|
||||
}
|
||||
# 依赖的 PhotoView
|
||||
-keep class com.github.chrisbanes.photoview.** { *; }
|
||||
-keepclassmembers class com.github.chrisbanes.photoview.** {
|
||||
public <init>(android.content.Context, android.util.AttributeSet);
|
||||
public <init>(android.content.Context, android.util.AttributeSet, int);
|
||||
<fields>;
|
||||
<methods>;
|
||||
}
|
||||
# 通用自定义 View 构造保留(XML 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);
|
||||
}
|
||||
-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);
|
||||
}
|
||||
# 保留注解、泛型、签名
|
||||
-keepattributes Signature,*Annotation*,InnerClasses,EnclosingMethod,RuntimeVisibleAnnotations
|
||||
-dontwarn com.huantansheng.easyphotos.**
|
||||
-dontwarn com.davemorrissey.labs.subscaleview.**
|
||||
-dontwarn com.github.chrisbanes.photoview.**
|
||||
14
easysocket/consumer-rules.pro
Normal file
14
easysocket/consumer-rules.pro
Normal file
@@ -0,0 +1,14 @@
|
||||
# ============================================================
|
||||
# easysocket 库模块 consumer-rules.pro(传递给 App)
|
||||
# 库实际包名:com.easysocket(namespace)
|
||||
# 要求:完全不混淆
|
||||
# ============================================================
|
||||
|
||||
-keep class com.easysocket.** { *; }
|
||||
-keepclassmembers class com.easysocket.** {
|
||||
public <init>(...);
|
||||
<fields>;
|
||||
<methods>;
|
||||
}
|
||||
-keepattributes Signature,*Annotation*,InnerClasses,EnclosingMethod,RuntimeVisibleAnnotations
|
||||
-dontwarn com.easysocket.**
|
||||
13
easysocket/proguard-rules.pro
vendored
Normal file
13
easysocket/proguard-rules.pro
vendored
Normal file
@@ -0,0 +1,13 @@
|
||||
# ============================================================
|
||||
# easysocket 自身的混淆规则(仅当本模块 minifyEnabled=true 时生效,当前默认 false)
|
||||
# 实际包名:com.easysocket
|
||||
# ============================================================
|
||||
|
||||
-keep class com.easysocket.** { *; }
|
||||
-keepclassmembers class com.easysocket.** {
|
||||
public <init>(...);
|
||||
<fields>;
|
||||
<methods>;
|
||||
}
|
||||
-keepattributes Signature,*Annotation*,InnerClasses,EnclosingMethod,RuntimeVisibleAnnotations,SourceFile,LineNumberTable
|
||||
-dontwarn com.easysocket.**
|
||||
Reference in New Issue
Block a user