Merge "rename callingPackageResourceId to resourceIdInCallingPackage" into tm-dev

This commit is contained in:
Kholoud Mohamed
2022-02-24 16:18:09 +00:00
committed by Android (Google) Code Review
4 changed files with 43 additions and 43 deletions

View File

@@ -1059,10 +1059,10 @@ package android.app.admin {
ctor public DevicePolicyDrawableResource(@NonNull android.content.Context, @NonNull String, @NonNull String, @NonNull String, @DrawableRes int); ctor public DevicePolicyDrawableResource(@NonNull android.content.Context, @NonNull String, @NonNull String, @NonNull String, @DrawableRes int);
ctor public DevicePolicyDrawableResource(@NonNull android.content.Context, @NonNull String, @NonNull String, @DrawableRes int); ctor public DevicePolicyDrawableResource(@NonNull android.content.Context, @NonNull String, @NonNull String, @DrawableRes int);
method public int describeContents(); method public int describeContents();
method @DrawableRes public int getCallingPackageResourceId();
method @NonNull public String getDrawableId(); method @NonNull public String getDrawableId();
method @NonNull public String getDrawableSource(); method @NonNull public String getDrawableSource();
method @NonNull public String getDrawableStyle(); method @NonNull public String getDrawableStyle();
method @DrawableRes public int getResourceIdInCallingPackage();
method public void writeToParcel(@NonNull android.os.Parcel, int); method public void writeToParcel(@NonNull android.os.Parcel, int);
field @NonNull public static final android.os.Parcelable.Creator<android.app.admin.DevicePolicyDrawableResource> CREATOR; field @NonNull public static final android.os.Parcelable.Creator<android.app.admin.DevicePolicyDrawableResource> CREATOR;
} }
@@ -1239,7 +1239,7 @@ package android.app.admin {
public final class DevicePolicyStringResource implements android.os.Parcelable { public final class DevicePolicyStringResource implements android.os.Parcelable {
ctor public DevicePolicyStringResource(@NonNull android.content.Context, @NonNull String, @StringRes int); ctor public DevicePolicyStringResource(@NonNull android.content.Context, @NonNull String, @StringRes int);
method public int describeContents(); method public int describeContents();
method public int getCallingPackageResourceId(); method public int getResourceIdInCallingPackage();
method @NonNull public String getStringId(); method @NonNull public String getStringId();
method public void writeToParcel(@NonNull android.os.Parcel, int); method public void writeToParcel(@NonNull android.os.Parcel, int);
field @NonNull public static final android.os.Parcelable.Creator<android.app.admin.DevicePolicyStringResource> CREATOR; field @NonNull public static final android.os.Parcelable.Creator<android.app.admin.DevicePolicyStringResource> CREATOR;

View File

@@ -38,7 +38,7 @@ public final class DevicePolicyDrawableResource implements Parcelable {
@NonNull private final @DevicePolicyResources.UpdatableDrawableId String mDrawableId; @NonNull private final @DevicePolicyResources.UpdatableDrawableId String mDrawableId;
@NonNull private final @DevicePolicyResources.UpdatableDrawableStyle String mDrawableStyle; @NonNull private final @DevicePolicyResources.UpdatableDrawableStyle String mDrawableStyle;
@NonNull private final @DevicePolicyResources.UpdatableDrawableSource String mDrawableSource; @NonNull private final @DevicePolicyResources.UpdatableDrawableSource String mDrawableSource;
private final @DrawableRes int mCallingPackageResourceId; private final @DrawableRes int mResourceIdInCallingPackage;
@NonNull private ParcelableResource mResource; @NonNull private ParcelableResource mResource;
/** /**
@@ -47,25 +47,25 @@ public final class DevicePolicyDrawableResource implements Parcelable {
* *
* <p>It will be used to update the drawable defined by {@code drawableId} with style * <p>It will be used to update the drawable defined by {@code drawableId} with style
* {@code drawableStyle} located in source {@code drawableSource} to the drawable with ID * {@code drawableStyle} located in source {@code drawableSource} to the drawable with ID
* {@code callingPackageResourceId} in the calling package</p> * {@code resourceIdInCallingPackage} in the calling package</p>
* *
* @param drawableId The ID of the drawable to update. * @param drawableId The ID of the drawable to update.
* @param drawableStyle The style of the drawable to update. * @param drawableStyle The style of the drawable to update.
* @param drawableSource The source of the drawable to update. * @param drawableSource The source of the drawable to update.
* @param callingPackageResourceId The ID of the drawable resource in the calling package to * @param resourceIdInCallingPackage The ID of the drawable resource in the calling package to
* use as an updated resource. * use as an updated resource.
* *
* @throws IllegalStateException if the resource with ID * @throws IllegalStateException if the resource with ID
* {@code callingPackageResourceId} doesn't exist in the {@code context} package. * {@code resourceIdInCallingPackage} doesn't exist in the {@code context} package.
*/ */
public DevicePolicyDrawableResource( public DevicePolicyDrawableResource(
@NonNull Context context, @NonNull Context context,
@NonNull @DevicePolicyResources.UpdatableDrawableId String drawableId, @NonNull @DevicePolicyResources.UpdatableDrawableId String drawableId,
@NonNull @DevicePolicyResources.UpdatableDrawableStyle String drawableStyle, @NonNull @DevicePolicyResources.UpdatableDrawableStyle String drawableStyle,
@NonNull @DevicePolicyResources.UpdatableDrawableSource String drawableSource, @NonNull @DevicePolicyResources.UpdatableDrawableSource String drawableSource,
@DrawableRes int callingPackageResourceId) { @DrawableRes int resourceIdInCallingPackage) {
this(drawableId, drawableStyle, drawableSource, callingPackageResourceId, this(drawableId, drawableStyle, drawableSource, resourceIdInCallingPackage,
new ParcelableResource(context, callingPackageResourceId, new ParcelableResource(context, resourceIdInCallingPackage,
ParcelableResource.RESOURCE_TYPE_DRAWABLE)); ParcelableResource.RESOURCE_TYPE_DRAWABLE));
} }
@@ -73,7 +73,7 @@ public final class DevicePolicyDrawableResource implements Parcelable {
@NonNull @DevicePolicyResources.UpdatableDrawableId String drawableId, @NonNull @DevicePolicyResources.UpdatableDrawableId String drawableId,
@NonNull @DevicePolicyResources.UpdatableDrawableStyle String drawableStyle, @NonNull @DevicePolicyResources.UpdatableDrawableStyle String drawableStyle,
@NonNull @DevicePolicyResources.UpdatableDrawableSource String drawableSource, @NonNull @DevicePolicyResources.UpdatableDrawableSource String drawableSource,
@DrawableRes int callingPackageResourceId, @DrawableRes int resourceIdInCallingPackage,
@NonNull ParcelableResource resource) { @NonNull ParcelableResource resource) {
Objects.requireNonNull(drawableId); Objects.requireNonNull(drawableId);
@@ -84,7 +84,7 @@ public final class DevicePolicyDrawableResource implements Parcelable {
this.mDrawableId = drawableId; this.mDrawableId = drawableId;
this.mDrawableStyle = drawableStyle; this.mDrawableStyle = drawableStyle;
this.mDrawableSource = drawableSource; this.mDrawableSource = drawableSource;
this.mCallingPackageResourceId = callingPackageResourceId; this.mResourceIdInCallingPackage = resourceIdInCallingPackage;
this.mResource = resource; this.mResource = resource;
} }
@@ -92,24 +92,24 @@ public final class DevicePolicyDrawableResource implements Parcelable {
* Creates an object containing the required information for updating an enterprise drawable * Creates an object containing the required information for updating an enterprise drawable
* resource using {@link DevicePolicyManager#setDrawables}. * resource using {@link DevicePolicyManager#setDrawables}.
* <p>It will be used to update the drawable defined by {@code drawableId} with style * <p>It will be used to update the drawable defined by {@code drawableId} with style
* {@code drawableStyle} to the drawable with ID {@code callingPackageResourceId} in the * {@code drawableStyle} to the drawable with ID {@code resourceIdInCallingPackage} in the
* calling package</p> * calling package</p>
* *
* @param drawableId The ID of the drawable to update. * @param drawableId The ID of the drawable to update.
* @param drawableStyle The style of the drawable to update. * @param drawableStyle The style of the drawable to update.
* @param callingPackageResourceId The ID of the drawable resource in the calling package to * @param resourceIdInCallingPackage The ID of the drawable resource in the calling package to
* use as an updated resource. * use as an updated resource.
* *
* @throws IllegalStateException if the resource with ID * @throws IllegalStateException if the resource with ID
* {@code callingPackageResourceId} doesn't exist in the calling package. * {@code resourceIdInCallingPackage} doesn't exist in the calling package.
*/ */
public DevicePolicyDrawableResource( public DevicePolicyDrawableResource(
@NonNull Context context, @NonNull Context context,
@NonNull @DevicePolicyResources.UpdatableDrawableId String drawableId, @NonNull @DevicePolicyResources.UpdatableDrawableId String drawableId,
@NonNull @DevicePolicyResources.UpdatableDrawableStyle String drawableStyle, @NonNull @DevicePolicyResources.UpdatableDrawableStyle String drawableStyle,
@DrawableRes int callingPackageResourceId) { @DrawableRes int resourceIdInCallingPackage) {
this(context, drawableId, drawableStyle, Drawables.Source.UNDEFINED, this(context, drawableId, drawableStyle, Drawables.Source.UNDEFINED,
callingPackageResourceId); resourceIdInCallingPackage);
} }
/** /**
@@ -144,8 +144,8 @@ public final class DevicePolicyDrawableResource implements Parcelable {
* resource. * resource.
*/ */
@DrawableRes @DrawableRes
public int getCallingPackageResourceId() { public int getResourceIdInCallingPackage() {
return mCallingPackageResourceId; return mResourceIdInCallingPackage;
} }
/** /**
@@ -166,14 +166,14 @@ public final class DevicePolicyDrawableResource implements Parcelable {
return mDrawableId.equals(other.mDrawableId) return mDrawableId.equals(other.mDrawableId)
&& mDrawableStyle.equals(other.mDrawableStyle) && mDrawableStyle.equals(other.mDrawableStyle)
&& mDrawableSource.equals(other.mDrawableSource) && mDrawableSource.equals(other.mDrawableSource)
&& mCallingPackageResourceId == other.mCallingPackageResourceId && mResourceIdInCallingPackage == other.mResourceIdInCallingPackage
&& mResource.equals(other.mResource); && mResource.equals(other.mResource);
} }
@Override @Override
public int hashCode() { public int hashCode() {
return Objects.hash( return Objects.hash(mDrawableId, mDrawableStyle, mDrawableSource,
mDrawableId, mDrawableStyle, mDrawableSource, mCallingPackageResourceId, mResource); mResourceIdInCallingPackage, mResource);
} }
@Override @Override
@@ -186,7 +186,7 @@ public final class DevicePolicyDrawableResource implements Parcelable {
dest.writeString(mDrawableId); dest.writeString(mDrawableId);
dest.writeString(mDrawableStyle); dest.writeString(mDrawableStyle);
dest.writeString(mDrawableSource); dest.writeString(mDrawableSource);
dest.writeInt(mCallingPackageResourceId); dest.writeInt(mResourceIdInCallingPackage);
dest.writeTypedObject(mResource, flags); dest.writeTypedObject(mResource, flags);
} }
@@ -197,11 +197,11 @@ public final class DevicePolicyDrawableResource implements Parcelable {
String drawableId = in.readString(); String drawableId = in.readString();
String drawableStyle = in.readString(); String drawableStyle = in.readString();
String drawableSource = in.readString(); String drawableSource = in.readString();
int callingPackageResourceId = in.readInt(); int resourceIdInCallingPackage = in.readInt();
ParcelableResource resource = in.readTypedObject(ParcelableResource.CREATOR); ParcelableResource resource = in.readTypedObject(ParcelableResource.CREATOR);
return new DevicePolicyDrawableResource( return new DevicePolicyDrawableResource(
drawableId, drawableStyle, drawableSource, callingPackageResourceId, drawableId, drawableStyle, drawableSource, resourceIdInCallingPackage,
resource); resource);
} }

View File

@@ -15134,7 +15134,7 @@ public class DevicePolicyManager {
* the combination of {@link DevicePolicyDrawableResource#getDrawableId()} and * the combination of {@link DevicePolicyDrawableResource#getDrawableId()} and
* {@link DevicePolicyDrawableResource#getDrawableStyle()}, (see * {@link DevicePolicyDrawableResource#getDrawableStyle()}, (see
* {@link DevicePolicyResources.Drawables} and {@link DevicePolicyResources.Drawables.Style}) to * {@link DevicePolicyResources.Drawables} and {@link DevicePolicyResources.Drawables.Style}) to
* the drawable with ID {@link DevicePolicyDrawableResource#getCallingPackageResourceId()}, * the drawable with ID {@link DevicePolicyDrawableResource#getResourceIdInCallingPackage()},
* meaning any system UI surface calling {@link #getDrawable} * meaning any system UI surface calling {@link #getDrawable}
* with {@code drawableId} and {@code drawableStyle} will get the new resource after this API * with {@code drawableId} and {@code drawableStyle} will get the new resource after this API
* is called. * is called.
@@ -15149,12 +15149,12 @@ public class DevicePolicyManager {
* <p>Important notes to consider when using this API: * <p>Important notes to consider when using this API:
* <ul> * <ul>
* <li>{@link #getDrawable} references the resource * <li>{@link #getDrawable} references the resource
* {@link DevicePolicyDrawableResource#getCallingPackageResourceId()} in the * {@link DevicePolicyDrawableResource#getResourceIdInCallingPackage()} in the
* calling package each time it gets called. You have to ensure that the resource is always * 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. * available in the calling package as long as it is used as an updated resource.
* <li>You still have to re-call {@code setDrawables} even if you only make changes to the * <li>You still have to re-call {@code setDrawables} even if you only make changes to the
* content of the resource with ID * content of the resource with ID
* {@link DevicePolicyDrawableResource#getCallingPackageResourceId()} as the content might be * {@link DevicePolicyDrawableResource#getResourceIdInCallingPackage()} as the content might be
* cached and would need updating. * cached and would need updating.
* </ul> * </ul>
* *

View File

@@ -35,7 +35,7 @@ import java.util.Objects;
@SystemApi @SystemApi
public final class DevicePolicyStringResource implements Parcelable { public final class DevicePolicyStringResource implements Parcelable {
@NonNull private final @DevicePolicyResources.UpdatableStringId String mStringId; @NonNull private final @DevicePolicyResources.UpdatableStringId String mStringId;
private final @StringRes int mCallingPackageResourceId; private final @StringRes int mResourceIdInCallingPackage;
@NonNull private ParcelableResource mResource; @NonNull private ParcelableResource mResource;
/** /**
@@ -43,32 +43,32 @@ public final class DevicePolicyStringResource implements Parcelable {
* resource using {@link DevicePolicyManager#setStrings}. * resource using {@link DevicePolicyManager#setStrings}.
* *
* <p>It will be used to update the string defined by {@code stringId} to the string with ID * <p>It will be used to update the string defined by {@code stringId} to the string with ID
* {@code callingPackageResourceId} in the calling package</p> * {@code resourceIdInCallingPackage} in the calling package</p>
* *
* @param stringId The ID of the string to update. * @param stringId The ID of the string to update.
* @param callingPackageResourceId The ID of the {@link StringRes} in the calling package to * @param resourceIdInCallingPackage The ID of the {@link StringRes} in the calling package to
* use as an updated resource. * use as an updated resource.
* *
* @throws IllegalStateException if the resource with ID {@code callingPackageResourceId} * @throws IllegalStateException if the resource with ID {@code resourceIdInCallingPackage}
* doesn't exist in the {@code context} package. * doesn't exist in the {@code context} package.
*/ */
public DevicePolicyStringResource( public DevicePolicyStringResource(
@NonNull Context context, @NonNull Context context,
@NonNull @DevicePolicyResources.UpdatableStringId String stringId, @NonNull @DevicePolicyResources.UpdatableStringId String stringId,
@StringRes int callingPackageResourceId) { @StringRes int resourceIdInCallingPackage) {
this(stringId, callingPackageResourceId, new ParcelableResource( this(stringId, resourceIdInCallingPackage, new ParcelableResource(
context, callingPackageResourceId, ParcelableResource.RESOURCE_TYPE_STRING)); context, resourceIdInCallingPackage, ParcelableResource.RESOURCE_TYPE_STRING));
} }
private DevicePolicyStringResource( private DevicePolicyStringResource(
@NonNull @DevicePolicyResources.UpdatableStringId String stringId, @NonNull @DevicePolicyResources.UpdatableStringId String stringId,
@StringRes int callingPackageResourceId, @StringRes int resourceIdInCallingPackage,
@NonNull ParcelableResource resource) { @NonNull ParcelableResource resource) {
Objects.requireNonNull(stringId, "stringId must be provided."); Objects.requireNonNull(stringId, "stringId must be provided.");
Objects.requireNonNull(resource, "ParcelableResource must be provided."); Objects.requireNonNull(resource, "ParcelableResource must be provided.");
this.mStringId = stringId; this.mStringId = stringId;
this.mCallingPackageResourceId = callingPackageResourceId; this.mResourceIdInCallingPackage = resourceIdInCallingPackage;
this.mResource = resource; this.mResource = resource;
} }
@@ -85,8 +85,8 @@ public final class DevicePolicyStringResource implements Parcelable {
* Returns the ID of the {@link StringRes} in the calling package to use as an updated * Returns the ID of the {@link StringRes} in the calling package to use as an updated
* resource. * resource.
*/ */
public int getCallingPackageResourceId() { public int getResourceIdInCallingPackage() {
return mCallingPackageResourceId; return mResourceIdInCallingPackage;
} }
/** /**
@@ -105,13 +105,13 @@ public final class DevicePolicyStringResource implements Parcelable {
if (o == null || getClass() != o.getClass()) return false; if (o == null || getClass() != o.getClass()) return false;
DevicePolicyStringResource other = (DevicePolicyStringResource) o; DevicePolicyStringResource other = (DevicePolicyStringResource) o;
return mStringId == other.mStringId return mStringId == other.mStringId
&& mCallingPackageResourceId == other.mCallingPackageResourceId && mResourceIdInCallingPackage == other.mResourceIdInCallingPackage
&& mResource.equals(other.mResource); && mResource.equals(other.mResource);
} }
@Override @Override
public int hashCode() { public int hashCode() {
return Objects.hash(mStringId, mCallingPackageResourceId, mResource); return Objects.hash(mStringId, mResourceIdInCallingPackage, mResource);
} }
@Override @Override
@@ -122,7 +122,7 @@ public final class DevicePolicyStringResource implements Parcelable {
@Override @Override
public void writeToParcel(@NonNull Parcel dest, int flags) { public void writeToParcel(@NonNull Parcel dest, int flags) {
dest.writeString(mStringId); dest.writeString(mStringId);
dest.writeInt(mCallingPackageResourceId); dest.writeInt(mResourceIdInCallingPackage);
dest.writeTypedObject(mResource, flags); dest.writeTypedObject(mResource, flags);
} }
@@ -131,10 +131,10 @@ public final class DevicePolicyStringResource implements Parcelable {
@Override @Override
public DevicePolicyStringResource createFromParcel(Parcel in) { public DevicePolicyStringResource createFromParcel(Parcel in) {
String stringId = in.readString(); String stringId = in.readString();
int callingPackageResourceId = in.readInt(); int resourceIdInCallingPackage = in.readInt();
ParcelableResource resource = in.readTypedObject(ParcelableResource.CREATOR); ParcelableResource resource = in.readTypedObject(ParcelableResource.CREATOR);
return new DevicePolicyStringResource(stringId, callingPackageResourceId, resource); return new DevicePolicyStringResource(stringId, resourceIdInCallingPackage, resource);
} }
@Override @Override