Loading core/java/android/content/pm/ILauncherApps.aidl +2 −2 Original line number Diff line number Diff line Loading @@ -99,9 +99,9 @@ interface ILauncherApps { in IShortcutChangeCallback callback); void cacheShortcuts(String callingPackage, String packageName, in List<String> shortcutIds, in UserHandle user); in UserHandle user, int cacheFlags); void uncacheShortcuts(String callingPackage, String packageName, in List<String> shortcutIds, in UserHandle user); in UserHandle user, int cacheFlags); String getShortcutIconUri(String callingPackage, String packageName, String shortcutId, int userId); Loading core/java/android/content/pm/LauncherApps.java +36 −4 Original line number Diff line number Diff line Loading @@ -155,6 +155,26 @@ public class LauncherApps { public static final String EXTRA_PIN_ITEM_REQUEST = "android.content.pm.extra.PIN_ITEM_REQUEST"; /** * Cache shortcuts which are used in notifications. * @hide */ public static final int FLAG_CACHE_NOTIFICATION_SHORTCUTS = 0; /** * Cache shortcuts which are used in bubbles. * @hide */ public static final int FLAG_CACHE_BUBBLE_SHORTCUTS = 1; /** @hide */ @IntDef(flag = false, prefix = { "FLAG_CACHE_" }, value = { FLAG_CACHE_NOTIFICATION_SHORTCUTS, FLAG_CACHE_BUBBLE_SHORTCUTS, }) @Retention(RetentionPolicy.SOURCE) public @interface ShortcutCacheFlags {} private final Context mContext; @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.P, trackingBug = 115609023) private final ILauncherApps mService; Loading Loading @@ -1109,6 +1129,11 @@ public class LauncherApps { * @param packageName The target package name. * @param shortcutIds The IDs of the shortcut to be cached. * @param user The UserHandle of the profile. * @param cacheFlags One of the values in: * <ul> * <li>{@link #FLAG_CACHE_NOTIFICATION_SHORTCUTS} * <li>{@link #FLAG_CACHE_BUBBLE_SHORTCUTS} * </ul> * @throws IllegalStateException when the user is locked, or when the {@code user} user * is locked or not running. * Loading @@ -1118,10 +1143,11 @@ public class LauncherApps { */ @RequiresPermission(android.Manifest.permission.ACCESS_SHORTCUTS) public void cacheShortcuts(@NonNull String packageName, @NonNull List<String> shortcutIds, @NonNull UserHandle user) { @NonNull UserHandle user, @ShortcutCacheFlags int cacheFlags) { logErrorForInvalidProfileAccess(user); try { mService.cacheShortcuts(mContext.getPackageName(), packageName, shortcutIds, user); mService.cacheShortcuts( mContext.getPackageName(), packageName, shortcutIds, user, cacheFlags); } catch (RemoteException e) { throw e.rethrowFromSystemServer(); } Loading @@ -1133,6 +1159,11 @@ public class LauncherApps { * @param packageName The target package name. * @param shortcutIds The IDs of the shortcut to be uncached. * @param user The UserHandle of the profile. * @param cacheFlags One of the values in: * <ul> * <li>{@link #FLAG_CACHE_NOTIFICATION_SHORTCUTS} * <li>{@link #FLAG_CACHE_BUBBLE_SHORTCUTS} * </ul> * @throws IllegalStateException when the user is locked, or when the {@code user} user * is locked or not running. * Loading @@ -1142,10 +1173,11 @@ public class LauncherApps { */ @RequiresPermission(android.Manifest.permission.ACCESS_SHORTCUTS) public void uncacheShortcuts(@NonNull String packageName, @NonNull List<String> shortcutIds, @NonNull UserHandle user) { @NonNull UserHandle user, @ShortcutCacheFlags int cacheFlags) { logErrorForInvalidProfileAccess(user); try { mService.uncacheShortcuts(mContext.getPackageName(), packageName, shortcutIds, user); mService.uncacheShortcuts( mContext.getPackageName(), packageName, shortcutIds, user, cacheFlags); } catch (RemoteException e) { throw e.rethrowFromSystemServer(); } Loading core/java/android/content/pm/ShortcutInfo.java +23 −7 Original line number Diff line number Diff line Loading @@ -119,12 +119,27 @@ public final class ShortcutInfo implements Parcelable { /** @hide */ public static final int FLAG_LONG_LIVED = 1 << 13; /** @hide */ public static final int FLAG_CACHED = 1 << 14; /** * TODO(b/155135057): This is a quick and temporary fix for b/155135890. ShortcutService doesn't * need to be aware of the outside world. Replace this with a more extensible solution. * @hide */ public static final int FLAG_CACHED_NOTIFICATIONS = 1 << 14; /** @hide */ public static final int FLAG_HAS_ICON_URI = 1 << 15; /** * TODO(b/155135057): This is a quick and temporary fix for b/155135890. ShortcutService doesn't * need to be aware of the outside world. Replace this with a more extensible solution. * @hide */ public static final int FLAG_CACHED_BUBBLES = 1 << 30; /** @hide */ public static final int FLAG_CACHED_ALL = FLAG_CACHED_NOTIFICATIONS | FLAG_CACHED_BUBBLES; /** @hide */ @IntDef(flag = true, prefix = { "FLAG_" }, value = { FLAG_DYNAMIC, Loading @@ -141,8 +156,9 @@ public final class ShortcutInfo implements Parcelable { FLAG_ICON_FILE_PENDING_SAVE, FLAG_SHADOW, FLAG_LONG_LIVED, FLAG_CACHED, FLAG_HAS_ICON_URI, FLAG_CACHED_NOTIFICATIONS, FLAG_CACHED_BUBBLES, }) @Retention(RetentionPolicy.SOURCE) public @interface ShortcutFlags {} Loading Loading @@ -1707,13 +1723,13 @@ public final class ShortcutInfo implements Parcelable { } /** @hide */ public void setCached() { addFlags(FLAG_CACHED); public void setCached(@ShortcutFlags int cacheFlag) { addFlags(cacheFlag); } /** Return whether a shortcut is cached. */ public boolean isCached() { return hasFlags(FLAG_CACHED); return (getFlags() & FLAG_CACHED_ALL) != 0; } /** Return whether a shortcut is dynamic. */ Loading Loading @@ -1807,7 +1823,7 @@ public final class ShortcutInfo implements Parcelable { /** @hide */ public boolean isAlive() { return hasFlags(FLAG_PINNED) || hasFlags(FLAG_DYNAMIC) || hasFlags(FLAG_MANIFEST) || hasFlags(FLAG_CACHED); || isCached(); } /** @hide */ Loading core/java/android/content/pm/ShortcutServiceInternal.java +2 −2 Original line number Diff line number Diff line Loading @@ -92,10 +92,10 @@ public abstract class ShortcutServiceInternal { public abstract void cacheShortcuts(int launcherUserId, @NonNull String callingPackage, @NonNull String packageName, @NonNull List<String> shortcutIds, int userId); @NonNull List<String> shortcutIds, int userId, int cacheFlags); public abstract void uncacheShortcuts(int launcherUserId, @NonNull String callingPackage, @NonNull String packageName, @NonNull List<String> shortcutIds, int userId); @NonNull List<String> shortcutIds, int userId, int cacheFlags); /** * Retrieves all of the direct share targets that match the given IntentFilter for the specified Loading services/core/java/com/android/server/notification/ShortcutHelper.java +1 −1 Original line number Diff line number Diff line Loading @@ -208,7 +208,7 @@ public class ShortcutHelper { if (shortcutInfo.isLongLived() && !shortcutInfo.isCached()) { mShortcutServiceInternal.cacheShortcuts(user.getIdentifier(), "android", shortcutInfo.getPackage(), Collections.singletonList(shortcutInfo.getId()), shortcutInfo.getUserId()); shortcutInfo.getUserId(), ShortcutInfo.FLAG_CACHED_NOTIFICATIONS); } } Loading Loading
core/java/android/content/pm/ILauncherApps.aidl +2 −2 Original line number Diff line number Diff line Loading @@ -99,9 +99,9 @@ interface ILauncherApps { in IShortcutChangeCallback callback); void cacheShortcuts(String callingPackage, String packageName, in List<String> shortcutIds, in UserHandle user); in UserHandle user, int cacheFlags); void uncacheShortcuts(String callingPackage, String packageName, in List<String> shortcutIds, in UserHandle user); in UserHandle user, int cacheFlags); String getShortcutIconUri(String callingPackage, String packageName, String shortcutId, int userId); Loading
core/java/android/content/pm/LauncherApps.java +36 −4 Original line number Diff line number Diff line Loading @@ -155,6 +155,26 @@ public class LauncherApps { public static final String EXTRA_PIN_ITEM_REQUEST = "android.content.pm.extra.PIN_ITEM_REQUEST"; /** * Cache shortcuts which are used in notifications. * @hide */ public static final int FLAG_CACHE_NOTIFICATION_SHORTCUTS = 0; /** * Cache shortcuts which are used in bubbles. * @hide */ public static final int FLAG_CACHE_BUBBLE_SHORTCUTS = 1; /** @hide */ @IntDef(flag = false, prefix = { "FLAG_CACHE_" }, value = { FLAG_CACHE_NOTIFICATION_SHORTCUTS, FLAG_CACHE_BUBBLE_SHORTCUTS, }) @Retention(RetentionPolicy.SOURCE) public @interface ShortcutCacheFlags {} private final Context mContext; @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.P, trackingBug = 115609023) private final ILauncherApps mService; Loading Loading @@ -1109,6 +1129,11 @@ public class LauncherApps { * @param packageName The target package name. * @param shortcutIds The IDs of the shortcut to be cached. * @param user The UserHandle of the profile. * @param cacheFlags One of the values in: * <ul> * <li>{@link #FLAG_CACHE_NOTIFICATION_SHORTCUTS} * <li>{@link #FLAG_CACHE_BUBBLE_SHORTCUTS} * </ul> * @throws IllegalStateException when the user is locked, or when the {@code user} user * is locked or not running. * Loading @@ -1118,10 +1143,11 @@ public class LauncherApps { */ @RequiresPermission(android.Manifest.permission.ACCESS_SHORTCUTS) public void cacheShortcuts(@NonNull String packageName, @NonNull List<String> shortcutIds, @NonNull UserHandle user) { @NonNull UserHandle user, @ShortcutCacheFlags int cacheFlags) { logErrorForInvalidProfileAccess(user); try { mService.cacheShortcuts(mContext.getPackageName(), packageName, shortcutIds, user); mService.cacheShortcuts( mContext.getPackageName(), packageName, shortcutIds, user, cacheFlags); } catch (RemoteException e) { throw e.rethrowFromSystemServer(); } Loading @@ -1133,6 +1159,11 @@ public class LauncherApps { * @param packageName The target package name. * @param shortcutIds The IDs of the shortcut to be uncached. * @param user The UserHandle of the profile. * @param cacheFlags One of the values in: * <ul> * <li>{@link #FLAG_CACHE_NOTIFICATION_SHORTCUTS} * <li>{@link #FLAG_CACHE_BUBBLE_SHORTCUTS} * </ul> * @throws IllegalStateException when the user is locked, or when the {@code user} user * is locked or not running. * Loading @@ -1142,10 +1173,11 @@ public class LauncherApps { */ @RequiresPermission(android.Manifest.permission.ACCESS_SHORTCUTS) public void uncacheShortcuts(@NonNull String packageName, @NonNull List<String> shortcutIds, @NonNull UserHandle user) { @NonNull UserHandle user, @ShortcutCacheFlags int cacheFlags) { logErrorForInvalidProfileAccess(user); try { mService.uncacheShortcuts(mContext.getPackageName(), packageName, shortcutIds, user); mService.uncacheShortcuts( mContext.getPackageName(), packageName, shortcutIds, user, cacheFlags); } catch (RemoteException e) { throw e.rethrowFromSystemServer(); } Loading
core/java/android/content/pm/ShortcutInfo.java +23 −7 Original line number Diff line number Diff line Loading @@ -119,12 +119,27 @@ public final class ShortcutInfo implements Parcelable { /** @hide */ public static final int FLAG_LONG_LIVED = 1 << 13; /** @hide */ public static final int FLAG_CACHED = 1 << 14; /** * TODO(b/155135057): This is a quick and temporary fix for b/155135890. ShortcutService doesn't * need to be aware of the outside world. Replace this with a more extensible solution. * @hide */ public static final int FLAG_CACHED_NOTIFICATIONS = 1 << 14; /** @hide */ public static final int FLAG_HAS_ICON_URI = 1 << 15; /** * TODO(b/155135057): This is a quick and temporary fix for b/155135890. ShortcutService doesn't * need to be aware of the outside world. Replace this with a more extensible solution. * @hide */ public static final int FLAG_CACHED_BUBBLES = 1 << 30; /** @hide */ public static final int FLAG_CACHED_ALL = FLAG_CACHED_NOTIFICATIONS | FLAG_CACHED_BUBBLES; /** @hide */ @IntDef(flag = true, prefix = { "FLAG_" }, value = { FLAG_DYNAMIC, Loading @@ -141,8 +156,9 @@ public final class ShortcutInfo implements Parcelable { FLAG_ICON_FILE_PENDING_SAVE, FLAG_SHADOW, FLAG_LONG_LIVED, FLAG_CACHED, FLAG_HAS_ICON_URI, FLAG_CACHED_NOTIFICATIONS, FLAG_CACHED_BUBBLES, }) @Retention(RetentionPolicy.SOURCE) public @interface ShortcutFlags {} Loading Loading @@ -1707,13 +1723,13 @@ public final class ShortcutInfo implements Parcelable { } /** @hide */ public void setCached() { addFlags(FLAG_CACHED); public void setCached(@ShortcutFlags int cacheFlag) { addFlags(cacheFlag); } /** Return whether a shortcut is cached. */ public boolean isCached() { return hasFlags(FLAG_CACHED); return (getFlags() & FLAG_CACHED_ALL) != 0; } /** Return whether a shortcut is dynamic. */ Loading Loading @@ -1807,7 +1823,7 @@ public final class ShortcutInfo implements Parcelable { /** @hide */ public boolean isAlive() { return hasFlags(FLAG_PINNED) || hasFlags(FLAG_DYNAMIC) || hasFlags(FLAG_MANIFEST) || hasFlags(FLAG_CACHED); || isCached(); } /** @hide */ Loading
core/java/android/content/pm/ShortcutServiceInternal.java +2 −2 Original line number Diff line number Diff line Loading @@ -92,10 +92,10 @@ public abstract class ShortcutServiceInternal { public abstract void cacheShortcuts(int launcherUserId, @NonNull String callingPackage, @NonNull String packageName, @NonNull List<String> shortcutIds, int userId); @NonNull List<String> shortcutIds, int userId, int cacheFlags); public abstract void uncacheShortcuts(int launcherUserId, @NonNull String callingPackage, @NonNull String packageName, @NonNull List<String> shortcutIds, int userId); @NonNull List<String> shortcutIds, int userId, int cacheFlags); /** * Retrieves all of the direct share targets that match the given IntentFilter for the specified Loading
services/core/java/com/android/server/notification/ShortcutHelper.java +1 −1 Original line number Diff line number Diff line Loading @@ -208,7 +208,7 @@ public class ShortcutHelper { if (shortcutInfo.isLongLived() && !shortcutInfo.isCached()) { mShortcutServiceInternal.cacheShortcuts(user.getIdentifier(), "android", shortcutInfo.getPackage(), Collections.singletonList(shortcutInfo.getId()), shortcutInfo.getUserId()); shortcutInfo.getUserId(), ShortcutInfo.FLAG_CACHED_NOTIFICATIONS); } } Loading