Compare commits

...

1 Commits

Author SHA1 Message Date
a0c25a7c56 feat: 使用ASM插件检查隐私政策授权时的隐私问题
Signed-off-by: chenjuntao <chenjuntao@ghzhushou.com>
2024-04-28 10:44:41 +08:00
5 changed files with 64 additions and 1 deletions

View File

@ -4,6 +4,7 @@ apply plugin: 'kotlin-android' // kotlin
apply plugin: 'kotlin-parcelize'
apply plugin: 'kotlin-kapt'
apply plugin: 'AndResGuard'
apply plugin: 'privacy-sentry-plugin'
import groovy.xml.XmlUtil
@ -416,6 +417,43 @@ dependencies {
implementation(pushProject) {
exclude group: 'androidx.swiperefreshlayout'
}
def privacyVersion = "1.3.4.2"
implementation "com.github.allenymt.PrivacySentry:hook-sentry:$privacyVersion"
implementation "com.github.allenymt.PrivacySentry:privacy-annotation:$privacyVersion"
// 代理类的库如果自己没有代理类那么必须引用这个aar
// 如果不想使用库中本身的代理方法可以不引入这个aar但是自己必须实现代理类
// 引入privacy-proxy也可以自定义类代理方法优先以业务方定义的为准
implementation "com.github.allenymt.PrivacySentry:privacy-proxy:$privacyVersion"
// 1.2.3 新增类替换主要是为了hook构造函数的参数按业务方需求自己决定
implementation "com.github.allenymt.PrivacySentry:privacy-replace:$privacyVersion"
}
privacy {
// 设置免hook的名单
blackList = []
// 开关PrivacySentry插件功能
enablePrivacy = true
// 开启hook反射的方法
hookReflex = true
// 开启hook 替换类目前支持file
hookConstructor = true
// 是否开启hook变量默认为false建议弃用
hookField = true
// 以下是为了解决小米照明弹自启动问题的尝试, 如果没有自启动的需求,这里关闭即可
// hook Service的部分代码修复在MIUI上的自启动问题
// 部分Service把自己的Priority设置为1000这里开启代理功能可以代理成0
enableReplacePriority = true
replacePriority = 1
// 支持关闭Service的Export功能默认为false注意部分厂商通道之类的push(xiaomi、vivo、huawei等厂商的pushService),不能关闭
enableCloseServiceExport = true
// Export白名单Service, 这里根据厂商的名称设置了白名单
serviceExportPkgWhiteList = ["xiaomi","vivo","honor","meizu","oppo","Oppo","Hms","huawei","stp","Honor"]
// 修改Service的onStartCommand 返回值修改为START_NOT_STICKY
enableHookServiceStartCommand = true
}
File propFile = file('sign.properties')

View File

@ -34,6 +34,8 @@ import com.gh.gamecenter.core.utils.SPUtils
import com.gh.gamecenter.feature.utils.PlatformUtils
import com.gh.gamecenter.pkg.PkgHelper
import com.halo.assistant.HaloApp
import com.lightgame.download.FileUtils
import com.yl.lib.sentry.hook.PrivacySentry
import org.json.JSONObject
import splitties.systemservices.notificationManager
import java.text.SimpleDateFormat
@ -154,6 +156,8 @@ class SplashScreenActivity : BaseActivity() {
private fun showPrivacyDialog() {
NewPrivacyPolicyDialogFragment.show(this, null) { isSuccess: Boolean ->
if (isSuccess) {
PrivacySentry.Privacy.updatePrivacyShow()
mShouldPrefetchData = false
prefetchData()

View File

@ -85,6 +85,8 @@ import com.lightgame.utils.Utils;
import com.llew.huawei.verifier.LoadedApkHuaWei;
import com.shuyu.gsyvideoplayer.cache.CacheFactory;
import com.shuyu.gsyvideoplayer.player.PlayerFactory;
import com.yl.lib.sentry.hook.PrivacySentry;
import com.yl.lib.sentry.hook.PrivacySentryBuilder;
import java.util.List;
import java.util.ServiceLoader;
@ -617,6 +619,24 @@ public class HaloApp extends MultiDexApplication {
@Override
protected void attachBaseContext(Context base) {
super.attachBaseContext(base);
// 完成功能的初始化
PrivacySentryBuilder builder = new PrivacySentryBuilder()
// 自定义文件结果的输出名
.configResultFileName("buyer_privacy")
// debug打开可以看到logcat的堆栈日志
.syncDebug(true)
// 配置写入文件日志 , 线上包这个开关不要打开true打开文件输入false关闭文件输入
.enableFileResult(true)
// 持续写入文件30分钟
.configWatchTime(30 * 60 * 1000)
// 文件输出后的回调
.configResultCallBack(s -> {
});
// 添加默认结果输出包含log输出和文件输出
PrivacySentry.Privacy.INSTANCE.init(this, builder);
for (IApplication application : mApplicationList) {
application.attachBaseContext();
}

View File

@ -16,6 +16,7 @@ buildscript {
dependencies {
classpath "com.android.tools.build:gradle:7.1.3"
classpath 'com.github.allenymt.PrivacySentry:plugin-sentry:1.3.4.2'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
// 使用了 1.2.21 在蓝叠模拟器上无法进入首页? 但是不使用又会出现触发 V3 签名...
classpath 'io.github.leon406:AndResGuard-gradle-plugin:1.2.23'

View File

@ -2,7 +2,7 @@ ext {
//Android
buildToolsVersion = "30.0.3"
compileSdkVersion = 34
minSdkVersion = 16
minSdkVersion = 21
targetSdkVersion = 30