allenymt / PrivacySentry

Android隐私合规整改检测工具,注解+Asm修改字节码的检测方案
MIT License
2.05k stars 262 forks source link

没有文件生成 #35

Open jackyzhougithub opened 2 years ago

jackyzhougithub commented 2 years ago

有成功onResultCallBack的回调 但是该文件地址找不到文件

allenymt commented 2 years ago

说下复现场景吧,我这边复现不了的

zhjun2016 commented 2 years ago

我也遇到了。我这边手机是华为mate40, 鸿蒙系统2.0.. 用的默认配置,设置builder写入时间3分钟。java项目,target sdk26,compileSdk 29. 卸载apk后,第一次安装后,进入主页弹隐私协议弹窗,不同意,不初始化sdk,不申请权限。有成功onResultCallBack的回调 但是该文件地址找不到文件。5分钟后检查文件管理器,没有找到文件。

allenymt commented 2 years ago

@zhjun2016 初始化代码贴出来看看

zhjun2016 commented 2 years ago

Owner @allenymt /**

  • 分包处理 */ @Override protected void attachBaseContext(Context base) { super.attachBaseContext(base); //Nuwa.init(this); try { File file = new File(Environment.getExternalStorageDirectory().getAbsolutePath() + ("/app/qkclound/patch/" + AppConfig.APP_VERSION.substring(0, 5).replaceAll("\.", ""))); if (file.isDirectory()) { File[] files = file.listFiles(); if (files.length > 0) { PrintLog.printError(TAG, "存在patch包,路径为:" + files[0].getAbsolutePath()); if (!AppConfig.ZHUZHAN_APP_ID.equals(AppConfig.APP_ID)) { // Nuwa.loadPatch(this, files[0].getAbsolutePath()); }
            }
        }
    } catch (Exception e) {
        PrintLog.printError(TAG, "异常:" + e);
    }
    //5.0一下的需要dex优化一下
    if (!quickStart() && Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) {
        if (needWait(base)) {
            waitForDexopt(base);
        }
        MultiDex.install(this);
    }
    //TODO 隐私检测
    //完成功能的初始化
    PrivacySentryBuilder builder = new PrivacySentryBuilder()
            // 自定义文件结果的输出名
            .configResultFileName("buyer_privacy")
            // 配置游客模式,true打开游客模式,false关闭游客模式
            .configVisitorModel(false)
            // 配置写入文件日志 , 线上包这个开关不要打开!!!!,true打开文件输入,false关闭文件输入
            .enableFileResult(true)
            .syncDebug(true)
            // 持续写入文件30分钟
            .configWatchTime(3* 1000)
            // 文件输出后的回调
            .configResultCallBack(new PrivacyResultCallBack() {

                @Override
                public void onResultCallBack(@NonNull String s) {
                    System.out.println("隐私协议检出回调:"+s);

                }
            });
    PrivacySentry.Privacy.INSTANCE.init(this,builder);

}