1) 是否可以直接打开谷歌设置-->安全-->
Google Play 保护页面?
您可以使用com.google.android.gms.security.settings.VerifyAppsSettingsActivity Intent 直接启动播放保护屏幕,如下所示。
val intent = Intent()
intent.setComponent(ComponentName("com.google.android.gms", "com.google.android.gms.security.settings.VerifyAppsSettingsActivity"))
startActivity(intent)
Here 是 Playstore APK 的元数据,您可以看到所有可用的活动。
2) 如何检查扫描设备是否存在安全威胁选项
启用还是禁用?
开发人员可以从 SafetyNet Verify Apps API 获得有关用户设备上已安装应用程序环境的类似安全见解。这套新的 API 可让开发人员确定用户的设备是否受 Google Play Protect 保护,鼓励尚未使用 Google Play Protect 的用户启用它,并识别设备上安装的任何已知的potentially harmful apps (PHA)。
这些 API 对于可能会受到在与其应用相同的设备上安装的 PHA 影响的应用开发者特别有用。确定使用isVerifyAppsEnabled() 启用了 Google Play Protect 可为开发人员提供额外的保证,即设备更有可能是干净的。如果设备未启用 Google Play Protect,开发者可以通过enableVerifyApps() 请求用户启用 Google Play Protect。启用 Google Play Protect 后,开发人员可以使用listHarmfulApps() 方法来确定用户设备上是否安装了任何可能有害的应用程序。这种易于使用的功能套件不需要 API 密钥和请求配额。
编译com.google.android.gms:play-services-safetynet:11.6.0并使用下面的代码。
确定是否启用应用验证
SafetyNet.getClient(this)
.isVerifyAppsEnabled()
.addOnCompleteListener(new OnCompleteListener<VerifyAppsUserResponse>() {
@Override
public void onComplete(Task<VerifyAppsUserResponse> task) {
if (task.isSuccessful()) {
VerifyAppsUserResponse result = task.getResult();
if (result.isVerifyAppsEnabled()) {
Log.d("MY_APP_TAG", "The Verify Apps feature is enabled.");
} else {
Log.d("MY_APP_TAG", "The Verify Apps feature is disabled.");
}
} else {
Log.e("MY_APP_TAG", "A general error occurred.");
}
}
});
请求启用应用验证
SafetyNet.getClient(this)
.enableVerifyApps()
.addOnCompleteListener(new OnCompleteListener<VerifyAppsUserResponse>() {
@Override
public void onComplete(Task<VerifyAppsUserResponse> task) {
if (task.isSuccessful()) {
VerifyAppsUserResponse result = task.getResult();
if (result.isVerifyAppsEnabled()) {
Log.d("MY_APP_TAG", "The user gave consent " +
"to enable the Verify Apps feature.");
} else {
Log.d("MY_APP_TAG", "The user didn't give consent " +
"to enable the Verify Apps feature.");
}
} else {
Log.e("MY_APP_TAG", "A general error occurred.");
}
}
});
为获得更好的保护,开发人员应将证明 API 与新的验证应用 API 一起使用。首先使用attestation API 确定设备尚未从已知状态修改。一旦 Android 系统可以被信任,来自验证应用 API 的结果就可以被信任。
附:在使用 API 之前通读Additional TOS