Revert "Revert "RESTRICT AUTOMERGE Add feature flag to disable resource updatability APIs"" am: 704a86f316
Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/18344247 Change-Id: I2d8cb327e5d7960a1fe0a2af33c48a0b398d2910 Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
This commit is contained in:
@@ -26,6 +26,7 @@ import android.content.res.Resources;
|
||||
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 @@ import java.util.function.Supplier;
|
||||
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 @@ public class DevicePolicyResourcesManager {
|
||||
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 @@ public class DevicePolicyResourcesManager {
|
||||
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 @@ public class DevicePolicyResourcesManager {
|
||||
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 @@ public class DevicePolicyResourcesManager {
|
||||
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 @@ public class DevicePolicyResourcesManager {
|
||||
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) {
|
||||
|
||||
Reference in New Issue
Block a user