Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit a4ea6126 authored by Kholoud Mohamed's avatar Kholoud Mohamed Committed by Automerger Merge Worker
Browse files

Merge "Change Callable to Supplier in the dpm resource apis" into tm-dev am: 7e76fddc

Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/16988746

Change-Id: Ic86d47f27e7ada265f49b4a189b70eda57786a3b
parents 35da7057 7e76fddc
Loading
Loading
Loading
Loading
+4 −4
Original line number Diff line number Diff line
@@ -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 @Nullable public String getDeviceManagerRoleHolderPackageName();
    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 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.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, @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, @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.function.Supplier<android.graphics.drawable.Drawable>);
    method public CharSequence getEndUserSessionMessage(@NonNull android.content.ComponentName);
    method @NonNull public String getEnrollmentSpecificId();
    method @Nullable public android.app.admin.FactoryResetProtectionPolicy getFactoryResetProtectionPolicy(@Nullable android.content.ComponentName);
+2 −2
Original line number Diff line number Diff line
@@ -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 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 public String getString(@NonNull String, @NonNull java.util.concurrent.Callable<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>);
    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 public boolean isDeviceManaged();
    method @RequiresPermission(android.Manifest.permission.MANAGE_USERS) public boolean isDeviceProvisioned();
+15 −15
Original line number Diff line number Diff line
@@ -132,11 +132,11 @@ import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.Set;
import java.util.concurrent.Callable;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.Executor;
import java.util.function.Consumer;
import java.util.function.Supplier;
// 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
     * 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
     * notified when a resource has been updated.
@@ -15232,16 +15232,16 @@ public class DevicePolicyManager {
    public Drawable getDrawable(
            @NonNull @DevicePolicyResources.UpdatableDrawableId String drawableId,
            @NonNull @DevicePolicyResources.UpdatableDrawableStyle String drawableStyle,
            @NonNull Callable<Drawable> defaultDrawableLoader) {
            @NonNull Supplier<Drawable> defaultDrawableLoader) {
        return getDrawable(
                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
     * 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.
     *
     * <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.UpdatableDrawableStyle String drawableStyle,
            @NonNull @DevicePolicyResources.UpdatableDrawableSource String drawableSource,
            @NonNull Callable<Drawable> defaultDrawableLoader) {
            @NonNull Supplier<Drawable> defaultDrawableLoader) {
        Objects.requireNonNull(drawableId, "drawableId 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)}.
     *
     * <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.UpdatableDrawableStyle String drawableStyle,
            int density,
            @NonNull Callable<Drawable> defaultDrawableLoader) {
            @NonNull Supplier<Drawable> defaultDrawableLoader) {
        return getDrawableForDensity(
                drawableId,
                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)}.
     *
      * <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.UpdatableDrawableSource String drawableSource,
            int density,
            @NonNull Callable<Drawable> defaultDrawableLoader) {
            @NonNull Supplier<Drawable> defaultDrawableLoader) {
        Objects.requireNonNull(drawableId, "drawableId 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}.
     *
     * @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}.
     *
     * @param drawableId The drawable ID to get the updated resource for.
@@ -15531,7 +15531,7 @@ public class DevicePolicyManager {
    @Nullable
    public String getString(
            @NonNull @DevicePolicyResources.UpdatableStringId String stringId,
            @NonNull Callable<String> defaultStringLoader) {
            @NonNull Supplier<String> defaultStringLoader) {
        Objects.requireNonNull(stringId, "stringId 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
     * {@link java.util.Formatter} and {@link java.lang.String#format}, (see
     * {@link Resources#getString(int, Object...)}).
@@ -15578,7 +15578,7 @@ public class DevicePolicyManager {
    @SuppressLint("SamShouldBeLast")
    public String getString(
            @NonNull @DevicePolicyResources.UpdatableStringId String stringId,
            @NonNull Callable<String> defaultStringLoader,
            @NonNull Supplier<String> defaultStringLoader,
            @NonNull Object... formatArgs) {
        Objects.requireNonNull(stringId, "stringId can't be null");
+10 −18
Original line number Diff line number Diff line
@@ -39,7 +39,7 @@ import java.io.IOException;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
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
@@ -179,7 +179,7 @@ public final class ParcelableResource implements Parcelable {
    public Drawable getDrawable(
            Context context,
            int density,
            @NonNull Callable<Drawable> defaultDrawableLoader) {
            @NonNull Supplier<Drawable> defaultDrawableLoader) {
        // TODO(b/203548565): properly handle edge case when the device manager role holder is
        //  unavailable because it's being updated.
        try {
@@ -203,7 +203,7 @@ public final class ParcelableResource implements Parcelable {
    @Nullable
    public String getString(
            Context context,
            @NonNull Callable<String> defaultStringLoader) {
            @NonNull Supplier<String> defaultStringLoader) {
        // TODO(b/203548565): properly handle edge case when the device manager role holder is
        //  unavailable because it's being updated.
        try {
@@ -227,7 +227,7 @@ public final class ParcelableResource implements Parcelable {
    @Nullable
    public String getString(
            Context context,
            @NonNull Callable<String> defaultStringLoader,
            @NonNull Supplier<String> defaultStringLoader,
            @NonNull Object... formatArgs) {
        // TODO(b/203548565): properly handle edge case when the device manager role holder is
        //  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}.
     */
    @Nullable
    public static Drawable loadDefaultDrawable(@NonNull Callable<Drawable> defaultDrawableLoader) {
        try {
    public static Drawable loadDefaultDrawable(@NonNull Supplier<Drawable> defaultDrawableLoader) {
        Objects.requireNonNull(defaultDrawableLoader, "defaultDrawableLoader can't be null");
            return defaultDrawableLoader.call();
        } catch (Exception e) {
            throw new RuntimeException("Couldn't load default drawable: ", e);
        }
        return defaultDrawableLoader.get();
    }

    /**
     * returns the {@link String} loaded from calling {@code defaultStringLoader}.
     */
    @Nullable
    public static String loadDefaultString(@NonNull Callable<String> defaultStringLoader) {
        try {
    public static String loadDefaultString(@NonNull Supplier<String> defaultStringLoader) {
        Objects.requireNonNull(defaultStringLoader, "defaultStringLoader can't be null");
            return defaultStringLoader.call();
        } catch (Exception e) {
            throw new RuntimeException("Couldn't load default string: ", e);
        }
        return defaultStringLoader.get();
    }

    /**