Revert "Revert "RESTRICT AUTOMERGE Add feature flag to disable resource updatability APIs"" am: 704a86f316 am: 965185b792
Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/18344247
Change-Id: Idaab7634e9a7701a0b07f306d5c5258944cecb8d
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
diff --git a/core/java/android/app/admin/DevicePolicyResourcesManager.java b/core/java/android/app/admin/DevicePolicyResourcesManager.java
index e8eb792..2cc189f 100644
--- a/core/java/android/app/admin/DevicePolicyResourcesManager.java
+++ b/core/java/android/app/admin/DevicePolicyResourcesManager.java
@@ -26,6 +26,7 @@
import android.graphics.drawable.Drawable;
import android.graphics.drawable.Icon;
import android.os.RemoteException;
+import android.provider.DeviceConfig;
import android.util.DisplayMetrics;
import android.util.Log;
@@ -40,6 +41,9 @@
public class DevicePolicyResourcesManager {
private static String TAG = "DevicePolicyResourcesManager";
+ private static String DISABLE_RESOURCES_UPDATABILITY_FLAG = "disable_resources_updatability";
+ private static boolean DEFAULT_DISABLE_RESOURCES_UPDATABILITY = false;
+
private final Context mContext;
private final IDevicePolicyManager mService;
@@ -194,16 +198,20 @@
Objects.requireNonNull(drawableSource, "drawableSource can't be null");
Objects.requireNonNull(defaultDrawableLoader, "defaultDrawableLoader can't be null");
- if (drawableId.equals(DevicePolicyResources.UNDEFINED)) {
+ if (drawableId.equals(DevicePolicyResources.UNDEFINED)
+ || DeviceConfig.getBoolean(
+ DeviceConfig.NAMESPACE_DEVICE_POLICY_MANAGER,
+ DISABLE_RESOURCES_UPDATABILITY_FLAG,
+ DEFAULT_DISABLE_RESOURCES_UPDATABILITY)) {
return ParcelableResource.loadDefaultDrawable(defaultDrawableLoader);
}
+
if (mService != null) {
try {
ParcelableResource resource = mService.getDrawable(
drawableId, drawableStyle, drawableSource);
if (resource == null) {
- return ParcelableResource.loadDefaultDrawable(
- defaultDrawableLoader);
+ return ParcelableResource.loadDefaultDrawable(defaultDrawableLoader);
}
return resource.getDrawable(
mContext,
@@ -287,16 +295,20 @@
Objects.requireNonNull(drawableSource, "drawableSource can't be null");
Objects.requireNonNull(defaultDrawableLoader, "defaultDrawableLoader can't be null");
- if (drawableId.equals(DevicePolicyResources.UNDEFINED)) {
+ if (drawableId.equals(DevicePolicyResources.UNDEFINED)
+ || DeviceConfig.getBoolean(
+ DeviceConfig.NAMESPACE_DEVICE_POLICY_MANAGER,
+ DISABLE_RESOURCES_UPDATABILITY_FLAG,
+ DEFAULT_DISABLE_RESOURCES_UPDATABILITY)) {
return ParcelableResource.loadDefaultDrawable(defaultDrawableLoader);
}
+
if (mService != null) {
try {
ParcelableResource resource = mService.getDrawable(
drawableId, drawableStyle, drawableSource);
if (resource == null) {
- return ParcelableResource.loadDefaultDrawable(
- defaultDrawableLoader);
+ return ParcelableResource.loadDefaultDrawable(defaultDrawableLoader);
}
return resource.getDrawable(mContext, density, defaultDrawableLoader);
} catch (RemoteException e) {
@@ -330,9 +342,14 @@
Objects.requireNonNull(drawableSource, "drawableSource can't be null");
Objects.requireNonNull(defaultIcon, "defaultIcon can't be null");
- if (drawableId.equals(DevicePolicyResources.UNDEFINED)) {
+ if (drawableId.equals(DevicePolicyResources.UNDEFINED)
+ || DeviceConfig.getBoolean(
+ DeviceConfig.NAMESPACE_DEVICE_POLICY_MANAGER,
+ DISABLE_RESOURCES_UPDATABILITY_FLAG,
+ DEFAULT_DISABLE_RESOURCES_UPDATABILITY)) {
return defaultIcon;
}
+
if (mService != null) {
try {
ParcelableResource resource = mService.getDrawable(
@@ -463,7 +480,10 @@
Objects.requireNonNull(stringId, "stringId can't be null");
Objects.requireNonNull(defaultStringLoader, "defaultStringLoader can't be null");
- if (stringId.equals(DevicePolicyResources.UNDEFINED)) {
+ if (stringId.equals(DevicePolicyResources.UNDEFINED) || DeviceConfig.getBoolean(
+ DeviceConfig.NAMESPACE_DEVICE_POLICY_MANAGER,
+ DISABLE_RESOURCES_UPDATABILITY_FLAG,
+ DEFAULT_DISABLE_RESOURCES_UPDATABILITY)) {
return ParcelableResource.loadDefaultString(defaultStringLoader);
}
if (mService != null) {
@@ -508,7 +528,10 @@
Objects.requireNonNull(stringId, "stringId can't be null");
Objects.requireNonNull(defaultStringLoader, "defaultStringLoader can't be null");
- if (stringId.equals(DevicePolicyResources.UNDEFINED)) {
+ if (stringId.equals(DevicePolicyResources.UNDEFINED) || DeviceConfig.getBoolean(
+ DeviceConfig.NAMESPACE_DEVICE_POLICY_MANAGER,
+ DISABLE_RESOURCES_UPDATABILITY_FLAG,
+ DEFAULT_DISABLE_RESOURCES_UPDATABILITY)) {
return ParcelableResource.loadDefaultString(defaultStringLoader);
}
if (mService != null) {