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

Commit 36b5678c authored by Jakob Schneider's avatar Jakob Schneider
Browse files

Adjust compat API based on API council feedback.

Bug: 322010040
Test: LauncherAppsTest
API-Coverage-Bug: 322010040
Change-Id: Ia4969e7e8d11b20c591b4a4d599e1d286cd36be4
parent 751ea275
Loading
Loading
Loading
Loading
+7 −1
Original line number Diff line number Diff line
@@ -12391,7 +12391,7 @@ package android.content.pm {
    method public void registerCallback(android.content.pm.LauncherApps.Callback, android.os.Handler);
    method public void registerPackageInstallerSessionCallback(@NonNull java.util.concurrent.Executor, @NonNull android.content.pm.PackageInstaller.SessionCallback);
    method public android.content.pm.LauncherActivityInfo resolveActivity(android.content.Intent, android.os.UserHandle);
    method @FlaggedApi("android.content.pm.archiving") public void setArchiveCompatibilityOptions(boolean, boolean);
    method @FlaggedApi("android.content.pm.archiving") public void setArchiveCompatibility(@NonNull android.content.pm.LauncherApps.ArchiveCompatibilityParams);
    method public boolean shouldHideFromSuggestions(@NonNull String, @NonNull android.os.UserHandle);
    method public void startAppDetailsActivity(android.content.ComponentName, android.os.UserHandle, android.graphics.Rect, android.os.Bundle);
    method public void startMainActivity(android.content.ComponentName, android.os.UserHandle, android.graphics.Rect, android.os.Bundle);
@@ -12405,6 +12405,12 @@ package android.content.pm {
    field public static final String EXTRA_PIN_ITEM_REQUEST = "android.content.pm.extra.PIN_ITEM_REQUEST";
  }
  @FlaggedApi("android.content.pm.archiving") public static class LauncherApps.ArchiveCompatibilityParams {
    ctor public LauncherApps.ArchiveCompatibilityParams();
    method public void setEnableIconOverlay(boolean);
    method public void setEnableUnarchivalConfirmation(boolean);
  }
  public abstract static class LauncherApps.Callback {
    ctor public LauncherApps.Callback();
    method public abstract void onPackageAdded(String, android.os.UserHandle);
+51 −16
Original line number Diff line number Diff line
@@ -1802,25 +1802,16 @@ public class LauncherApps {
    }

    /**
     * Enable or disable different archive compatibility options of the launcher.
     *
     * @param enableIconOverlay Provides a cloud overlay for archived apps to ensure users are aware
     * that a certain app is archived. True by default.
     * Launchers might want to disable this operation if they want to provide custom user experience
     * to differentiate archived apps.
     * @param enableUnarchivalConfirmation If true, the user is shown a confirmation dialog when
     * they click an archived app, which explains that the app will be downloaded and restored in
     * the background. True by default.
     * Launchers might want to disable this operation if they provide sufficient, alternative user
     * guidance to highlight that an unarchival is starting and ongoing once an archived app is
     * tapped. E.g., this could be achieved by showing the unarchival progress around the icon.
     * Disable different archive compatibility options of the launcher for the caller of this
     * method.
     *
     * @see ArchiveCompatibilityParams for individual options.
     */
    @FlaggedApi(android.content.pm.Flags.FLAG_ARCHIVING)
    public void setArchiveCompatibilityOptions(boolean enableIconOverlay,
            boolean enableUnarchivalConfirmation) {
    public void setArchiveCompatibility(@NonNull ArchiveCompatibilityParams params) {
        try {
            mService.setArchiveCompatibilityOptions(enableIconOverlay,
                    enableUnarchivalConfirmation);
            mService.setArchiveCompatibilityOptions(params.isEnableIconOverlay(),
                    params.isEnableUnarchivalConfirmation());
        } catch (RemoteException re) {
            throw re.rethrowFromSystemServer();
        }
@@ -1982,6 +1973,50 @@ public class LauncherApps {
        }
    };

    /**
     * Used to enable Archiving compatibility options with {@link #setArchiveCompatibility}.
     */
    @FlaggedApi(android.content.pm.Flags.FLAG_ARCHIVING)
    public static class ArchiveCompatibilityParams {
        private boolean mEnableIconOverlay = true;

        private boolean mEnableUnarchivalConfirmation = true;

        /** @hide */
        public boolean isEnableIconOverlay() {
            return mEnableIconOverlay;
        }

        /** @hide */
        public boolean isEnableUnarchivalConfirmation() {
            return mEnableUnarchivalConfirmation;
        }

        /**
         * If true, provides a cloud overlay for archived apps to ensure users are aware that a
         * certain app is archived. True by default.
         *
         * <p> Launchers might want to disable this operation if they want to provide custom user
         * experience to differentiate archived apps.
         */
        public void setEnableIconOverlay(boolean enableIconOverlay) {
            this.mEnableIconOverlay = enableIconOverlay;
        }

        /**
         * If true, the user is shown a confirmation dialog when they click an archived app, which
         * explains that the app will be downloaded and restored in the background. True by default.
         *
         * <p> Launchers might want to disable this operation if they provide sufficient,
         * alternative user guidance to highlight that an unarchival is starting and ongoing once an
         * archived app is tapped. E.g., this could be achieved by showing the unarchival progress
         * around the icon.
         */
        public void setEnableUnarchivalConfirmation(boolean enableUnarchivalConfirmation) {
            this.mEnableUnarchivalConfirmation = enableUnarchivalConfirmation;
        }
    }

    private static class CallbackMessageHandler extends Handler {
        private static final int MSG_ADDED = 1;
        private static final int MSG_REMOVED = 2;