如何打开并检查 Play Protect 是否启用或禁用
How to open and check whether Play Protect is enabled or disabled
minSdkVersion 18
targetSdkVersion 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(), "Activity Not Found", Toast.LENGTH_LONG).show();
}
- 是否可以直接打开Google设置 --> 安全 --> Google 播放保护 页。
- 如何查看扫描设备安全威胁选项是启用还是禁用?
1) Is it possible to directly open the Google Settings --> Security -->
Google Play Protect page ?
您可以使用 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) How to check whether the Scan device for security threats option is
enabled or disabled?
开发人员可以从安装在设备上的 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 (PHA) 获得对用户设备上已安装应用程序环境的类似安全洞察。
这些 API 对可能受安装在其应用所在的同一设备上的 PHA 影响的应用的开发者特别有用。使用 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()
方法确定 Google Play Protect 是否已启用,以确定用户设备上是否安装了任何可能有害的应用程序。这套易于使用的功能不需要 API 密钥和请求配额。
编译com.google.android.gms:play-services-safetynet:11.6.0
并使用下面的代码。
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.");
}
}
});
为了更好的保护,开发者应该使用认证 API 以及新的 Verify Apps API。首先使用 attestation API 确定设备未从已知状态修改。一旦 Android 系统可以信任,验证应用程序 API 的结果就可以信任。
P.S。在使用 API
之前通读 Additional TOS
在JAVA
Intent i = new Intent();
i.setClassName("com.google.android.gms", "com.google.android.gms.security.settings.VerifyAppsSettingsActivity" );
try {
startActivity(i);
} catch (android.content.ActivityNotFoundException ex) {
Toast.makeText(getApplicationContext(), "Activity Not Found", Toast.LENGTH_LONG).show();
}
minSdkVersion 18
targetSdkVersion 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(), "Activity Not Found", Toast.LENGTH_LONG).show();
}
- 是否可以直接打开Google设置 --> 安全 --> Google 播放保护 页。
- 如何查看扫描设备安全威胁选项是启用还是禁用?
1) Is it possible to directly open the Google Settings --> Security --> Google Play Protect page ?
您可以使用 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) How to check whether the Scan device for security threats option is enabled or disabled?
开发人员可以从安装在设备上的 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 (PHA) 获得对用户设备上已安装应用程序环境的类似安全洞察。
这些 API 对可能受安装在其应用所在的同一设备上的 PHA 影响的应用的开发者特别有用。使用 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()
方法确定 Google Play Protect 是否已启用,以确定用户设备上是否安装了任何可能有害的应用程序。这套易于使用的功能不需要 API 密钥和请求配额。
编译com.google.android.gms:play-services-safetynet:11.6.0
并使用下面的代码。
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.");
}
}
});
为了更好的保护,开发者应该使用认证 API 以及新的 Verify Apps API。首先使用 attestation API 确定设备未从已知状态修改。一旦 Android 系统可以信任,验证应用程序 API 的结果就可以信任。
P.S。在使用 API
之前通读 Additional TOS在JAVA
Intent i = new Intent();
i.setClassName("com.google.android.gms", "com.google.android.gms.security.settings.VerifyAppsSettingsActivity" );
try {
startActivity(i);
} catch (android.content.ActivityNotFoundException ex) {
Toast.makeText(getApplicationContext(), "Activity Not Found", Toast.LENGTH_LONG).show();
}