Loading api/test-current.txt +1 −0 Original line number Diff line number Diff line Loading @@ -10516,6 +10516,7 @@ package android.content.pm { method public android.content.pm.LauncherApps.ShortcutQuery setQueryFlags(int); method public android.content.pm.LauncherApps.ShortcutQuery setShortcutIds(java.util.List<java.lang.String>); field public static final int FLAG_GET_KEY_FIELDS_ONLY = 4; // 0x4 field public static final int FLAG_MATCH_ALL_PINNED = 1024; // 0x400 field public static final int FLAG_MATCH_DYNAMIC = 1; // 0x1 field public static final int FLAG_MATCH_MANIFEST = 8; // 0x8 field public static final int FLAG_MATCH_PINNED = 2; // 0x2 core/java/android/content/pm/LauncherApps.java +19 −3 Original line number Diff line number Diff line Loading @@ -282,12 +282,27 @@ public class LauncherApps { public static final int FLAG_GET_MANIFEST = FLAG_MATCH_MANIFEST; /** * Does not retrieve CHOOSER only shortcuts. * TODO: Add another flag for MATCH_ALL_PINNED * @hide include all pinned shortcuts by any launchers, not just by the caller, * in the result. * If the caller doesn't havve the {@link android.Manifest.permission#ACCESS_SHORTCUTS} * permission, this flag will be ignored. */ @TestApi public static final int FLAG_MATCH_ALL_PINNED = 1 << 10; /** * FLAG_MATCH_DYNAMIC | FLAG_MATCH_PINNED | FLAG_MATCH_MANIFEST * @hide */ public static final int FLAG_MATCH_ALL_KINDS = FLAG_GET_DYNAMIC | FLAG_GET_PINNED | FLAG_GET_MANIFEST; FLAG_MATCH_DYNAMIC | FLAG_MATCH_PINNED | FLAG_MATCH_MANIFEST; /** * FLAG_MATCH_DYNAMIC | FLAG_MATCH_PINNED | FLAG_MATCH_MANIFEST | FLAG_MATCH_ALL_PINNED * @hide */ public static final int FLAG_MATCH_ALL_KINDS_WITH_ALL_PINNED = FLAG_MATCH_ALL_KINDS | FLAG_MATCH_ALL_PINNED; /** @hide kept for unit tests */ @Deprecated Loading Loading @@ -319,6 +334,7 @@ public class LauncherApps { FLAG_MATCH_PINNED, FLAG_MATCH_MANIFEST, FLAG_GET_KEY_FIELDS_ONLY, FLAG_MATCH_MANIFEST, }) @Retention(RetentionPolicy.SOURCE) public @interface QueryFlags {} Loading core/java/android/content/pm/ShortcutServiceInternal.java +4 −3 Original line number Diff line number Diff line Loading @@ -46,7 +46,7 @@ public abstract class ShortcutServiceInternal { @NonNull String callingPackage, long changedSince, @Nullable String packageName, @Nullable List<String> shortcutIds, @Nullable ComponentName componentName, @ShortcutQuery.QueryFlags int flags, int userId); int userId, int callingPid, int callingUid); public abstract boolean isPinnedByCaller(int launcherUserId, @NonNull String callingPackage, Loading @@ -58,7 +58,8 @@ public abstract class ShortcutServiceInternal { public abstract Intent[] createShortcutIntents( int launcherUserId, @NonNull String callingPackage, @NonNull String packageName, @NonNull String shortcutId, int userId); @NonNull String packageName, @NonNull String shortcutId, int userId, int callingPid, int callingUid); public abstract void addListener(@NonNull ShortcutChangeListener listener); Loading @@ -70,7 +71,7 @@ public abstract class ShortcutServiceInternal { @NonNull String packageName, @NonNull String shortcutId, int userId); public abstract boolean hasShortcutHostPermission(int launcherUserId, @NonNull String callingPackage); @NonNull String callingPackage, int callingPid, int callingUid); public abstract boolean requestPinAppWidget(@NonNull String callingPackage, @NonNull AppWidgetProviderInfo appWidget, @Nullable Bundle extras, Loading core/res/AndroidManifest.xml +4 −0 Original line number Diff line number Diff line Loading @@ -3587,6 +3587,10 @@ <permission android:name="android.permission.INSTANT_APP_FOREGROUND_SERVICE" android:protectionLevel="signature|development|instant|appop" /> <!-- @hide Allows system components to access all app shortcuts. --> <permission android:name="android.permission.ACCESS_SHORTCUTS" android:protectionLevel="signature" /> <application android:process="system" android:persistent="true" android:hasCode="false" Loading services/core/java/com/android/server/pm/LauncherAppsService.java +21 −12 Original line number Diff line number Diff line Loading @@ -30,12 +30,10 @@ import android.content.pm.ActivityInfo; import android.content.pm.ApplicationInfo; import android.content.pm.ILauncherApps; import android.content.pm.IOnAppsChangedListener; import android.content.pm.IPackageManager; import android.content.pm.LauncherApps.ShortcutQuery; import android.content.pm.PackageInfo; import android.content.pm.PackageManager; import android.content.pm.PackageManagerInternal; import android.content.pm.PackageManager.NameNotFoundException; import android.content.pm.ParceledListSlice; import android.content.pm.ResolveInfo; import android.content.pm.ShortcutInfo; Loading Loading @@ -64,7 +62,6 @@ import com.android.internal.util.Preconditions; import com.android.server.LocalServices; import com.android.server.SystemService; import java.util.ArrayList; import java.util.Collections; import java.util.List; Loading @@ -89,10 +86,14 @@ public class LauncherAppsService extends SystemService { static class BroadcastCookie { public final UserHandle user; public final String packageName; public final int callingUid; public final int callingPid; BroadcastCookie(UserHandle userHandle, String packageName) { BroadcastCookie(UserHandle userHandle, String packageName, int callingPid, int callingUid) { this.user = userHandle; this.packageName = packageName; this.callingUid = callingUid; this.callingPid = callingPid; } } Loading Loading @@ -127,6 +128,11 @@ public class LauncherAppsService extends SystemService { return getCallingUid(); } @VisibleForTesting int injectBinderCallingPid() { return getCallingPid(); } final int injectCallingUserId() { return UserHandle.getUserId(injectBinderCallingUid()); } Loading Loading @@ -166,7 +172,7 @@ public class LauncherAppsService extends SystemService { } mListeners.unregister(listener); mListeners.register(listener, new BroadcastCookie(UserHandle.of(getCallingUserId()), callingPackage)); callingPackage, injectBinderCallingPid(), injectBinderCallingUid())); } } Loading Loading @@ -438,7 +444,7 @@ public class LauncherAppsService extends SystemService { private void ensureShortcutPermission(@NonNull String callingPackage) { verifyCallingPackage(callingPackage); if (!mShortcutServiceInternal.hasShortcutHostPermission(getCallingUserId(), callingPackage)) { callingPackage, injectBinderCallingPid(), injectBinderCallingUid())) { throw new SecurityException("Caller can't access shortcut information"); } } Loading @@ -461,7 +467,8 @@ public class LauncherAppsService extends SystemService { return new ParceledListSlice<>((List<ShortcutInfo>) mShortcutServiceInternal.getShortcuts(getCallingUserId(), callingPackage, changedSince, packageName, shortcutIds, componentName, flags, targetUser.getIdentifier())); componentName, flags, targetUser.getIdentifier(), injectBinderCallingPid(), injectBinderCallingUid())); } @Override Loading Loading @@ -514,7 +521,7 @@ public class LauncherAppsService extends SystemService { public boolean hasShortcutHostPermission(String callingPackage) { verifyCallingPackage(callingPackage); return mShortcutServiceInternal.hasShortcutHostPermission(getCallingUserId(), callingPackage); callingPackage, injectBinderCallingPid(), injectBinderCallingUid()); } @Override Loading @@ -536,7 +543,8 @@ public class LauncherAppsService extends SystemService { } final Intent[] intents = mShortcutServiceInternal.createShortcutIntents( getCallingUserId(), callingPackage, packageName, shortcutId, targetUserId); getCallingUserId(), callingPackage, packageName, shortcutId, targetUserId, injectBinderCallingPid(), injectBinderCallingUid()); if (intents == null || intents.length == 0) { return false; } Loading Loading @@ -901,7 +909,8 @@ public class LauncherAppsService extends SystemService { // Make sure the caller has the permission. if (!mShortcutServiceInternal.hasShortcutHostPermission( launcherUserId, cookie.packageName)) { launcherUserId, cookie.packageName, cookie.callingPid, cookie.callingUid)) { continue; } // Each launcher has a different set of pinned shortcuts, so we need to do a Loading @@ -914,8 +923,8 @@ public class LauncherAppsService extends SystemService { /* changedSince= */ 0, packageName, /* shortcutIds=*/ null, /* component= */ null, ShortcutQuery.FLAG_GET_KEY_FIELDS_ONLY | ShortcutQuery.FLAG_GET_ALL_KINDS , userId); | ShortcutQuery.FLAG_MATCH_ALL_KINDS_WITH_ALL_PINNED , userId, cookie.callingPid, cookie.callingUid); try { listener.onShortcutChanged(user, packageName, new ParceledListSlice<>(list)); Loading Loading
api/test-current.txt +1 −0 Original line number Diff line number Diff line Loading @@ -10516,6 +10516,7 @@ package android.content.pm { method public android.content.pm.LauncherApps.ShortcutQuery setQueryFlags(int); method public android.content.pm.LauncherApps.ShortcutQuery setShortcutIds(java.util.List<java.lang.String>); field public static final int FLAG_GET_KEY_FIELDS_ONLY = 4; // 0x4 field public static final int FLAG_MATCH_ALL_PINNED = 1024; // 0x400 field public static final int FLAG_MATCH_DYNAMIC = 1; // 0x1 field public static final int FLAG_MATCH_MANIFEST = 8; // 0x8 field public static final int FLAG_MATCH_PINNED = 2; // 0x2
core/java/android/content/pm/LauncherApps.java +19 −3 Original line number Diff line number Diff line Loading @@ -282,12 +282,27 @@ public class LauncherApps { public static final int FLAG_GET_MANIFEST = FLAG_MATCH_MANIFEST; /** * Does not retrieve CHOOSER only shortcuts. * TODO: Add another flag for MATCH_ALL_PINNED * @hide include all pinned shortcuts by any launchers, not just by the caller, * in the result. * If the caller doesn't havve the {@link android.Manifest.permission#ACCESS_SHORTCUTS} * permission, this flag will be ignored. */ @TestApi public static final int FLAG_MATCH_ALL_PINNED = 1 << 10; /** * FLAG_MATCH_DYNAMIC | FLAG_MATCH_PINNED | FLAG_MATCH_MANIFEST * @hide */ public static final int FLAG_MATCH_ALL_KINDS = FLAG_GET_DYNAMIC | FLAG_GET_PINNED | FLAG_GET_MANIFEST; FLAG_MATCH_DYNAMIC | FLAG_MATCH_PINNED | FLAG_MATCH_MANIFEST; /** * FLAG_MATCH_DYNAMIC | FLAG_MATCH_PINNED | FLAG_MATCH_MANIFEST | FLAG_MATCH_ALL_PINNED * @hide */ public static final int FLAG_MATCH_ALL_KINDS_WITH_ALL_PINNED = FLAG_MATCH_ALL_KINDS | FLAG_MATCH_ALL_PINNED; /** @hide kept for unit tests */ @Deprecated Loading Loading @@ -319,6 +334,7 @@ public class LauncherApps { FLAG_MATCH_PINNED, FLAG_MATCH_MANIFEST, FLAG_GET_KEY_FIELDS_ONLY, FLAG_MATCH_MANIFEST, }) @Retention(RetentionPolicy.SOURCE) public @interface QueryFlags {} Loading
core/java/android/content/pm/ShortcutServiceInternal.java +4 −3 Original line number Diff line number Diff line Loading @@ -46,7 +46,7 @@ public abstract class ShortcutServiceInternal { @NonNull String callingPackage, long changedSince, @Nullable String packageName, @Nullable List<String> shortcutIds, @Nullable ComponentName componentName, @ShortcutQuery.QueryFlags int flags, int userId); int userId, int callingPid, int callingUid); public abstract boolean isPinnedByCaller(int launcherUserId, @NonNull String callingPackage, Loading @@ -58,7 +58,8 @@ public abstract class ShortcutServiceInternal { public abstract Intent[] createShortcutIntents( int launcherUserId, @NonNull String callingPackage, @NonNull String packageName, @NonNull String shortcutId, int userId); @NonNull String packageName, @NonNull String shortcutId, int userId, int callingPid, int callingUid); public abstract void addListener(@NonNull ShortcutChangeListener listener); Loading @@ -70,7 +71,7 @@ public abstract class ShortcutServiceInternal { @NonNull String packageName, @NonNull String shortcutId, int userId); public abstract boolean hasShortcutHostPermission(int launcherUserId, @NonNull String callingPackage); @NonNull String callingPackage, int callingPid, int callingUid); public abstract boolean requestPinAppWidget(@NonNull String callingPackage, @NonNull AppWidgetProviderInfo appWidget, @Nullable Bundle extras, Loading
core/res/AndroidManifest.xml +4 −0 Original line number Diff line number Diff line Loading @@ -3587,6 +3587,10 @@ <permission android:name="android.permission.INSTANT_APP_FOREGROUND_SERVICE" android:protectionLevel="signature|development|instant|appop" /> <!-- @hide Allows system components to access all app shortcuts. --> <permission android:name="android.permission.ACCESS_SHORTCUTS" android:protectionLevel="signature" /> <application android:process="system" android:persistent="true" android:hasCode="false" Loading
services/core/java/com/android/server/pm/LauncherAppsService.java +21 −12 Original line number Diff line number Diff line Loading @@ -30,12 +30,10 @@ import android.content.pm.ActivityInfo; import android.content.pm.ApplicationInfo; import android.content.pm.ILauncherApps; import android.content.pm.IOnAppsChangedListener; import android.content.pm.IPackageManager; import android.content.pm.LauncherApps.ShortcutQuery; import android.content.pm.PackageInfo; import android.content.pm.PackageManager; import android.content.pm.PackageManagerInternal; import android.content.pm.PackageManager.NameNotFoundException; import android.content.pm.ParceledListSlice; import android.content.pm.ResolveInfo; import android.content.pm.ShortcutInfo; Loading Loading @@ -64,7 +62,6 @@ import com.android.internal.util.Preconditions; import com.android.server.LocalServices; import com.android.server.SystemService; import java.util.ArrayList; import java.util.Collections; import java.util.List; Loading @@ -89,10 +86,14 @@ public class LauncherAppsService extends SystemService { static class BroadcastCookie { public final UserHandle user; public final String packageName; public final int callingUid; public final int callingPid; BroadcastCookie(UserHandle userHandle, String packageName) { BroadcastCookie(UserHandle userHandle, String packageName, int callingPid, int callingUid) { this.user = userHandle; this.packageName = packageName; this.callingUid = callingUid; this.callingPid = callingPid; } } Loading Loading @@ -127,6 +128,11 @@ public class LauncherAppsService extends SystemService { return getCallingUid(); } @VisibleForTesting int injectBinderCallingPid() { return getCallingPid(); } final int injectCallingUserId() { return UserHandle.getUserId(injectBinderCallingUid()); } Loading Loading @@ -166,7 +172,7 @@ public class LauncherAppsService extends SystemService { } mListeners.unregister(listener); mListeners.register(listener, new BroadcastCookie(UserHandle.of(getCallingUserId()), callingPackage)); callingPackage, injectBinderCallingPid(), injectBinderCallingUid())); } } Loading Loading @@ -438,7 +444,7 @@ public class LauncherAppsService extends SystemService { private void ensureShortcutPermission(@NonNull String callingPackage) { verifyCallingPackage(callingPackage); if (!mShortcutServiceInternal.hasShortcutHostPermission(getCallingUserId(), callingPackage)) { callingPackage, injectBinderCallingPid(), injectBinderCallingUid())) { throw new SecurityException("Caller can't access shortcut information"); } } Loading @@ -461,7 +467,8 @@ public class LauncherAppsService extends SystemService { return new ParceledListSlice<>((List<ShortcutInfo>) mShortcutServiceInternal.getShortcuts(getCallingUserId(), callingPackage, changedSince, packageName, shortcutIds, componentName, flags, targetUser.getIdentifier())); componentName, flags, targetUser.getIdentifier(), injectBinderCallingPid(), injectBinderCallingUid())); } @Override Loading Loading @@ -514,7 +521,7 @@ public class LauncherAppsService extends SystemService { public boolean hasShortcutHostPermission(String callingPackage) { verifyCallingPackage(callingPackage); return mShortcutServiceInternal.hasShortcutHostPermission(getCallingUserId(), callingPackage); callingPackage, injectBinderCallingPid(), injectBinderCallingUid()); } @Override Loading @@ -536,7 +543,8 @@ public class LauncherAppsService extends SystemService { } final Intent[] intents = mShortcutServiceInternal.createShortcutIntents( getCallingUserId(), callingPackage, packageName, shortcutId, targetUserId); getCallingUserId(), callingPackage, packageName, shortcutId, targetUserId, injectBinderCallingPid(), injectBinderCallingUid()); if (intents == null || intents.length == 0) { return false; } Loading Loading @@ -901,7 +909,8 @@ public class LauncherAppsService extends SystemService { // Make sure the caller has the permission. if (!mShortcutServiceInternal.hasShortcutHostPermission( launcherUserId, cookie.packageName)) { launcherUserId, cookie.packageName, cookie.callingPid, cookie.callingUid)) { continue; } // Each launcher has a different set of pinned shortcuts, so we need to do a Loading @@ -914,8 +923,8 @@ public class LauncherAppsService extends SystemService { /* changedSince= */ 0, packageName, /* shortcutIds=*/ null, /* component= */ null, ShortcutQuery.FLAG_GET_KEY_FIELDS_ONLY | ShortcutQuery.FLAG_GET_ALL_KINDS , userId); | ShortcutQuery.FLAG_MATCH_ALL_KINDS_WITH_ALL_PINNED , userId, cookie.callingPid, cookie.callingUid); try { listener.onShortcutChanged(user, packageName, new ParceledListSlice<>(list)); Loading