You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何通过代码阻止Play Protect扫描并报告自行安装的APK应用?

解决Play Protect弹窗及上报的代码/批量方案

一、自研设备系统级批量配置(优先推荐)

针对数千台自研设备,系统级配置是最高效的方案:

  • 预加入Play Protect白名单:如果设备采用定制ROM,可在系统源码中预先将应用包名添加到Play Protect可信列表。也可通过Android Enterprise的企业管理接口,批量标记应用为可信,从根源避免检测弹窗。
  • 精准禁用Play Protect检测组件:无需禁用整个Play Services,只需禁用其VerifyApps相关组件。使用系统级命令(需root或系统签名权限):
    pm disable com.google.android.gms/com.google.android.gms.security.VerifyAppsService
    pm disable com.google.android.gms/com.google.android.gms.security.settings.VerifyAppsSettingsActivity
    
    可将该命令集成到设备批量部署的初始化脚本中,自动执行。

二、原生Java应用内实现方案(需特殊权限)

如果应用具备系统签名或设备root权限,可在应用启动时自动完成配置:

  • 借助DevicePolicyManager禁用检测:将应用设置为设备所有者后,通过DevicePolicyManager关闭VerifyApps功能:
    DevicePolicyManager dpm = (DevicePolicyManager) getSystemService(Context.DEVICE_POLICY_SERVICE);
    ComponentName adminReceiver = new ComponentName(this, YourDeviceAdminReceiver.class);
    if (dpm.isAdminActive(adminReceiver)) {
        dpm.setVerifyAppsEnabled(adminReceiver, false);
    }
    
    批量部署时,可通过adb命令预先设置设备所有者:dpm set-device-owner com.your.package/.YourDeviceAdminReceiver
  • root权限下执行组件禁用:如果设备已root,应用启动时执行shell命令禁用相关组件:
    try {
        Process suProcess = Runtime.getRuntime().exec("su");
        DataOutputStream os = new DataOutputStream(suProcess.getOutputStream());
        os.writeBytes("pm disable com.google.android.gms/com.google.android.gms.security.VerifyAppsService\n");
        os.writeBytes("pm disable com.google.android.gms/com.google.android.gms.security.settings.VerifyAppsSettingsActivity\n");
        os.writeBytes("exit\n");
        os.flush();
        suProcess.waitFor();
    } catch (IOException | InterruptedException e) {
        e.printStackTrace();
    }
    

三、辅助优化措施

  • 固定应用签名:使用长期稳定的签名证书打包应用,避免频繁更换签名引发Play Protect的异常检测。
  • 企业私有应用发布:通过Android Enterprise将应用发布为私有应用,Play Protect会默认信任这类企业部署的应用,不再弹窗提示。

内容的提问来源于stack exchange,提问作者Eko Freshh

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.18 18:15:06