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

Commit ba4e3f41 authored by Treehugger Robot's avatar Treehugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Clean up unused code in ShortcutService." into main

parents 8acfa7f3 56fa877b
Loading
Loading
Loading
Loading
+0 −2
Original line number Diff line number Diff line
@@ -83,8 +83,6 @@ interface ILauncherApps {

    ParceledListSlice getShortcuts(String callingPackage, in ShortcutQueryWrapper query,
            in UserHandle user);
    void getShortcutsAsync(String callingPackage, in ShortcutQueryWrapper query,
            in UserHandle user, in AndroidFuture<List<ShortcutInfo>> cb);
    void pinShortcuts(String callingPackage, String packageName, in List<String> shortcutIds,
            in UserHandle user);
    boolean startShortcut(String callingPackage, String packageName, String featureId, String id,
+4 −6
Original line number Diff line number Diff line
@@ -21,8 +21,6 @@ import android.content.IntentSender;
import android.content.pm.ParceledListSlice;
import android.content.pm.ShortcutInfo;

import com.android.internal.infra.AndroidFuture;

/** {@hide} */
interface IShortcutService {

@@ -38,11 +36,11 @@ interface IShortcutService {

    boolean updateShortcuts(String packageName, in ParceledListSlice shortcuts, int userId);

    void requestPinShortcut(String packageName, in ShortcutInfo shortcut,
            in IntentSender resultIntent, int userId, in AndroidFuture<String> ret);
    boolean requestPinShortcut(String packageName, in ShortcutInfo shortcut,
            in IntentSender resultIntent, int userId);

    void createShortcutResultIntent(String packageName, in ShortcutInfo shortcut, int userId,
            in AndroidFuture<Intent> ret);
    Intent createShortcutResultIntent(String packageName, in ShortcutInfo shortcut,
            int userId);

    void disableShortcuts(String packageName, in List<String> shortcutIds,
            CharSequence disabledMessage, int disabledMessageResId, int userId);
+8 −27
Original line number Diff line number Diff line
@@ -464,26 +464,26 @@ public class LauncherApps {
        public static final int FLAG_GET_KEY_FIELDS_ONLY = 1 << 2;

        /**
         * Includes shortcuts from persistence layer in the search result.
         * Populate the persons field in the result. See {@link ShortcutInfo#getPersons()}.
         *
         * <p>The caller should make the query on a worker thread since accessing persistence layer
         * is considered asynchronous.
         * <p>The caller must have the system {@code ACCESS_SHORTCUTS} permission.
         *
         * @hide
         */
        @SystemApi
        public static final int FLAG_GET_PERSISTED_DATA = 1 << 12;
        @RequiresPermission(android.Manifest.permission.ACCESS_SHORTCUTS)
        public static final int FLAG_GET_PERSONS_DATA = 1 << 11;

        /**
         * Populate the persons field in the result. See {@link ShortcutInfo#getPersons()}.
         * Includes shortcuts from persistence layer in the search result.
         *
         * <p>The caller must have the system {@code ACCESS_SHORTCUTS} permission.
         * <p>The caller should make the query on a worker thread since accessing persistence layer
         * is considered asynchronous.
         *
         * @hide
         */
        @SystemApi
        @RequiresPermission(android.Manifest.permission.ACCESS_SHORTCUTS)
        public static final int FLAG_GET_PERSONS_DATA = 1 << 11;
        public static final int FLAG_GET_PERSISTED_DATA = 1 << 12;

        /** @hide */
        @IntDef(flag = true, prefix = { "FLAG_" }, value = {
@@ -1500,9 +1500,6 @@ public class LauncherApps {
            @NonNull UserHandle user) {
        logErrorForInvalidProfileAccess(user);
        try {
            if ((query.mQueryFlags & ShortcutQuery.FLAG_GET_PERSISTED_DATA) != 0) {
                return getShortcutsBlocked(query, user);
            }
            // Note this is the only case we need to update the disabled message for shortcuts
            // that weren't restored.
            // The restore problem messages are only shown by the user, and publishers will never
@@ -1517,22 +1514,6 @@ public class LauncherApps {
        }
    }

    private List<ShortcutInfo> getShortcutsBlocked(@NonNull ShortcutQuery query,
            @NonNull UserHandle user) {
        logErrorForInvalidProfileAccess(user);
        final AndroidFuture<List<ShortcutInfo>> future = new AndroidFuture<>();
        future.thenApply(this::maybeUpdateDisabledMessage);
        try {
            mService.getShortcutsAsync(mContext.getPackageName(),
                            new ShortcutQueryWrapper(query), user, future);
            return future.get();
        } catch (RemoteException e) {
            throw e.rethrowFromSystemServer();
        } catch (InterruptedException | ExecutionException e) {
            throw new RuntimeException(e);
        }
    }

    /**
     * @hide // No longer used.  Use getShortcuts() instead.  Kept for unit tests.
     */
+4 −26
Original line number Diff line number Diff line
@@ -44,7 +44,6 @@ import android.os.RemoteException;
import android.os.ServiceManager;

import com.android.internal.annotations.VisibleForTesting;
import com.android.internal.infra.AndroidFuture;

import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
@@ -598,10 +597,8 @@ public class ShortcutManager {
    public boolean requestPinShortcut(@NonNull ShortcutInfo shortcut,
            @Nullable IntentSender resultIntent) {
        try {
            AndroidFuture<String> ret = new AndroidFuture<>();
            mService.requestPinShortcut(mContext.getPackageName(), shortcut, resultIntent,
                    injectMyUserId(), ret);
            return Boolean.parseBoolean(getFutureOrThrow(ret));
            return mService.requestPinShortcut(mContext.getPackageName(), shortcut, resultIntent,
                    injectMyUserId());
        } catch (RemoteException e) {
            throw e.rethrowFromSystemServer();
        }
@@ -626,11 +623,9 @@ public class ShortcutManager {
     */
    @WorkerThread
    public Intent createShortcutResultIntent(@NonNull ShortcutInfo shortcut) {
        final AndroidFuture<Intent> ret = new AndroidFuture<>();
        try {
            mService.createShortcutResultIntent(mContext.getPackageName(),
                    shortcut, injectMyUserId(), ret);
            Intent result = getFutureOrThrow(ret);
            Intent result = mService.createShortcutResultIntent(mContext.getPackageName(),
                    shortcut, injectMyUserId());
            if (result != null) {
                result.prepareToEnterProcess(LOCAL_FLAG_FROM_SYSTEM,
                        mContext.getAttributionSource());
@@ -793,21 +788,4 @@ public class ShortcutManager {
            throw e.rethrowFromSystemServer();
        }
    }

    private static <T> T getFutureOrThrow(@NonNull AndroidFuture<T> future) {
        try {
            return future.get();
        } catch (Throwable e) {
            if (e instanceof ExecutionException) {
                e = e.getCause();
            }
            if (e instanceof RuntimeException) {
                throw (RuntimeException) e;
            }
            if (e instanceof Error) {
                throw (Error) e;
            }
            throw new RuntimeException(e);
        }
    }
}
+0 −36
Original line number Diff line number Diff line
@@ -52,19 +52,6 @@ public abstract class ShortcutServiceInternal {
            @Nullable List<LocusId> locusIds, @Nullable ComponentName componentName,
            @ShortcutQuery.QueryFlags int flags, int userId, int callingPid, int callingUid);

    /**
     * Retrieves shortcuts asynchronously. Query will go through persistence layer (thus making the
     * call async) if querying by shortcutIds in a specific package; otherwise it's effectively the
     * same as calling {@link #getShortcuts}.
     */
    public abstract void
            getShortcutsAsync(int launcherUserId,
            @NonNull String callingPackage, long changedSince,
            @Nullable String packageName, @Nullable List<String> shortcutIds,
            @Nullable List<LocusId> locusIds, @Nullable ComponentName componentName,
            @ShortcutQuery.QueryFlags int flags, int userId, int callingPid, int callingUid,
            AndroidFuture<List<ShortcutInfo>> cb);

    public abstract boolean
            isPinnedByCaller(int launcherUserId, @NonNull String callingPackage,
            @NonNull String packageName, @NonNull String id, int userId);
@@ -78,14 +65,6 @@ public abstract class ShortcutServiceInternal {
            @NonNull String packageName, @NonNull String shortcutId, int userId,
            int callingPid, int callingUid);

    /**
     * Retrieves the intents from a specified shortcut asynchronously.
     */
    public abstract void createShortcutIntentsAsync(
            int launcherUserId, @NonNull String callingPackage,
            @NonNull String packageName, @NonNull String shortcutId, int userId,
            int callingPid, int callingUid, @NonNull AndroidFuture<Intent[]> cb);

    public abstract void addListener(@NonNull ShortcutChangeListener listener);

    public abstract void addShortcutChangeCallback(
@@ -108,13 +87,6 @@ public abstract class ShortcutServiceInternal {
            @NonNull String callingPackage,
            @NonNull String packageName, @NonNull String shortcutId, int userId);

    /**
     * Retrieves a file descriptor from the icon in a specified shortcut asynchronously.
     */
    public abstract void getShortcutIconFdAsync(int launcherUserId, @NonNull String callingPackage,
            @NonNull String packageName, @NonNull String shortcutId, int userId,
            @NonNull AndroidFuture<ParcelFileDescriptor> cb);

    public abstract boolean hasShortcutHostPermission(int launcherUserId,
            @NonNull String callingPackage, int callingPid, int callingUid);

@@ -155,14 +127,6 @@ public abstract class ShortcutServiceInternal {
    public abstract String getShortcutIconUri(int launcherUserId, @NonNull String launcherPackage,
            @NonNull String packageName, @NonNull String shortcutId, int userId);

    /**
     * Retrieves the icon Uri of the shortcut asynchronously, and grants Uri read permission to the
     * caller.
     */
    public abstract void getShortcutIconUriAsync(int launcherUserId,
            @NonNull String launcherPackage, @NonNull String packageName,
            @NonNull String shortcutId, int userId, @NonNull AndroidFuture<String> cb);

    public abstract boolean isSharingShortcut(int callingUserId, @NonNull String callingPackage,
            @NonNull String packageName, @NonNull String shortcutId, int userId,
            @NonNull IntentFilter filter);
Loading