Merge "Change Callable to Supplier in the dpm resource apis" into tm-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
7e76fddc52
@@ -7390,12 +7390,12 @@ package android.app.admin {
|
|||||||
method @NonNull public java.util.List<java.lang.String> getDelegatedScopes(@Nullable android.content.ComponentName, @NonNull String);
|
method @NonNull public java.util.List<java.lang.String> getDelegatedScopes(@Nullable android.content.ComponentName, @NonNull String);
|
||||||
method @Nullable public String getDeviceManagerRoleHolderPackageName();
|
method @Nullable public String getDeviceManagerRoleHolderPackageName();
|
||||||
method public CharSequence getDeviceOwnerLockScreenInfo();
|
method public CharSequence getDeviceOwnerLockScreenInfo();
|
||||||
method @Nullable public android.graphics.drawable.Drawable getDrawable(@NonNull String, @NonNull String, @NonNull java.util.concurrent.Callable<android.graphics.drawable.Drawable>);
|
method @Nullable public android.graphics.drawable.Drawable getDrawable(@NonNull String, @NonNull String, @NonNull java.util.function.Supplier<android.graphics.drawable.Drawable>);
|
||||||
method @Nullable public android.graphics.drawable.Drawable getDrawable(@NonNull String, @NonNull String, @NonNull String, @NonNull java.util.concurrent.Callable<android.graphics.drawable.Drawable>);
|
method @Nullable public android.graphics.drawable.Drawable getDrawable(@NonNull String, @NonNull String, @NonNull String, @NonNull java.util.function.Supplier<android.graphics.drawable.Drawable>);
|
||||||
method @Nullable public android.graphics.drawable.Icon getDrawableAsIcon(@NonNull String, @NonNull String, @NonNull String, @Nullable android.graphics.drawable.Icon);
|
method @Nullable public android.graphics.drawable.Icon getDrawableAsIcon(@NonNull String, @NonNull String, @NonNull String, @Nullable android.graphics.drawable.Icon);
|
||||||
method @Nullable public android.graphics.drawable.Icon getDrawableAsIcon(@NonNull String, @NonNull String, @Nullable android.graphics.drawable.Icon);
|
method @Nullable public android.graphics.drawable.Icon getDrawableAsIcon(@NonNull String, @NonNull String, @Nullable android.graphics.drawable.Icon);
|
||||||
method @Nullable public android.graphics.drawable.Drawable getDrawableForDensity(@NonNull String, @NonNull String, int, @NonNull java.util.concurrent.Callable<android.graphics.drawable.Drawable>);
|
method @Nullable public android.graphics.drawable.Drawable getDrawableForDensity(@NonNull String, @NonNull String, int, @NonNull java.util.function.Supplier<android.graphics.drawable.Drawable>);
|
||||||
method @Nullable public android.graphics.drawable.Drawable getDrawableForDensity(@NonNull String, @NonNull String, @NonNull String, int, @NonNull java.util.concurrent.Callable<android.graphics.drawable.Drawable>);
|
method @Nullable public android.graphics.drawable.Drawable getDrawableForDensity(@NonNull String, @NonNull String, @NonNull String, int, @NonNull java.util.function.Supplier<android.graphics.drawable.Drawable>);
|
||||||
method public CharSequence getEndUserSessionMessage(@NonNull android.content.ComponentName);
|
method public CharSequence getEndUserSessionMessage(@NonNull android.content.ComponentName);
|
||||||
method @NonNull public String getEnrollmentSpecificId();
|
method @NonNull public String getEnrollmentSpecificId();
|
||||||
method @Nullable public android.app.admin.FactoryResetProtectionPolicy getFactoryResetProtectionPolicy(@Nullable android.content.ComponentName);
|
method @Nullable public android.app.admin.FactoryResetProtectionPolicy getFactoryResetProtectionPolicy(@Nullable android.content.ComponentName);
|
||||||
|
|||||||
@@ -1088,8 +1088,8 @@ package android.app.admin {
|
|||||||
method @Nullable @RequiresPermission(anyOf={android.Manifest.permission.MANAGE_USERS, android.Manifest.permission.QUERY_ADMIN_POLICY}) public java.util.List<java.lang.String> getPermittedInputMethodsForCurrentUser();
|
method @Nullable @RequiresPermission(anyOf={android.Manifest.permission.MANAGE_USERS, android.Manifest.permission.QUERY_ADMIN_POLICY}) public java.util.List<java.lang.String> getPermittedInputMethodsForCurrentUser();
|
||||||
method @Nullable public android.content.ComponentName getProfileOwner() throws java.lang.IllegalArgumentException;
|
method @Nullable public android.content.ComponentName getProfileOwner() throws java.lang.IllegalArgumentException;
|
||||||
method @Nullable @RequiresPermission(anyOf={android.Manifest.permission.MANAGE_USERS, android.Manifest.permission.MANAGE_PROFILE_AND_DEVICE_OWNERS}) public String getProfileOwnerNameAsUser(int) throws java.lang.IllegalArgumentException;
|
method @Nullable @RequiresPermission(anyOf={android.Manifest.permission.MANAGE_USERS, android.Manifest.permission.MANAGE_PROFILE_AND_DEVICE_OWNERS}) public String getProfileOwnerNameAsUser(int) throws java.lang.IllegalArgumentException;
|
||||||
method @Nullable public String getString(@NonNull String, @NonNull java.util.concurrent.Callable<java.lang.String>);
|
method @Nullable public String getString(@NonNull String, @NonNull java.util.function.Supplier<java.lang.String>);
|
||||||
method @Nullable public String getString(@NonNull String, @NonNull java.util.concurrent.Callable<java.lang.String>, @NonNull java.lang.Object...);
|
method @Nullable public String getString(@NonNull String, @NonNull java.util.function.Supplier<java.lang.String>, @NonNull java.lang.Object...);
|
||||||
method @RequiresPermission(anyOf={android.Manifest.permission.MANAGE_USERS, android.Manifest.permission.MANAGE_PROFILE_AND_DEVICE_OWNERS}) public int getUserProvisioningState();
|
method @RequiresPermission(anyOf={android.Manifest.permission.MANAGE_USERS, android.Manifest.permission.MANAGE_PROFILE_AND_DEVICE_OWNERS}) public int getUserProvisioningState();
|
||||||
method public boolean isDeviceManaged();
|
method public boolean isDeviceManaged();
|
||||||
method @RequiresPermission(android.Manifest.permission.MANAGE_USERS) public boolean isDeviceProvisioned();
|
method @RequiresPermission(android.Manifest.permission.MANAGE_USERS) public boolean isDeviceProvisioned();
|
||||||
|
|||||||
@@ -132,11 +132,11 @@ import java.util.List;
|
|||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.concurrent.Callable;
|
|
||||||
import java.util.concurrent.CompletableFuture;
|
import java.util.concurrent.CompletableFuture;
|
||||||
import java.util.concurrent.ExecutionException;
|
import java.util.concurrent.ExecutionException;
|
||||||
import java.util.concurrent.Executor;
|
import java.util.concurrent.Executor;
|
||||||
import java.util.function.Consumer;
|
import java.util.function.Consumer;
|
||||||
|
import java.util.function.Supplier;
|
||||||
|
|
||||||
// TODO(b/172376923) - add CarDevicePolicyManager examples below (or remove reference to it).
|
// TODO(b/172376923) - add CarDevicePolicyManager examples below (or remove reference to it).
|
||||||
/**
|
/**
|
||||||
@@ -15215,7 +15215,7 @@ public class DevicePolicyManager {
|
|||||||
*
|
*
|
||||||
* <p>This API uses the screen density returned from {@link Resources#getConfiguration()}, to
|
* <p>This API uses the screen density returned from {@link Resources#getConfiguration()}, to
|
||||||
* set a different value use
|
* set a different value use
|
||||||
* {@link #getDrawableForDensity(String, String, int, Callable)}.
|
* {@link #getDrawableForDensity(String, String, int, Supplier)}.
|
||||||
*
|
*
|
||||||
* <p>Callers should register for {@link #ACTION_DEVICE_POLICY_RESOURCE_UPDATED} to get
|
* <p>Callers should register for {@link #ACTION_DEVICE_POLICY_RESOURCE_UPDATED} to get
|
||||||
* notified when a resource has been updated.
|
* notified when a resource has been updated.
|
||||||
@@ -15232,16 +15232,16 @@ public class DevicePolicyManager {
|
|||||||
public Drawable getDrawable(
|
public Drawable getDrawable(
|
||||||
@NonNull @DevicePolicyResources.UpdatableDrawableId String drawableId,
|
@NonNull @DevicePolicyResources.UpdatableDrawableId String drawableId,
|
||||||
@NonNull @DevicePolicyResources.UpdatableDrawableStyle String drawableStyle,
|
@NonNull @DevicePolicyResources.UpdatableDrawableStyle String drawableStyle,
|
||||||
@NonNull Callable<Drawable> defaultDrawableLoader) {
|
@NonNull Supplier<Drawable> defaultDrawableLoader) {
|
||||||
return getDrawable(
|
return getDrawable(
|
||||||
drawableId, drawableStyle, Drawables.Source.UNDEFINED, defaultDrawableLoader);
|
drawableId, drawableStyle, Drawables.Source.UNDEFINED, defaultDrawableLoader);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Similar to {@link #getDrawable(String, String, Callable)}, but also accepts
|
* Similar to {@link #getDrawable(String, String, Supplier)}, but also accepts
|
||||||
* a {@code drawableSource} (see {@link DevicePolicyResources.Drawables.Source}) which
|
* a {@code drawableSource} (see {@link DevicePolicyResources.Drawables.Source}) which
|
||||||
* could result in returning a different drawable than
|
* could result in returning a different drawable than
|
||||||
* {@link #getDrawable(String, String, Callable)}
|
* {@link #getDrawable(String, String, Supplier)}
|
||||||
* if an override was set for that specific source.
|
* if an override was set for that specific source.
|
||||||
*
|
*
|
||||||
* <p>Calls to this API will not return {@code null} unless no updated drawable was found
|
* <p>Calls to this API will not return {@code null} unless no updated drawable was found
|
||||||
@@ -15261,7 +15261,7 @@ public class DevicePolicyManager {
|
|||||||
@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,
|
||||||
@NonNull Callable<Drawable> defaultDrawableLoader) {
|
@NonNull Supplier<Drawable> defaultDrawableLoader) {
|
||||||
|
|
||||||
Objects.requireNonNull(drawableId, "drawableId can't be null");
|
Objects.requireNonNull(drawableId, "drawableId can't be null");
|
||||||
Objects.requireNonNull(drawableStyle, "drawableStyle can't be null");
|
Objects.requireNonNull(drawableStyle, "drawableStyle can't be null");
|
||||||
@@ -15296,7 +15296,7 @@ public class DevicePolicyManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Similar to {@link #getDrawable(String, String, Callable)}, but also accepts
|
* Similar to {@link #getDrawable(String, String, Supplier)}, but also accepts
|
||||||
* {@code density}. See {@link Resources#getDrawableForDensity(int, int, Resources.Theme)}.
|
* {@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
|
* <p>Calls to this API will not return {@code null} unless no updated drawable was found
|
||||||
@@ -15318,7 +15318,7 @@ public class DevicePolicyManager {
|
|||||||
@NonNull @DevicePolicyResources.UpdatableDrawableId String drawableId,
|
@NonNull @DevicePolicyResources.UpdatableDrawableId String drawableId,
|
||||||
@NonNull @DevicePolicyResources.UpdatableDrawableStyle String drawableStyle,
|
@NonNull @DevicePolicyResources.UpdatableDrawableStyle String drawableStyle,
|
||||||
int density,
|
int density,
|
||||||
@NonNull Callable<Drawable> defaultDrawableLoader) {
|
@NonNull Supplier<Drawable> defaultDrawableLoader) {
|
||||||
return getDrawableForDensity(
|
return getDrawableForDensity(
|
||||||
drawableId,
|
drawableId,
|
||||||
drawableStyle,
|
drawableStyle,
|
||||||
@@ -15328,7 +15328,7 @@ public class DevicePolicyManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Similar to {@link #getDrawable(String, String, String, Callable)}, but also accepts
|
* Similar to {@link #getDrawable(String, String, String, Supplier)}, but also accepts
|
||||||
* {@code density}. See {@link Resources#getDrawableForDensity(int, int, Resources.Theme)}.
|
* {@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
|
* <p>Calls to this API will not return {@code null} unless no updated drawable was found
|
||||||
@@ -15352,7 +15352,7 @@ public class DevicePolicyManager {
|
|||||||
@NonNull @DevicePolicyResources.UpdatableDrawableStyle String drawableStyle,
|
@NonNull @DevicePolicyResources.UpdatableDrawableStyle String drawableStyle,
|
||||||
@NonNull @DevicePolicyResources.UpdatableDrawableSource String drawableSource,
|
@NonNull @DevicePolicyResources.UpdatableDrawableSource String drawableSource,
|
||||||
int density,
|
int density,
|
||||||
@NonNull Callable<Drawable> defaultDrawableLoader) {
|
@NonNull Supplier<Drawable> defaultDrawableLoader) {
|
||||||
|
|
||||||
Objects.requireNonNull(drawableId, "drawableId can't be null");
|
Objects.requireNonNull(drawableId, "drawableId can't be null");
|
||||||
Objects.requireNonNull(drawableStyle, "drawableStyle can't be null");
|
Objects.requireNonNull(drawableStyle, "drawableStyle can't be null");
|
||||||
@@ -15383,7 +15383,7 @@ public class DevicePolicyManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Similar to {@link #getDrawable(String, String, String, Callable)} but returns an
|
* Similar to {@link #getDrawable(String, String, String, Supplier)} but returns an
|
||||||
* {@link Icon} instead of a {@link Drawable}.
|
* {@link Icon} instead of a {@link Drawable}.
|
||||||
*
|
*
|
||||||
* @param drawableId The drawable ID to get the updated resource for.
|
* @param drawableId The drawable ID to get the updated resource for.
|
||||||
@@ -15425,7 +15425,7 @@ public class DevicePolicyManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Similar to {@link #getDrawable(String, String, Callable)} but returns an {@link Icon}
|
* Similar to {@link #getDrawable(String, String, Supplier)} but returns an {@link Icon}
|
||||||
* instead of a {@link Drawable}.
|
* instead of a {@link Drawable}.
|
||||||
*
|
*
|
||||||
* @param drawableId The drawable ID to get the updated resource for.
|
* @param drawableId The drawable ID to get the updated resource for.
|
||||||
@@ -15531,7 +15531,7 @@ public class DevicePolicyManager {
|
|||||||
@Nullable
|
@Nullable
|
||||||
public String getString(
|
public String getString(
|
||||||
@NonNull @DevicePolicyResources.UpdatableStringId String stringId,
|
@NonNull @DevicePolicyResources.UpdatableStringId String stringId,
|
||||||
@NonNull Callable<String> defaultStringLoader) {
|
@NonNull Supplier<String> defaultStringLoader) {
|
||||||
|
|
||||||
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");
|
||||||
@@ -15558,7 +15558,7 @@ public class DevicePolicyManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Similar to {@link #getString(String, Callable)} but accepts {@code formatArgs} and returns a
|
* Similar to {@link #getString(String, Supplier)} but accepts {@code formatArgs} and returns a
|
||||||
* localized formatted string, substituting the format arguments as defined in
|
* localized formatted string, substituting the format arguments as defined in
|
||||||
* {@link java.util.Formatter} and {@link java.lang.String#format}, (see
|
* {@link java.util.Formatter} and {@link java.lang.String#format}, (see
|
||||||
* {@link Resources#getString(int, Object...)}).
|
* {@link Resources#getString(int, Object...)}).
|
||||||
@@ -15578,7 +15578,7 @@ public class DevicePolicyManager {
|
|||||||
@SuppressLint("SamShouldBeLast")
|
@SuppressLint("SamShouldBeLast")
|
||||||
public String getString(
|
public String getString(
|
||||||
@NonNull @DevicePolicyResources.UpdatableStringId String stringId,
|
@NonNull @DevicePolicyResources.UpdatableStringId String stringId,
|
||||||
@NonNull Callable<String> defaultStringLoader,
|
@NonNull Supplier<String> defaultStringLoader,
|
||||||
@NonNull Object... formatArgs) {
|
@NonNull Object... formatArgs) {
|
||||||
|
|
||||||
Objects.requireNonNull(stringId, "stringId can't be null");
|
Objects.requireNonNull(stringId, "stringId can't be null");
|
||||||
|
|||||||
@@ -39,7 +39,7 @@ import java.io.IOException;
|
|||||||
import java.lang.annotation.Retention;
|
import java.lang.annotation.Retention;
|
||||||
import java.lang.annotation.RetentionPolicy;
|
import java.lang.annotation.RetentionPolicy;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
import java.util.concurrent.Callable;
|
import java.util.function.Supplier;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Used to store the required information to load a resource that was updated using
|
* Used to store the required information to load a resource that was updated using
|
||||||
@@ -179,7 +179,7 @@ public final class ParcelableResource implements Parcelable {
|
|||||||
public Drawable getDrawable(
|
public Drawable getDrawable(
|
||||||
Context context,
|
Context context,
|
||||||
int density,
|
int density,
|
||||||
@NonNull Callable<Drawable> defaultDrawableLoader) {
|
@NonNull Supplier<Drawable> defaultDrawableLoader) {
|
||||||
// TODO(b/203548565): properly handle edge case when the device manager role holder is
|
// TODO(b/203548565): properly handle edge case when the device manager role holder is
|
||||||
// unavailable because it's being updated.
|
// unavailable because it's being updated.
|
||||||
try {
|
try {
|
||||||
@@ -203,7 +203,7 @@ public final class ParcelableResource implements Parcelable {
|
|||||||
@Nullable
|
@Nullable
|
||||||
public String getString(
|
public String getString(
|
||||||
Context context,
|
Context context,
|
||||||
@NonNull Callable<String> defaultStringLoader) {
|
@NonNull Supplier<String> defaultStringLoader) {
|
||||||
// TODO(b/203548565): properly handle edge case when the device manager role holder is
|
// TODO(b/203548565): properly handle edge case when the device manager role holder is
|
||||||
// unavailable because it's being updated.
|
// unavailable because it's being updated.
|
||||||
try {
|
try {
|
||||||
@@ -227,7 +227,7 @@ public final class ParcelableResource implements Parcelable {
|
|||||||
@Nullable
|
@Nullable
|
||||||
public String getString(
|
public String getString(
|
||||||
Context context,
|
Context context,
|
||||||
@NonNull Callable<String> defaultStringLoader,
|
@NonNull Supplier<String> defaultStringLoader,
|
||||||
@NonNull Object... formatArgs) {
|
@NonNull Object... formatArgs) {
|
||||||
// TODO(b/203548565): properly handle edge case when the device manager role holder is
|
// TODO(b/203548565): properly handle edge case when the device manager role holder is
|
||||||
// unavailable because it's being updated.
|
// unavailable because it's being updated.
|
||||||
@@ -268,26 +268,18 @@ public final class ParcelableResource implements Parcelable {
|
|||||||
* returns the {@link Drawable} loaded from calling {@code defaultDrawableLoader}.
|
* returns the {@link Drawable} loaded from calling {@code defaultDrawableLoader}.
|
||||||
*/
|
*/
|
||||||
@Nullable
|
@Nullable
|
||||||
public static Drawable loadDefaultDrawable(@NonNull Callable<Drawable> defaultDrawableLoader) {
|
public static Drawable loadDefaultDrawable(@NonNull Supplier<Drawable> defaultDrawableLoader) {
|
||||||
try {
|
|
||||||
Objects.requireNonNull(defaultDrawableLoader, "defaultDrawableLoader can't be null");
|
Objects.requireNonNull(defaultDrawableLoader, "defaultDrawableLoader can't be null");
|
||||||
return defaultDrawableLoader.call();
|
return defaultDrawableLoader.get();
|
||||||
} catch (Exception e) {
|
|
||||||
throw new RuntimeException("Couldn't load default drawable: ", e);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* returns the {@link String} loaded from calling {@code defaultStringLoader}.
|
* returns the {@link String} loaded from calling {@code defaultStringLoader}.
|
||||||
*/
|
*/
|
||||||
@Nullable
|
@Nullable
|
||||||
public static String loadDefaultString(@NonNull Callable<String> defaultStringLoader) {
|
public static String loadDefaultString(@NonNull Supplier<String> defaultStringLoader) {
|
||||||
try {
|
|
||||||
Objects.requireNonNull(defaultStringLoader, "defaultStringLoader can't be null");
|
Objects.requireNonNull(defaultStringLoader, "defaultStringLoader can't be null");
|
||||||
return defaultStringLoader.call();
|
return defaultStringLoader.get();
|
||||||
} catch (Exception e) {
|
|
||||||
throw new RuntimeException("Couldn't load default string: ", e);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Reference in New Issue
Block a user