RESTRICT AUTOMERGE hide device policy resources constants
Bug: 218875965 Bug: 217388602 Test: atest EnterpriseResourcesTests Change-Id: Iac71c0d5b451e8ec77c0ca0113e2248ef21cc412
This commit is contained in:
@@ -7839,31 +7839,7 @@ package android.app.admin {
|
||||
}
|
||||
|
||||
public final class DevicePolicyResources {
|
||||
}
|
||||
|
||||
public static final class DevicePolicyResources.Drawables {
|
||||
field public static final String UNDEFINED = "UNDEFINED";
|
||||
field public static final String WORK_PROFILE_ICON = "WORK_PROFILE_ICON";
|
||||
field public static final String WORK_PROFILE_ICON_BADGE = "WORK_PROFILE_ICON_BADGE";
|
||||
field public static final String WORK_PROFILE_OFF_ICON = "WORK_PROFILE_OFF_ICON";
|
||||
field public static final String WORK_PROFILE_USER_ICON = "WORK_PROFILE_USER_ICON";
|
||||
}
|
||||
|
||||
public static final class DevicePolicyResources.Drawables.Source {
|
||||
field public static final String HOME_WIDGET = "HOME_WIDGET";
|
||||
field public static final String LAUNCHER_OFF_BUTTON = "LAUNCHER_OFF_BUTTON";
|
||||
field public static final String NOTIFICATION = "NOTIFICATION";
|
||||
field public static final String PROFILE_SWITCH_ANIMATION = "PROFILE_SWITCH_ANIMATION";
|
||||
field public static final String QUICK_SETTINGS = "QUICK_SETTINGS";
|
||||
field public static final String STATUS_BAR = "STATUS_BAR";
|
||||
field public static final String UNDEFINED = "UNDEFINED";
|
||||
}
|
||||
|
||||
public static final class DevicePolicyResources.Drawables.Style {
|
||||
field public static final String DEFAULT = "DEFAULT";
|
||||
field public static final String OUTLINE = "OUTLINE";
|
||||
field public static final String SOLID_COLORED = "SOLID_COLORED";
|
||||
field public static final String SOLID_NOT_COLORED = "SOLID_NOT_COLORED";
|
||||
}
|
||||
|
||||
public final class DnsEvent extends android.app.admin.NetworkEvent implements android.os.Parcelable {
|
||||
|
||||
@@ -1198,43 +1198,6 @@ package android.app.admin {
|
||||
}
|
||||
|
||||
public static final class DevicePolicyResources.Strings {
|
||||
field public static final String UNDEFINED = "UNDEFINED";
|
||||
}
|
||||
|
||||
public static final class DevicePolicyResources.Strings.Dialer {
|
||||
field public static final String NOTIFICATION_INCOMING_WORK_CALL_TITLE = "Dialer.NOTIFICATION_INCOMING_WORK_CALL_TITLE";
|
||||
field public static final String NOTIFICATION_MISSED_WORK_CALL_TITLE = "Dialer.NOTIFICATION_MISSED_WORK_CALL_TITLE";
|
||||
field public static final String NOTIFICATION_ONGOING_WORK_CALL_TITLE = "Dialer.NOTIFICATION_ONGOING_WORK_CALL_TITLE";
|
||||
field public static final String NOTIFICATION_WIFI_WORK_CALL_LABEL = "Dialer.NOTIFICATION_WIFI_WORK_CALL_LABEL";
|
||||
}
|
||||
|
||||
public static final class DevicePolicyResources.Strings.DocumentsUi {
|
||||
field public static final String CANT_SAVE_TO_PERSONAL_MESSAGE = "DocumentsUi.CANT_SAVE_TO_PERSONAL_MESSAGE";
|
||||
field public static final String CANT_SAVE_TO_PERSONAL_TITLE = "DocumentsUi.CANT_SAVE_TO_PERSONAL_TITLE";
|
||||
field public static final String CANT_SAVE_TO_WORK_MESSAGE = "DocumentsUi.CANT_SAVE_TO_WORK_MESSAGE";
|
||||
field public static final String CANT_SAVE_TO_WORK_TITLE = "DocumentsUi.CANT_SAVE_TO_WORK_TITLE";
|
||||
field public static final String CANT_SELECT_PERSONAL_FILES_MESSAGE = "DocumentsUi.CANT_SELECT_PERSONAL_FILES_MESSAGE";
|
||||
field public static final String CANT_SELECT_PERSONAL_FILES_TITLE = "DocumentsUi.CANT_SELECT_PERSONAL_FILES_TITLE";
|
||||
field public static final String CANT_SELECT_WORK_FILES_MESSAGE = "DocumentsUi.CANT_SELECT_WORK_FILES_MESSAGE";
|
||||
field public static final String CANT_SELECT_WORK_FILES_TITLE = "DocumentsUi.CANT_SELECT_WORK_FILES_TITLE";
|
||||
field public static final String CROSS_PROFILE_NOT_ALLOWED_MESSAGE = "DocumentsUi.CROSS_PROFILE_NOT_ALLOWED_MESSAGE";
|
||||
field public static final String CROSS_PROFILE_NOT_ALLOWED_TITLE = "DocumentsUi.CROSS_PROFILE_NOT_ALLOWED_TITLE";
|
||||
field public static final String PERSONAL_TAB = "DocumentsUi.PERSONAL_TAB";
|
||||
field public static final String PREVIEW_WORK_FILE_ACCESSIBILITY = "DocumentsUi.PREVIEW_WORK_FILE_ACCESSIBILITY";
|
||||
field public static final String WORK_ACCESSIBILITY = "DocumentsUi.WORK_ACCESSIBILITY";
|
||||
field public static final String WORK_PROFILE_OFF_ENABLE_BUTTON = "DocumentsUi.WORK_PROFILE_OFF_ENABLE_BUTTON";
|
||||
field public static final String WORK_PROFILE_OFF_ERROR_TITLE = "DocumentsUi.WORK_PROFILE_OFF_ERROR_TITLE";
|
||||
field public static final String WORK_TAB = "DocumentsUi.WORK_TAB";
|
||||
}
|
||||
|
||||
public static final class DevicePolicyResources.Strings.MediaProvider {
|
||||
field public static final String BLOCKED_BY_ADMIN_TITLE = "MediaProvider.BLOCKED_BY_ADMIN_TITLE";
|
||||
field public static final String BLOCKED_FROM_PERSONAL_MESSAGE = "MediaProvider.BLOCKED_FROM_PERSONAL_MESSAGE";
|
||||
field public static final String BLOCKED_FROM_WORK_MESSAGE = "MediaProvider.BLOCKED_FROM_WORK_MESSAGE";
|
||||
field public static final String SWITCH_TO_PERSONAL_MESSAGE = "MediaProvider.SWITCH_TO_PERSONAL_MESSAGE";
|
||||
field public static final String SWITCH_TO_WORK_MESSAGE = "MediaProvider.SWITCH_TO_WORK_MESSAGE";
|
||||
field public static final String WORK_PROFILE_PAUSED_MESSAGE = "MediaProvider.WORK_PROFILE_PAUSED_MESSAGE";
|
||||
field public static final String WORK_PROFILE_PAUSED_TITLE = "MediaProvider.WORK_PROFILE_PAUSED_TITLE";
|
||||
}
|
||||
|
||||
public static final class DevicePolicyResources.Strings.PermissionController {
|
||||
|
||||
@@ -20,7 +20,6 @@ import android.annotation.DrawableRes;
|
||||
import android.annotation.NonNull;
|
||||
import android.annotation.Nullable;
|
||||
import android.annotation.SystemApi;
|
||||
import android.app.admin.DevicePolicyResources.Drawables;
|
||||
import android.content.Context;
|
||||
import android.os.Parcel;
|
||||
import android.os.Parcelable;
|
||||
@@ -35,9 +34,9 @@ import java.util.Objects;
|
||||
*/
|
||||
@SystemApi
|
||||
public final class DevicePolicyDrawableResource implements Parcelable {
|
||||
@NonNull private final @DevicePolicyResources.UpdatableDrawableId String mDrawableId;
|
||||
@NonNull private final @DevicePolicyResources.UpdatableDrawableStyle String mDrawableStyle;
|
||||
@NonNull private final @DevicePolicyResources.UpdatableDrawableSource String mDrawableSource;
|
||||
@NonNull private final String mDrawableId;
|
||||
@NonNull private final String mDrawableStyle;
|
||||
@NonNull private final String mDrawableSource;
|
||||
private final @DrawableRes int mResourceIdInCallingPackage;
|
||||
@NonNull private ParcelableResource mResource;
|
||||
|
||||
@@ -60,9 +59,9 @@ public final class DevicePolicyDrawableResource implements Parcelable {
|
||||
*/
|
||||
public DevicePolicyDrawableResource(
|
||||
@NonNull Context context,
|
||||
@NonNull @DevicePolicyResources.UpdatableDrawableId String drawableId,
|
||||
@NonNull @DevicePolicyResources.UpdatableDrawableStyle String drawableStyle,
|
||||
@NonNull @DevicePolicyResources.UpdatableDrawableSource String drawableSource,
|
||||
@NonNull String drawableId,
|
||||
@NonNull String drawableStyle,
|
||||
@NonNull String drawableSource,
|
||||
@DrawableRes int resourceIdInCallingPackage) {
|
||||
this(drawableId, drawableStyle, drawableSource, resourceIdInCallingPackage,
|
||||
new ParcelableResource(context, resourceIdInCallingPackage,
|
||||
@@ -70,9 +69,9 @@ public final class DevicePolicyDrawableResource implements Parcelable {
|
||||
}
|
||||
|
||||
private DevicePolicyDrawableResource(
|
||||
@NonNull @DevicePolicyResources.UpdatableDrawableId String drawableId,
|
||||
@NonNull @DevicePolicyResources.UpdatableDrawableStyle String drawableStyle,
|
||||
@NonNull @DevicePolicyResources.UpdatableDrawableSource String drawableSource,
|
||||
@NonNull String drawableId,
|
||||
@NonNull String drawableStyle,
|
||||
@NonNull String drawableSource,
|
||||
@DrawableRes int resourceIdInCallingPackage,
|
||||
@NonNull ParcelableResource resource) {
|
||||
|
||||
@@ -105,10 +104,10 @@ public final class DevicePolicyDrawableResource implements Parcelable {
|
||||
*/
|
||||
public DevicePolicyDrawableResource(
|
||||
@NonNull Context context,
|
||||
@NonNull @DevicePolicyResources.UpdatableDrawableId String drawableId,
|
||||
@NonNull @DevicePolicyResources.UpdatableDrawableStyle String drawableStyle,
|
||||
@NonNull String drawableId,
|
||||
@NonNull String drawableStyle,
|
||||
@DrawableRes int resourceIdInCallingPackage) {
|
||||
this(context, drawableId, drawableStyle, Drawables.Source.UNDEFINED,
|
||||
this(context, drawableId, drawableStyle, DevicePolicyResources.UNDEFINED,
|
||||
resourceIdInCallingPackage);
|
||||
}
|
||||
|
||||
@@ -116,7 +115,6 @@ public final class DevicePolicyDrawableResource implements Parcelable {
|
||||
* Returns the ID of the drawable to update.
|
||||
*/
|
||||
@NonNull
|
||||
@DevicePolicyResources.UpdatableDrawableId
|
||||
public String getDrawableId() {
|
||||
return mDrawableId;
|
||||
}
|
||||
@@ -125,7 +123,6 @@ public final class DevicePolicyDrawableResource implements Parcelable {
|
||||
* Returns the style of the drawable to update
|
||||
*/
|
||||
@NonNull
|
||||
@DevicePolicyResources.UpdatableDrawableStyle
|
||||
public String getDrawableStyle() {
|
||||
return mDrawableStyle;
|
||||
}
|
||||
@@ -134,7 +131,6 @@ public final class DevicePolicyDrawableResource implements Parcelable {
|
||||
* Returns the source of the drawable to update.
|
||||
*/
|
||||
@NonNull
|
||||
@DevicePolicyResources.UpdatableDrawableSource
|
||||
public String getDrawableSource() {
|
||||
return mDrawableSource;
|
||||
}
|
||||
|
||||
@@ -15304,19 +15304,16 @@ public class DevicePolicyManager {
|
||||
|
||||
/**
|
||||
* For each {@link DevicePolicyDrawableResource} item in {@code drawables}, if
|
||||
* {@link DevicePolicyDrawableResource#getDrawableSource()} is not set or is set to
|
||||
* {@link DevicePolicyResources.Drawables.Source#UNDEFINED}, it updates the drawable resource for
|
||||
* the combination of {@link DevicePolicyDrawableResource#getDrawableId()} and
|
||||
* {@link DevicePolicyDrawableResource#getDrawableStyle()}, (see
|
||||
* {@link DevicePolicyResources.Drawables} and {@link DevicePolicyResources.Drawables.Style}) to
|
||||
* the drawable with ID {@link DevicePolicyDrawableResource#getResourceIdInCallingPackage()},
|
||||
* meaning any system UI surface calling {@link #getDrawable}
|
||||
* with {@code drawableId} and {@code drawableStyle} will get the new resource after this API
|
||||
* is called.
|
||||
* {@link DevicePolicyDrawableResource#getDrawableSource()} is not set, it updates the drawable
|
||||
* resource for the combination of {@link DevicePolicyDrawableResource#getDrawableId()} and
|
||||
* {@link DevicePolicyDrawableResource#getDrawableStyle()} to the drawable with resource ID
|
||||
* {@link DevicePolicyDrawableResource#getResourceIdInCallingPackage()},
|
||||
* meaning any system UI surface calling {@link #getDrawable} with {@code drawableId} and
|
||||
* {@code drawableStyle} will get the new resource after this API is called.
|
||||
*
|
||||
* <p>Otherwise, if {@link DevicePolicyDrawableResource#getDrawableSource()} is set (see
|
||||
* {@link DevicePolicyResources.Drawables.Source}, it overrides any drawables that was set for
|
||||
* the same {@code drawableId} and {@code drawableStyle} for the provided source.
|
||||
* <p>Otherwise, if {@link DevicePolicyDrawableResource#getDrawableSource()} is set, it
|
||||
* overrides any drawables that was set for the same {@code drawableId} and
|
||||
* {@code drawableStyle} for the provided source.
|
||||
*
|
||||
* <p>Sends a broadcast with action {@link #ACTION_DEVICE_POLICY_RESOURCE_UPDATED} to
|
||||
* registered receivers when a resource has been updated successfully.
|
||||
@@ -15350,12 +15347,10 @@ public class DevicePolicyManager {
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes all updated drawables for the list of {@code drawableIds} (see
|
||||
* {@link DevicePolicyResources.Drawables} that was previously set by calling
|
||||
* {@link #setDrawables}, meaning any subsequent calls to {@link #getDrawable} for the provided
|
||||
* IDs with any {@link DevicePolicyResources.Drawables.Style} and any
|
||||
* {@link DevicePolicyResources.Drawables.Source} will return the default drawable from
|
||||
* {@code defaultDrawableLoader}.
|
||||
* Removes all updated drawables for the list of {@code drawableIds} that was previously set by
|
||||
* calling {@link #setDrawables}, meaning any subsequent calls to {@link #getDrawable} for the
|
||||
* provided IDs with any {@code drawableStyle} and any {@code drawableSource} will return the
|
||||
* default drawable from {@code defaultDrawableLoader}.
|
||||
*
|
||||
* <p>Sends a broadcast with action {@link #ACTION_DEVICE_POLICY_RESOURCE_UPDATED} to
|
||||
* registered receivers when a resource has been reset successfully.
|
||||
@@ -15377,13 +15372,12 @@ public class DevicePolicyManager {
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the appropriate updated drawable for the {@code drawableId}
|
||||
* (see {@link DevicePolicyResources.Drawables}), with style {@code drawableStyle}
|
||||
* (see {@link DevicePolicyResources.Drawables.Style}) if one was set using
|
||||
* {@code setDrawables}, otherwise returns the drawable from {@code defaultDrawableLoader}.
|
||||
* Returns the appropriate updated drawable for the {@code drawableId} with style
|
||||
* {@code drawableStyle} if one was set using {@code setDrawables}, otherwise returns the
|
||||
* drawable from {@code defaultDrawableLoader}.
|
||||
*
|
||||
* <p>Also returns the drawable from {@code defaultDrawableLoader} if
|
||||
* {@link DevicePolicyResources.Drawables#UNDEFINED} was passed.
|
||||
* <p>Also returns the drawable from {@code defaultDrawableLoader} if {@code drawableId}
|
||||
* is {@link DevicePolicyResources#UNDEFINED}.
|
||||
*
|
||||
* <p>Calls to this API will not return {@code null} unless no updated drawable was found
|
||||
* and the call to {@code defaultDrawableLoader} returned {@code null}.
|
||||
@@ -15405,19 +15399,22 @@ public class DevicePolicyManager {
|
||||
*/
|
||||
@Nullable
|
||||
public Drawable getDrawable(
|
||||
@NonNull @DevicePolicyResources.UpdatableDrawableId String drawableId,
|
||||
@NonNull @DevicePolicyResources.UpdatableDrawableStyle String drawableStyle,
|
||||
@NonNull String drawableId,
|
||||
@NonNull String drawableStyle,
|
||||
@NonNull Supplier<Drawable> defaultDrawableLoader) {
|
||||
return getDrawable(
|
||||
drawableId, drawableStyle, Drawables.Source.UNDEFINED, defaultDrawableLoader);
|
||||
drawableId, drawableStyle, DevicePolicyResources.UNDEFINED, defaultDrawableLoader);
|
||||
}
|
||||
|
||||
/**
|
||||
* Similar to {@link #getDrawable(String, String, Supplier)}, but also accepts
|
||||
* a {@code drawableSource} (see {@link DevicePolicyResources.Drawables.Source}) which
|
||||
* could result in returning a different drawable than
|
||||
* {@link #getDrawable(String, String, Supplier)}
|
||||
* if an override was set for that specific source.
|
||||
* a {@code drawableSource} which could result in returning a different drawable than
|
||||
* {@link #getDrawable(String, String, Supplier)} if an override was set for that specific
|
||||
* source.
|
||||
*
|
||||
* <p> If {@code drawableSource} is {@link DevicePolicyResources#UNDEFINED}, it returns the
|
||||
* appropriate string for {@code drawableId} and {@code drawableStyle} similar to
|
||||
* {@link #getDrawable(String, String, Supplier)}.
|
||||
*
|
||||
* <p>Calls to this API will not return {@code null} unless no updated drawable was found
|
||||
* and the call to {@code defaultDrawableLoader} returned {@code null}.
|
||||
@@ -15433,9 +15430,9 @@ public class DevicePolicyManager {
|
||||
*/
|
||||
@Nullable
|
||||
public Drawable getDrawable(
|
||||
@NonNull @DevicePolicyResources.UpdatableDrawableId String drawableId,
|
||||
@NonNull @DevicePolicyResources.UpdatableDrawableStyle String drawableStyle,
|
||||
@NonNull @DevicePolicyResources.UpdatableDrawableSource String drawableSource,
|
||||
@NonNull String drawableId,
|
||||
@NonNull String drawableStyle,
|
||||
@NonNull String drawableSource,
|
||||
@NonNull Supplier<Drawable> defaultDrawableLoader) {
|
||||
|
||||
Objects.requireNonNull(drawableId, "drawableId can't be null");
|
||||
@@ -15443,7 +15440,7 @@ public class DevicePolicyManager {
|
||||
Objects.requireNonNull(drawableSource, "drawableSource can't be null");
|
||||
Objects.requireNonNull(defaultDrawableLoader, "defaultDrawableLoader can't be null");
|
||||
|
||||
if (Drawables.UNDEFINED.equals(drawableId)) {
|
||||
if (drawableId.equals(DevicePolicyResources.UNDEFINED)) {
|
||||
return ParcelableResource.loadDefaultDrawable(defaultDrawableLoader);
|
||||
}
|
||||
if (mService != null) {
|
||||
@@ -15490,14 +15487,14 @@ public class DevicePolicyManager {
|
||||
*/
|
||||
@Nullable
|
||||
public Drawable getDrawableForDensity(
|
||||
@NonNull @DevicePolicyResources.UpdatableDrawableId String drawableId,
|
||||
@NonNull @DevicePolicyResources.UpdatableDrawableStyle String drawableStyle,
|
||||
@NonNull String drawableId,
|
||||
@NonNull String drawableStyle,
|
||||
int density,
|
||||
@NonNull Supplier<Drawable> defaultDrawableLoader) {
|
||||
return getDrawableForDensity(
|
||||
drawableId,
|
||||
drawableStyle,
|
||||
Drawables.Source.UNDEFINED,
|
||||
DevicePolicyResources.UNDEFINED,
|
||||
density,
|
||||
defaultDrawableLoader);
|
||||
}
|
||||
@@ -15506,8 +15503,8 @@ public class DevicePolicyManager {
|
||||
* Similar to {@link #getDrawable(String, String, String, Supplier)}, but also accepts
|
||||
* {@code density}. See {@link Resources#getDrawableForDensity(int, int, Resources.Theme)}.
|
||||
*
|
||||
* <p>Calls to this API will not return {@code null} unless no updated drawable was found
|
||||
* and the call to {@code defaultDrawableLoader} returned {@code null}.
|
||||
* <p>Calls to this API will not return {@code null} unless no updated drawable was found
|
||||
* and the call to {@code defaultDrawableLoader} returned {@code null}.
|
||||
*
|
||||
* <p>Callers should register for {@link #ACTION_DEVICE_POLICY_RESOURCE_UPDATED} to get
|
||||
* notified when a resource has been updated.
|
||||
@@ -15523,9 +15520,9 @@ public class DevicePolicyManager {
|
||||
*/
|
||||
@Nullable
|
||||
public Drawable getDrawableForDensity(
|
||||
@NonNull @DevicePolicyResources.UpdatableDrawableId String drawableId,
|
||||
@NonNull @DevicePolicyResources.UpdatableDrawableStyle String drawableStyle,
|
||||
@NonNull @DevicePolicyResources.UpdatableDrawableSource String drawableSource,
|
||||
@NonNull String drawableId,
|
||||
@NonNull String drawableStyle,
|
||||
@NonNull String drawableSource,
|
||||
int density,
|
||||
@NonNull Supplier<Drawable> defaultDrawableLoader) {
|
||||
|
||||
@@ -15534,7 +15531,7 @@ public class DevicePolicyManager {
|
||||
Objects.requireNonNull(drawableSource, "drawableSource can't be null");
|
||||
Objects.requireNonNull(defaultDrawableLoader, "defaultDrawableLoader can't be null");
|
||||
|
||||
if (Drawables.UNDEFINED.equals(drawableId)) {
|
||||
if (drawableId.equals(DevicePolicyResources.UNDEFINED)) {
|
||||
return ParcelableResource.loadDefaultDrawable(defaultDrawableLoader);
|
||||
}
|
||||
if (mService != null) {
|
||||
@@ -15568,16 +15565,16 @@ public class DevicePolicyManager {
|
||||
*/
|
||||
@Nullable
|
||||
public Icon getDrawableAsIcon(
|
||||
@NonNull @DevicePolicyResources.UpdatableDrawableId String drawableId,
|
||||
@NonNull @DevicePolicyResources.UpdatableDrawableStyle String drawableStyle,
|
||||
@NonNull @DevicePolicyResources.UpdatableDrawableSource String drawableSource,
|
||||
@NonNull String drawableId,
|
||||
@NonNull String drawableStyle,
|
||||
@NonNull String drawableSource,
|
||||
@Nullable Icon defaultIcon) {
|
||||
Objects.requireNonNull(drawableId, "drawableId can't be null");
|
||||
Objects.requireNonNull(drawableStyle, "drawableStyle can't be null");
|
||||
Objects.requireNonNull(drawableSource, "drawableSource can't be null");
|
||||
Objects.requireNonNull(defaultIcon, "defaultIcon can't be null");
|
||||
|
||||
if (Drawables.UNDEFINED.equals(drawableId)) {
|
||||
if (drawableId.equals(DevicePolicyResources.UNDEFINED)) {
|
||||
return defaultIcon;
|
||||
}
|
||||
if (mService != null) {
|
||||
@@ -15609,30 +15606,28 @@ public class DevicePolicyManager {
|
||||
*/
|
||||
@Nullable
|
||||
public Icon getDrawableAsIcon(
|
||||
@NonNull @DevicePolicyResources.UpdatableDrawableId String drawableId,
|
||||
@NonNull @DevicePolicyResources.UpdatableDrawableStyle String drawableStyle,
|
||||
@NonNull String drawableId,
|
||||
@NonNull String drawableStyle,
|
||||
@Nullable Icon defaultIcon) {
|
||||
return getDrawableAsIcon(
|
||||
drawableId, drawableStyle, Drawables.Source.UNDEFINED, defaultIcon);
|
||||
drawableId, drawableStyle, DevicePolicyResources.UNDEFINED, defaultIcon);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* For each {@link DevicePolicyStringResource} item in {@code strings}, it updates the string
|
||||
* resource for {@link DevicePolicyStringResource#getStringId()} to the string with ID
|
||||
* {@code callingPackageResourceId} (see {@link DevicePolicyResources.Strings}), meaning any
|
||||
* system UI surface calling {@link #getString} with {@code stringId} will get
|
||||
* the new resource after this API is called.
|
||||
* {@code callingPackageResourceId}, meaning any system UI surface calling {@link #getString}
|
||||
* with {@code stringId} will get the new resource after this API is called.
|
||||
*
|
||||
* <p>Sends a broadcast with action {@link #ACTION_DEVICE_POLICY_RESOURCE_UPDATED} to
|
||||
* registered receivers when a resource has been updated successfully.
|
||||
*
|
||||
* <p>Important notes to consider when using this API:
|
||||
* <ul>
|
||||
* <li> {@link #getString} references the resource
|
||||
* {@code callingPackageResourceId} in the calling package each time it gets called. You have to
|
||||
* ensure that the resource is always available in the calling package as long as it is used as
|
||||
* an updated resource.
|
||||
* <li> {@link #getString} references the resource {@code callingPackageResourceId} in the
|
||||
* calling package each time it gets called. You have to ensure that the resource is always
|
||||
* available in the calling package as long as it is used as an updated resource.
|
||||
* <li> You still have to re-call {@code setStrings} even if you only make changes to the
|
||||
* content of the resource with ID {@code callingPackageResourceId} as the content might be
|
||||
* cached and would need updating.
|
||||
@@ -15655,10 +15650,9 @@ public class DevicePolicyManager {
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes the updated strings for the list of {@code stringIds} (see
|
||||
* {@link DevicePolicyResources.Strings}) that was previously set by calling {@link #setStrings},
|
||||
* meaning any subsequent calls to {@link #getString} for the provided IDs will
|
||||
* return the default string from {@code defaultStringLoader}.
|
||||
* Removes the updated strings for the list of {@code stringIds} that was previously set by
|
||||
* calling {@link #setStrings}, meaning any subsequent calls to {@link #getString} for the
|
||||
* provided IDs will return the default string from {@code defaultStringLoader}.
|
||||
*
|
||||
* <p>Sends a broadcast with action {@link #ACTION_DEVICE_POLICY_RESOURCE_UPDATED} to
|
||||
* registered receivers when a resource has been reset successfully.
|
||||
@@ -15684,8 +15678,8 @@ public class DevicePolicyManager {
|
||||
* {@link DevicePolicyResources.Strings}) if one was set using
|
||||
* {@code setStrings}, otherwise returns the string from {@code defaultStringLoader}.
|
||||
*
|
||||
* <p>Also returns the string from {@code defaultStringLoader} if
|
||||
* {@link DevicePolicyResources.Strings#UNDEFINED} was passed.
|
||||
* <p>Also returns the string from {@code defaultStringLoader} if {@code stringId} is
|
||||
* {@link DevicePolicyResources#UNDEFINED}.
|
||||
*
|
||||
* <p>Calls to this API will not return {@code null} unless no updated drawable was found
|
||||
* and the call to {@code defaultStringLoader} returned {@code null}.
|
||||
@@ -15702,13 +15696,13 @@ public class DevicePolicyManager {
|
||||
*/
|
||||
@Nullable
|
||||
public String getString(
|
||||
@NonNull @DevicePolicyResources.UpdatableStringId String stringId,
|
||||
@NonNull String stringId,
|
||||
@NonNull Supplier<String> defaultStringLoader) {
|
||||
|
||||
Objects.requireNonNull(stringId, "stringId can't be null");
|
||||
Objects.requireNonNull(defaultStringLoader, "defaultStringLoader can't be null");
|
||||
|
||||
if (stringId.equals(DevicePolicyResources.Strings.UNDEFINED)) {
|
||||
if (stringId.equals(DevicePolicyResources.UNDEFINED)) {
|
||||
return ParcelableResource.loadDefaultString(defaultStringLoader);
|
||||
}
|
||||
if (mService != null) {
|
||||
@@ -15746,14 +15740,14 @@ public class DevicePolicyManager {
|
||||
@Nullable
|
||||
@SuppressLint("SamShouldBeLast")
|
||||
public String getString(
|
||||
@NonNull @DevicePolicyResources.UpdatableStringId String stringId,
|
||||
@NonNull String stringId,
|
||||
@NonNull Supplier<String> defaultStringLoader,
|
||||
@NonNull Object... formatArgs) {
|
||||
|
||||
Objects.requireNonNull(stringId, "stringId can't be null");
|
||||
Objects.requireNonNull(defaultStringLoader, "defaultStringLoader can't be null");
|
||||
|
||||
if (stringId.equals(DevicePolicyResources.Strings.UNDEFINED)) {
|
||||
if (stringId.equals(DevicePolicyResources.UNDEFINED)) {
|
||||
return ParcelableResource.loadDefaultString(defaultStringLoader);
|
||||
}
|
||||
if (mService != null) {
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -34,7 +34,7 @@ import java.util.Objects;
|
||||
*/
|
||||
@SystemApi
|
||||
public final class DevicePolicyStringResource implements Parcelable {
|
||||
@NonNull private final @DevicePolicyResources.UpdatableStringId String mStringId;
|
||||
@NonNull private final String mStringId;
|
||||
private final @StringRes int mResourceIdInCallingPackage;
|
||||
@NonNull private ParcelableResource mResource;
|
||||
|
||||
@@ -54,14 +54,14 @@ public final class DevicePolicyStringResource implements Parcelable {
|
||||
*/
|
||||
public DevicePolicyStringResource(
|
||||
@NonNull Context context,
|
||||
@NonNull @DevicePolicyResources.UpdatableStringId String stringId,
|
||||
@NonNull String stringId,
|
||||
@StringRes int resourceIdInCallingPackage) {
|
||||
this(stringId, resourceIdInCallingPackage, new ParcelableResource(
|
||||
context, resourceIdInCallingPackage, ParcelableResource.RESOURCE_TYPE_STRING));
|
||||
}
|
||||
|
||||
private DevicePolicyStringResource(
|
||||
@NonNull @DevicePolicyResources.UpdatableStringId String stringId,
|
||||
@NonNull String stringId,
|
||||
@StringRes int resourceIdInCallingPackage,
|
||||
@NonNull ParcelableResource resource) {
|
||||
Objects.requireNonNull(stringId, "stringId must be provided.");
|
||||
@@ -75,7 +75,6 @@ public final class DevicePolicyStringResource implements Parcelable {
|
||||
/**
|
||||
* Returns the ID of the string to update.
|
||||
*/
|
||||
@DevicePolicyResources.UpdatableStringId
|
||||
@NonNull
|
||||
public String getStringId() {
|
||||
return mStringId;
|
||||
|
||||
@@ -16,17 +16,14 @@
|
||||
|
||||
package com.android.server.devicepolicy;
|
||||
|
||||
import static android.app.admin.DevicePolicyResources.Drawables.Source.UPDATABLE_DRAWABLE_SOURCES;
|
||||
import static android.app.admin.DevicePolicyResources.Drawables.Style;
|
||||
import static android.app.admin.DevicePolicyResources.Drawables.Style.UPDATABLE_DRAWABLE_STYLES;
|
||||
import static android.app.admin.DevicePolicyResources.Drawables.UPDATABLE_DRAWABLE_IDS;
|
||||
import static android.app.admin.DevicePolicyResources.Strings.UPDATABLE_STRING_IDS;
|
||||
|
||||
import static java.util.Objects.requireNonNull;
|
||||
|
||||
import android.annotation.NonNull;
|
||||
import android.annotation.Nullable;
|
||||
import android.app.admin.DevicePolicyDrawableResource;
|
||||
import android.app.admin.DevicePolicyResources;
|
||||
import android.app.admin.DevicePolicyResources.Drawables;
|
||||
import android.app.admin.DevicePolicyStringResource;
|
||||
import android.app.admin.ParcelableResource;
|
||||
@@ -113,7 +110,7 @@ class DeviceManagementResourcesProvider {
|
||||
Objects.requireNonNull(drawableSource, "drawableSource must be provided.");
|
||||
Objects.requireNonNull(resource, "ParcelableResource must be provided.");
|
||||
|
||||
if (Drawables.Source.UNDEFINED.equals(drawableSource)) {
|
||||
if (DevicePolicyResources.UNDEFINED.equals(drawableSource)) {
|
||||
updated |= updateDrawable(drawableId, drawableStyle, resource);
|
||||
} else {
|
||||
updated |= updateDrawableForSource(drawableId, drawableSource, resource);
|
||||
@@ -130,12 +127,6 @@ class DeviceManagementResourcesProvider {
|
||||
|
||||
private boolean updateDrawable(
|
||||
String drawableId, String drawableStyle, ParcelableResource updatableResource) {
|
||||
if (!UPDATABLE_DRAWABLE_IDS.contains(drawableId)) {
|
||||
Log.w(TAG, "Updating a resource for an unknown drawable id " + drawableId);
|
||||
}
|
||||
if (!UPDATABLE_DRAWABLE_STYLES.contains(drawableStyle)) {
|
||||
Log.w(TAG, "Updating a resource for an unknown style id " + drawableStyle);
|
||||
}
|
||||
synchronized (mLock) {
|
||||
if (!mUpdatedDrawablesForStyle.containsKey(drawableId)) {
|
||||
mUpdatedDrawablesForStyle.put(drawableId, new HashMap<>());
|
||||
@@ -153,12 +144,6 @@ class DeviceManagementResourcesProvider {
|
||||
// TODO(b/214576716): change this to respect style
|
||||
private boolean updateDrawableForSource(
|
||||
String drawableId, String drawableSource, ParcelableResource updatableResource) {
|
||||
if (!UPDATABLE_DRAWABLE_IDS.contains(drawableId)) {
|
||||
Log.w(TAG, "Updating a resource for an unknown drawable id " + drawableId);
|
||||
}
|
||||
if (!UPDATABLE_DRAWABLE_SOURCES.contains(drawableSource)) {
|
||||
Log.w(TAG, "Updating a resource for an unknown source id " + drawableSource);
|
||||
}
|
||||
synchronized (mLock) {
|
||||
if (!mUpdatedDrawablesForSource.containsKey(drawableId)) {
|
||||
mUpdatedDrawablesForSource.put(drawableId, new HashMap<>());
|
||||
@@ -195,17 +180,6 @@ class DeviceManagementResourcesProvider {
|
||||
@Nullable
|
||||
ParcelableResource getDrawable(
|
||||
String drawableId, String drawableStyle, String drawableSource) {
|
||||
if (!UPDATABLE_DRAWABLE_IDS.contains(drawableId)) {
|
||||
Log.w(TAG, "Getting an updated resource for an unknown drawable id " + drawableId);
|
||||
}
|
||||
if (!UPDATABLE_DRAWABLE_STYLES.contains(drawableStyle)) {
|
||||
Log.w(TAG, "Getting an updated resource for an unknown drawable style "
|
||||
+ drawableStyle);
|
||||
}
|
||||
if (!UPDATABLE_DRAWABLE_SOURCES.contains(drawableSource)) {
|
||||
Log.w(TAG, "Getting an updated resource for an unknown drawable Source "
|
||||
+ drawableSource);
|
||||
}
|
||||
if (mUpdatedDrawablesForSource.containsKey(drawableId)
|
||||
&& mUpdatedDrawablesForSource.get(drawableId).containsKey(drawableSource)) {
|
||||
return mUpdatedDrawablesForSource.get(drawableId).get(drawableSource);
|
||||
@@ -217,10 +191,6 @@ class DeviceManagementResourcesProvider {
|
||||
if (mUpdatedDrawablesForStyle.get(drawableId).containsKey(drawableStyle)) {
|
||||
return mUpdatedDrawablesForStyle.get(drawableId).get(drawableStyle);
|
||||
}
|
||||
|
||||
if (mUpdatedDrawablesForStyle.get(drawableId).containsKey(Style.DEFAULT)) {
|
||||
return mUpdatedDrawablesForStyle.get(drawableId).get(Style.DEFAULT);
|
||||
}
|
||||
Log.d(TAG, "No updated drawable found for drawable id " + drawableId);
|
||||
return null;
|
||||
}
|
||||
@@ -249,9 +219,6 @@ class DeviceManagementResourcesProvider {
|
||||
}
|
||||
|
||||
private boolean updateString(String stringId, ParcelableResource updatableResource) {
|
||||
if (!UPDATABLE_STRING_IDS.contains(stringId)) {
|
||||
Log.w(TAG, "Updating a resource for an unknown string id " + stringId);
|
||||
}
|
||||
synchronized (mLock) {
|
||||
ParcelableResource current = mUpdatedStrings.get(stringId);
|
||||
if (updatableResource.equals(current)) {
|
||||
@@ -282,10 +249,6 @@ class DeviceManagementResourcesProvider {
|
||||
|
||||
@Nullable
|
||||
ParcelableResource getString(String stringId) {
|
||||
if (!UPDATABLE_STRING_IDS.contains(stringId)) {
|
||||
Log.w(TAG, "Getting an updated resource for an unknown string id " + stringId);
|
||||
}
|
||||
|
||||
if (mUpdatedStrings.containsKey(stringId)) {
|
||||
return mUpdatedStrings.get(stringId);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user