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

Commit 62875c96 authored by Mehdi Alizadeh's avatar Mehdi Alizadeh
Browse files

Adds a new flag in ShortcutQuery to return person data

Bug: 169878448
Test: atest com.android.server.pm.ShortcutManagerTest1
            com.android.server.pm.ShortcutManagerTest2
            com.android.server.pm.ShortcutManagerTest3
            com.android.server.pm.ShortcutManagerTest4
            com.android.server.pm.ShortcutManagerTest5
            com.android.server.pm.ShortcutManagerTest6
            com.android.server.pm.ShortcutManagerTest7
            com.android.server.pm.ShortcutManagerTest8
            com.android.server.pm.ShortcutManagerTest9
            com.android.server.pm.ShortcutManagerTest10
            com.android.server.pm.ShortcutManagerTest11
Change-Id: Iafbd558e542c40a808bfd9b13dc7d69c92e76cfc
parent 115861da
Loading
Loading
Loading
Loading
+4 −0
Original line number Diff line number Diff line
@@ -2066,6 +2066,10 @@ package android.content.pm {
    field @NonNull public static final android.os.Parcelable.Creator<android.content.pm.LauncherApps.AppUsageLimit> CREATOR;
  }
  public static class LauncherApps.ShortcutQuery {
    field public static final int FLAG_GET_PERSONS_DATA = 2048; // 0x800
  }
  public class PackageInstaller {
    method @RequiresPermission(android.Manifest.permission.INSTALL_PACKAGES) public void setPermissionsResult(int, boolean);
    field public static final int DATA_LOADER_TYPE_INCREMENTAL = 2; // 0x2
+11 −0
Original line number Diff line number Diff line
@@ -433,6 +433,16 @@ public class LauncherApps {
         */
        public static final int FLAG_GET_KEY_FIELDS_ONLY = 1 << 2;

        /**
         * Populate the persons field in the result. See {@link ShortcutInfo#getPersons()}.
         *
         * <p>The caller must have the system {@code ACCESS_SHORTCUTS} permission.
         *
         * @hide
         */
        @SystemApi
        public static final int FLAG_GET_PERSONS_DATA = 1 << 11;

        /** @hide */
        @IntDef(flag = true, prefix = { "FLAG_" }, value = {
                FLAG_MATCH_DYNAMIC,
@@ -440,6 +450,7 @@ public class LauncherApps {
                FLAG_MATCH_MANIFEST,
                FLAG_MATCH_CACHED,
                FLAG_GET_KEY_FIELDS_ONLY,
                FLAG_GET_PERSONS_DATA,
        })
        @Retention(RetentionPolicy.SOURCE)
        public @interface QueryFlags {}
+3 −0
Original line number Diff line number Diff line
@@ -775,6 +775,9 @@ public class LauncherAppsService extends SystemService {
                throw new IllegalArgumentException(
                        "To query by locus ID, package name must also be set");
            }
            if ((query.getQueryFlags() & ShortcutQuery.FLAG_GET_PERSONS_DATA) != 0) {
                ensureStrictAccessShortcutsPermission(callingPackage);
            }

            // TODO(b/29399275): Eclipse compiler requires explicit List<ShortcutInfo> cast below.
            return new ParceledListSlice<>((List<ShortcutInfo>)
+8 −4
Original line number Diff line number Diff line
@@ -2865,10 +2865,14 @@ public class ShortcutService extends IShortcutService.Stub {
                int queryFlags, int userId, int callingPid, int callingUid) {
            final ArrayList<ShortcutInfo> ret = new ArrayList<>();

            final boolean cloneKeyFieldOnly =
                    ((queryFlags & ShortcutQuery.FLAG_GET_KEY_FIELDS_ONLY) != 0);
            final int cloneFlag = cloneKeyFieldOnly ? ShortcutInfo.CLONE_REMOVE_NON_KEY_INFO
                    : ShortcutInfo.CLONE_REMOVE_FOR_LAUNCHER;
            int flags = ShortcutInfo.CLONE_REMOVE_FOR_LAUNCHER;
            if ((queryFlags & ShortcutQuery.FLAG_GET_KEY_FIELDS_ONLY) != 0) {
                flags = ShortcutInfo.CLONE_REMOVE_NON_KEY_INFO;
            } else if ((queryFlags & ShortcutQuery.FLAG_GET_PERSONS_DATA) != 0) {
                flags &= ~ShortcutInfo.CLONE_REMOVE_PERSON;
            }
            final int cloneFlag = flags;

            if (packageName == null) {
                shortcutIds = null; // LauncherAppsService already threw for it though.
            }
+1 −1
Original line number Diff line number Diff line
@@ -568,7 +568,7 @@ public abstract class BaseShortcutManagerTest extends InstrumentationTestCase {

        @Override
        boolean injectHasAccessShortcutsPermission(int callingPid, int callingUid) {
            return true;
            return mInjectCheckAccessShortcutsPermission;
        }

        @Override
Loading