如何打开并检查Play Protect是启用还是禁用 [英] How to open and check whether Play Protect is enabled or disabled

查看:1890
本文介绍了如何打开并检查Play Protect是启用还是禁用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

  minSdkVersion 18 
目标SdkVersion 27

下面的代码,我可以打开 Google设置页面。

  private static final String GOOGLE_SETTINGS_COMPONENT =  com.google.android.gms; 
private static final String GOOGLE_SETTINGS_ACTIVITY = .app.settings.GoogleSettingsActivity;
Intent i = new Intent();
i.setClassName(GOOGLE_SETTINGS_COMPONENT,GOOGLE_SETTINGS_COMPONENT + GOOGLE_SETTINGS_ACTIVITY);
try {
startActivity(i);
} catch(android.content.ActivityNotFoundException ex){
Toast.makeText(getApplicationContext(),找不到活动,Toast.LENGTH_LONG).show();
}




  1. 是否可以直接打开 Google设置-> 安全性-> Google Play保护页面。

  2. 如何检查启用或禁用扫描设备是否存在安全威胁选项?


解决方案


1)是否可以直接打开Goog​​le设置->安全->
Google Play保护页面?


您可以使用 com.google.android.gms.security.settings.VerifyAppsSettingsActivity 意图直接启动播放保护屏幕,如下所示。

  val intent = Intent()
intent.setComponent(ComponentName( com.google.android.gms, com。 google.android.gms.security.settings.VerifyAppsSettingsActivity))
startActivity(intent)

此处是playstore APK的元数据,您可以在其中看到所有可用的活动。


2)如何检查扫描设备的安全威胁选项是启用还是禁用


开发人员可以从SafetyNet 验证Apps API 。通过这种新的API套件,开发人员可以确定用户的设备是否受到Google Play保护的保护,鼓励尚未使用Google Play保护的用户启用该设备,并识别任何已知的已安装在设备上的潜在有害应用(PHA)。



这些API是对于可能会受到与其应用程序安装在同一设备上的PHA影响的应用程序开发人员而言特别有用。确定已通过 isVerifyAppsEnabled() 为开发人员提供了进一步的保证,即设备更可能是干净的。如果设备未启用Google Play保护,则开发人员可以请求用户使用 enableVerifyApps() 。启用Google Play保护后,开发人员可以使用 listHarmfulApps() 方法来确定用户设备上是否安装了可能有害的应用程序。这个易于使用的功能套件不需要API密钥和请求配额。



编译 com.google.android.gms:play- services-safetynet:11.6.0 并使用以下代码。


确定是否启用了应用验证




  SafetyNet.getClient(this)
.isVerifyAppsEnabled()
.addOnCompleteListener (新的OnCompleteListener< VerifyAppsUserResponse>(){
@Override
public void onComplete(Task< VerifyAppsUserResponse>任务){
如果(task.isSuccessful()){
VerifyAppsUserResponse结果= task.getResult();
if(result.isVerifyAppsEnabled()){
Log.d( MY_APP_TAG,验证应用功能已启用。);
}否则{
Log.d( MY_APP_TAG,验证应用功能已禁用。);
}
} else {
Log.e( MY_APP_TAG,发生一般错误。);
}
}
});




请求启用应用验证




  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,用户同意 +
以启用验证应用功能。);
} else {
Log.d( MY_APP_TAG,用户未表示同意 +
以启用验证应用功能。);
}
}否则{
Log.e( MY_APP_TAG,发生一般错误。);
}
}
});

为了获得更好的保护,开发人员应将证明API与新的Verify Apps API一起使用。首先使用证明API 来确定尚未从已知状态修改设备。一旦可以信任Android系统,就可以信任来自Verify Apps API的结果。



P.S。使用API​​之前,请通读其他TOS 。 >

    minSdkVersion 18
    targetSdkVersion 27

Using below code, I can able to open the Google Settings page.

private static final String GOOGLE_SETTINGS_COMPONENT = "com.google.android.gms";
private static final String GOOGLE_SETTINGS_ACTIVITY = ".app.settings.GoogleSettingsActivity";
Intent i = new Intent();
i.setClassName(GOOGLE_SETTINGS_COMPONENT,GOOGLE_SETTINGS_COMPONENT + GOOGLE_SETTINGS_ACTIVITY);
try {
      startActivity(i);
} catch (android.content.ActivityNotFoundException ex) {
      Toast.makeText(getApplicationContext(), "Activity Not Found", Toast.LENGTH_LONG).show();
 }

  1. Is it possible to directly open the Google Settings --> Security --> Google Play Protect page.
  2. How to check whether the Scan device for security threats option is enabled or disabled?

解决方案

1) Is it possible to directly open the Google Settings --> Security --> Google Play Protect page ?

You can use the com.google.android.gms.security.settings.VerifyAppsSettingsActivity intent to launch play protect screen directly as below.

val intent = Intent()
intent.setComponent(ComponentName("com.google.android.gms", "com.google.android.gms.security.settings.VerifyAppsSettingsActivity"))
startActivity(intent)

Here is the meta data of playstore APK you can see all available activities out there.

2) How to check whether the Scan device for security threats option is enabled or disabled?

Developers can get similar security insights into the installed apps landscape on user devices from the SafetyNet Verify Apps API. This new suite of APIs lets developers determine whether a user's device is protected by Google Play Protect, encourage users not already using Google Play Protect to enable it, and identify any known potentially harmful apps (PHAs) that are installed on the device.

These APIs are especially useful for developers of apps that may be impacted by installed PHAs on the same device as their app. Determining that Google Play Protect is enabled with isVerifyAppsEnabled() gives developers additional assurance that a device is more likely to be clean. If a device doesn't have Google Play Protect enabled, developers can request that the user enable Google Play Protect with enableVerifyApps(). With Google Play Protect enabled, developers can use the listHarmfulApps() method to determine whether there are any potentially harmful apps installed on a user's device. This easy-to-use suite of features does not require API keys and requesting quota.

Compile com.google.android.gms:play-services-safetynet:11.6.0 and use the below code.

Determine whether app verification is enabled

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.");
            }
        }
    });

Request enabling of app verification

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.");
            }
        }
    });

For better protection, developers should use the attestation API along with the new Verify Apps API. Use the attestation API first to establish that the device has not been modified from a known state. Once the Android system can be trusted, the results from the Verify Apps API can be trusted.

P.S. Read through the Additional TOS prior using the API

这篇关于如何打开并检查Play Protect是启用还是禁用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆