Merge "Fix SafetyProtectionUtils" into udc-dev am: b7793f5891

Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/21993884

Change-Id: Ieabb0690dc6583b138b794cdc4afe1c409ba189e
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
This commit is contained in:
Yi-an Chen
2023-03-23 20:58:34 +00:00
committed by Automerger Merge Worker

View File

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