Merge "Fix SafetyProtectionUtils" into udc-dev

This commit is contained in:
Yi-an Chen
2023-03-23 20:39:21 +00:00
committed by Android (Google) Code Review

View File

@@ -40,6 +40,7 @@ public class SafetyProtectionUtils {
* @hide * @hide
*/ */
public static boolean shouldShowSafetyProtectionResources(Context context) { public static boolean shouldShowSafetyProtectionResources(Context context) {
try {
return DeviceConfig.getBoolean(DeviceConfig.NAMESPACE_PRIVACY, return DeviceConfig.getBoolean(DeviceConfig.NAMESPACE_PRIVACY,
SAFETY_PROTECTION_RESOURCES_ENABLED, false) SAFETY_PROTECTION_RESOURCES_ENABLED, false)
&& context.getResources().getBoolean( && context.getResources().getBoolean(
@@ -47,7 +48,12 @@ public class SafetyProtectionUtils {
.getIdentifier("config_safetyProtectionEnabled", .getIdentifier("config_safetyProtectionEnabled",
"bool", "android")) "bool", "android"))
&& context.getDrawable(android.R.drawable.ic_safety_protection) != null && context.getDrawable(android.R.drawable.ic_safety_protection) != null
&& context.getString(android.R.string.safety_protection_display_text) != null && !context.getString(
&& !context.getString(android.R.string.safety_protection_display_text).isEmpty(); android.R.string.safety_protection_display_text).isEmpty();
} catch (Resources.NotFoundException e) {
// We should expect the resources to not exist for non-pixel devices
// (except for the OEMs that opt-in)
return false;
}
} }
} }