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

Commit 8c68af5d authored by Mehdi Alizadeh's avatar Mehdi Alizadeh Committed by Android (Google) Code Review
Browse files

Merge "Adds a new flag in ShortcutQuery to return person data"

parents 539bfca1 62875c96
Loading
Loading
Loading
Loading
+4 −0
Original line number Original line 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;
    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 {
  public class PackageInstaller {
    method @RequiresPermission(android.Manifest.permission.INSTALL_PACKAGES) public void setPermissionsResult(int, boolean);
    method @RequiresPermission(android.Manifest.permission.INSTALL_PACKAGES) public void setPermissionsResult(int, boolean);
    field public static final int DATA_LOADER_TYPE_INCREMENTAL = 2; // 0x2
    field public static final int DATA_LOADER_TYPE_INCREMENTAL = 2; // 0x2
+11 −0
Original line number Original line Diff line number Diff line
@@ -433,6 +433,16 @@ public class LauncherApps {
         */
         */
        public static final int FLAG_GET_KEY_FIELDS_ONLY = 1 << 2;
        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 */
        /** @hide */
        @IntDef(flag = true, prefix = { "FLAG_" }, value = {
        @IntDef(flag = true, prefix = { "FLAG_" }, value = {
                FLAG_MATCH_DYNAMIC,
                FLAG_MATCH_DYNAMIC,
@@ -440,6 +450,7 @@ public class LauncherApps {
                FLAG_MATCH_MANIFEST,
                FLAG_MATCH_MANIFEST,
                FLAG_MATCH_CACHED,
                FLAG_MATCH_CACHED,
                FLAG_GET_KEY_FIELDS_ONLY,
                FLAG_GET_KEY_FIELDS_ONLY,
                FLAG_GET_PERSONS_DATA,
        })
        })
        @Retention(RetentionPolicy.SOURCE)
        @Retention(RetentionPolicy.SOURCE)
        public @interface QueryFlags {}
        public @interface QueryFlags {}
+3 −0
Original line number Original line Diff line number Diff line
@@ -774,6 +774,9 @@ public class LauncherAppsService extends SystemService {
                throw new IllegalArgumentException(
                throw new IllegalArgumentException(
                        "To query by locus ID, package name must also be set");
                        "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.
            // TODO(b/29399275): Eclipse compiler requires explicit List<ShortcutInfo> cast below.
            return new ParceledListSlice<>((List<ShortcutInfo>)
            return new ParceledListSlice<>((List<ShortcutInfo>)
+8 −4
Original line number Original line Diff line number Diff line
@@ -2837,10 +2837,14 @@ public class ShortcutService extends IShortcutService.Stub {
                int queryFlags, int userId, int callingPid, int callingUid) {
                int queryFlags, int userId, int callingPid, int callingUid) {
            final ArrayList<ShortcutInfo> ret = new ArrayList<>();
            final ArrayList<ShortcutInfo> ret = new ArrayList<>();


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

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


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


        @Override
        @Override
Loading