Revert "Revert "RESTRICT AUTOMERGE Add feature flag to disable resource updatability APIs""
This reverts commit 00c0a92877.
Reason for revert: fixed the original issue
Change-Id: Ie5905820de253630935ad59ba83d93446b8a377f
This commit is contained in:
@@ -26,6 +26,7 @@ import android.content.res.Resources;
|
|||||||
import android.graphics.drawable.Drawable;
|
import android.graphics.drawable.Drawable;
|
||||||
import android.graphics.drawable.Icon;
|
import android.graphics.drawable.Icon;
|
||||||
import android.os.RemoteException;
|
import android.os.RemoteException;
|
||||||
|
import android.provider.DeviceConfig;
|
||||||
import android.util.DisplayMetrics;
|
import android.util.DisplayMetrics;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
|
|
||||||
@@ -40,6 +41,9 @@ import java.util.function.Supplier;
|
|||||||
public class DevicePolicyResourcesManager {
|
public class DevicePolicyResourcesManager {
|
||||||
private static String TAG = "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 Context mContext;
|
||||||
private final IDevicePolicyManager mService;
|
private final IDevicePolicyManager mService;
|
||||||
|
|
||||||
@@ -194,16 +198,20 @@ public class DevicePolicyResourcesManager {
|
|||||||
Objects.requireNonNull(drawableSource, "drawableSource can't be null");
|
Objects.requireNonNull(drawableSource, "drawableSource can't be null");
|
||||||
Objects.requireNonNull(defaultDrawableLoader, "defaultDrawableLoader 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);
|
return ParcelableResource.loadDefaultDrawable(defaultDrawableLoader);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mService != null) {
|
if (mService != null) {
|
||||||
try {
|
try {
|
||||||
ParcelableResource resource = mService.getDrawable(
|
ParcelableResource resource = mService.getDrawable(
|
||||||
drawableId, drawableStyle, drawableSource);
|
drawableId, drawableStyle, drawableSource);
|
||||||
if (resource == null) {
|
if (resource == null) {
|
||||||
return ParcelableResource.loadDefaultDrawable(
|
return ParcelableResource.loadDefaultDrawable(defaultDrawableLoader);
|
||||||
defaultDrawableLoader);
|
|
||||||
}
|
}
|
||||||
return resource.getDrawable(
|
return resource.getDrawable(
|
||||||
mContext,
|
mContext,
|
||||||
@@ -287,16 +295,20 @@ public class DevicePolicyResourcesManager {
|
|||||||
Objects.requireNonNull(drawableSource, "drawableSource can't be null");
|
Objects.requireNonNull(drawableSource, "drawableSource can't be null");
|
||||||
Objects.requireNonNull(defaultDrawableLoader, "defaultDrawableLoader 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);
|
return ParcelableResource.loadDefaultDrawable(defaultDrawableLoader);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mService != null) {
|
if (mService != null) {
|
||||||
try {
|
try {
|
||||||
ParcelableResource resource = mService.getDrawable(
|
ParcelableResource resource = mService.getDrawable(
|
||||||
drawableId, drawableStyle, drawableSource);
|
drawableId, drawableStyle, drawableSource);
|
||||||
if (resource == null) {
|
if (resource == null) {
|
||||||
return ParcelableResource.loadDefaultDrawable(
|
return ParcelableResource.loadDefaultDrawable(defaultDrawableLoader);
|
||||||
defaultDrawableLoader);
|
|
||||||
}
|
}
|
||||||
return resource.getDrawable(mContext, density, defaultDrawableLoader);
|
return resource.getDrawable(mContext, density, defaultDrawableLoader);
|
||||||
} catch (RemoteException e) {
|
} catch (RemoteException e) {
|
||||||
@@ -330,9 +342,14 @@ public class DevicePolicyResourcesManager {
|
|||||||
Objects.requireNonNull(drawableSource, "drawableSource can't be null");
|
Objects.requireNonNull(drawableSource, "drawableSource can't be null");
|
||||||
Objects.requireNonNull(defaultIcon, "defaultIcon 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;
|
return defaultIcon;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mService != null) {
|
if (mService != null) {
|
||||||
try {
|
try {
|
||||||
ParcelableResource resource = mService.getDrawable(
|
ParcelableResource resource = mService.getDrawable(
|
||||||
@@ -463,7 +480,10 @@ public class DevicePolicyResourcesManager {
|
|||||||
Objects.requireNonNull(stringId, "stringId can't be null");
|
Objects.requireNonNull(stringId, "stringId can't be null");
|
||||||
Objects.requireNonNull(defaultStringLoader, "defaultStringLoader 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);
|
return ParcelableResource.loadDefaultString(defaultStringLoader);
|
||||||
}
|
}
|
||||||
if (mService != null) {
|
if (mService != null) {
|
||||||
@@ -508,7 +528,10 @@ public class DevicePolicyResourcesManager {
|
|||||||
Objects.requireNonNull(stringId, "stringId can't be null");
|
Objects.requireNonNull(stringId, "stringId can't be null");
|
||||||
Objects.requireNonNull(defaultStringLoader, "defaultStringLoader 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);
|
return ParcelableResource.loadDefaultString(defaultStringLoader);
|
||||||
}
|
}
|
||||||
if (mService != null) {
|
if (mService != null) {
|
||||||
|
|||||||
Reference in New Issue
Block a user