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,14 +40,20 @@ public class SafetyProtectionUtils {
* @hide * @hide
*/ */
public static boolean shouldShowSafetyProtectionResources(Context context) { public static boolean shouldShowSafetyProtectionResources(Context context) {
return DeviceConfig.getBoolean(DeviceConfig.NAMESPACE_PRIVACY, try {
SAFETY_PROTECTION_RESOURCES_ENABLED, false) return DeviceConfig.getBoolean(DeviceConfig.NAMESPACE_PRIVACY,
&& context.getResources().getBoolean( SAFETY_PROTECTION_RESOURCES_ENABLED, false)
Resources.getSystem() && context.getResources().getBoolean(
.getIdentifier("config_safetyProtectionEnabled", Resources.getSystem()
"bool", "android")) .getIdentifier("config_safetyProtectionEnabled",
&& context.getDrawable(android.R.drawable.ic_safety_protection) != null "bool", "android"))
&& context.getString(android.R.string.safety_protection_display_text) != null && context.getDrawable(android.R.drawable.ic_safety_protection) != null
&& !context.getString(android.R.string.safety_protection_display_text).isEmpty(); && !context.getString(
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;
}
} }
} }