Loading core/java/android/content/pm/LauncherApps.java +21 −13 Original line number Original line Diff line number Diff line Loading @@ -492,7 +492,7 @@ public class LauncherApps { * If the calling launcher application contains pinned shortcuts, they will still work, * If the calling launcher application contains pinned shortcuts, they will still work, * even though the caller no longer has the shortcut host permission. * even though the caller no longer has the shortcut host permission. * * * @throws IllegalStateException when the user is locked. * <p>Returns {@code false} when the user is locked. * * * @see ShortcutManager * @see ShortcutManager */ */ Loading @@ -510,12 +510,13 @@ public class LauncherApps { * <p>Callers must be allowed to access the shortcut information, as defined in {@link * <p>Callers must be allowed to access the shortcut information, as defined in {@link * #hasShortcutHostPermission()}. * #hasShortcutHostPermission()}. * * * <p>Returns am empty list when the user is locked, or when the {@code user} user * is locked or not running. * * @param query result includes shortcuts matching this query. * @param query result includes shortcuts matching this query. * @param user The UserHandle of the profile. * @param user The UserHandle of the profile. * * * @return the IDs of {@link ShortcutInfo}s that match the query. * @return the IDs of {@link ShortcutInfo}s that match the query. * @throws IllegalStateException when the user is locked, or when the {@code user} user * is locked or not running. * * * @see ShortcutManager * @see ShortcutManager */ */ Loading Loading @@ -555,11 +556,12 @@ public class LauncherApps { * <p>The calling launcher application must be allowed to access the shortcut information, * <p>The calling launcher application must be allowed to access the shortcut information, * as defined in {@link #hasShortcutHostPermission()}. * as defined in {@link #hasShortcutHostPermission()}. * * * <p>Call will be ignored when the user is locked, or when the {@code user} user * is locked or not running. * * @param packageName The target package name. * @param packageName The target package name. * @param shortcutIds The IDs of the shortcut to be pinned. * @param shortcutIds The IDs of the shortcut to be pinned. * @param user The UserHandle of the profile. * @param user The UserHandle of the profile. * @throws IllegalStateException when the user is locked, or when the {@code user} user * is locked or not running. * * * @see ShortcutManager * @see ShortcutManager */ */ Loading Loading @@ -628,12 +630,13 @@ public class LauncherApps { * <p>The calling launcher application must be allowed to access the shortcut information, * <p>The calling launcher application must be allowed to access the shortcut information, * as defined in {@link #hasShortcutHostPermission()}. * as defined in {@link #hasShortcutHostPermission()}. * * * <p>Returns {@code null} when the user is locked, or when the user owning the shortcut * is locked or not running. * * @param density The preferred density of the icon, zero for default density. Use * @param density The preferred density of the icon, zero for default density. Use * density DPI values from {@link DisplayMetrics}. * density DPI values from {@link DisplayMetrics}. * * * @return The drawable associated with the shortcut. * @return The drawable associated with the shortcut. * @throws IllegalStateException when the user is locked, or when the {@code user} user * is locked or not running. * * * @see ShortcutManager * @see ShortcutManager * @see #getShortcutBadgedIconDrawable(ShortcutInfo, int) * @see #getShortcutBadgedIconDrawable(ShortcutInfo, int) Loading Loading @@ -678,10 +681,11 @@ public class LauncherApps { * <p>The calling launcher application must be allowed to access the shortcut information, * <p>The calling launcher application must be allowed to access the shortcut information, * as defined in {@link #hasShortcutHostPermission()}. * as defined in {@link #hasShortcutHostPermission()}. * * * <p>Returns {@code 0} when the user is locked, or when the user owning the shortcut * is locked or not running. * * @param density Optional density for the icon, or 0 to use the default density. Use * @param density Optional density for the icon, or 0 to use the default density. Use * @return A badged icon for the shortcut. * @return A badged icon for the shortcut. * @throws IllegalStateException when the user is locked, or when the {@code user} user * is locked or not running. * * * @see ShortcutManager * @see ShortcutManager * @see #getShortcutIconDrawable(ShortcutInfo, int) * @see #getShortcutIconDrawable(ShortcutInfo, int) Loading @@ -700,13 +704,15 @@ public class LauncherApps { * <p>The calling launcher application must be allowed to access the shortcut information, * <p>The calling launcher application must be allowed to access the shortcut information, * as defined in {@link #hasShortcutHostPermission()}. * as defined in {@link #hasShortcutHostPermission()}. * * * <p>Throws {@link android.content.ActivityNotFoundException} * when the user is locked, or when the {@code user} user * is locked or not running. * * @param packageName The target shortcut package name. * @param packageName The target shortcut package name. * @param shortcutId The target shortcut ID. * @param shortcutId The target shortcut ID. * @param sourceBounds The Rect containing the source bounds of the clicked icon. * @param sourceBounds The Rect containing the source bounds of the clicked icon. * @param startActivityOptions Options to pass to startActivity. * @param startActivityOptions Options to pass to startActivity. * @param user The UserHandle of the profile. * @param user The UserHandle of the profile. * @throws IllegalStateException when the user is locked, or when the {@code user} user * is locked or not running. * * * @throws android.content.ActivityNotFoundException failed to start shortcut. (e.g. * @throws android.content.ActivityNotFoundException failed to start shortcut. (e.g. * the shortcut no longer exists, is disabled, the intent receiver activity doesn't exist, etc) * the shortcut no longer exists, is disabled, the intent receiver activity doesn't exist, etc) Loading @@ -724,11 +730,13 @@ public class LauncherApps { * <p>The calling launcher application must be allowed to access the shortcut information, * <p>The calling launcher application must be allowed to access the shortcut information, * as defined in {@link #hasShortcutHostPermission()}. * as defined in {@link #hasShortcutHostPermission()}. * * * <p>Throws {@link android.content.ActivityNotFoundException} * when the user is locked, or when the user owning the shortcut * is locked or not running. * * @param shortcut The target shortcut. * @param shortcut The target shortcut. * @param sourceBounds The Rect containing the source bounds of the clicked icon. * @param sourceBounds The Rect containing the source bounds of the clicked icon. * @param startActivityOptions Options to pass to startActivity. * @param startActivityOptions Options to pass to startActivity. * @throws IllegalStateException when the user is locked, or when the {@code user} user * is locked or not running. * * * @throws android.content.ActivityNotFoundException failed to start shortcut. (e.g. * @throws android.content.ActivityNotFoundException failed to start shortcut. (e.g. * the shortcut no longer exists, is disabled, the intent receiver activity doesn't exist, etc) * the shortcut no longer exists, is disabled, the intent receiver activity doesn't exist, etc) Loading services/core/java/com/android/server/pm/ShortcutService.java +24 −16 Original line number Original line Diff line number Diff line Loading @@ -2170,9 +2170,9 @@ public class ShortcutService extends IShortcutService.Stub { @Nullable ComponentName componentName, @Nullable ComponentName componentName, int queryFlags, int userId) { int queryFlags, int userId) { final ArrayList<ShortcutInfo> ret = new ArrayList<>(); final ArrayList<ShortcutInfo> ret = new ArrayList<>(); if (!isUserUnlocked(userId) || !isUserUnlocked(launcherUserId)) { throwIfUserLocked(userId); return ret; throwIfUserLocked(launcherUserId); } final boolean cloneKeyFieldOnly = final boolean cloneKeyFieldOnly = ((queryFlags & ShortcutQuery.FLAG_GET_KEY_FIELDS_ONLY) != 0); ((queryFlags & ShortcutQuery.FLAG_GET_KEY_FIELDS_ONLY) != 0); Loading Loading @@ -2251,8 +2251,9 @@ public class ShortcutService extends IShortcutService.Stub { Preconditions.checkStringNotEmpty(packageName, "packageName"); Preconditions.checkStringNotEmpty(packageName, "packageName"); Preconditions.checkStringNotEmpty(shortcutId, "shortcutId"); Preconditions.checkStringNotEmpty(shortcutId, "shortcutId"); throwIfUserLocked(userId); if (!isUserUnlocked(userId) || !isUserUnlocked(launcherUserId)) { throwIfUserLocked(launcherUserId); return false; } synchronized (mLock) { synchronized (mLock) { getLauncherShortcutsLocked(callingPackage, userId, launcherUserId) getLauncherShortcutsLocked(callingPackage, userId, launcherUserId) Loading @@ -2270,8 +2271,9 @@ public class ShortcutService extends IShortcutService.Stub { Preconditions.checkStringNotEmpty(packageName, "packageName"); Preconditions.checkStringNotEmpty(packageName, "packageName"); Preconditions.checkStringNotEmpty(shortcutId, "shortcutId"); Preconditions.checkStringNotEmpty(shortcutId, "shortcutId"); throwIfUserLocked(userId); if (!isUserUnlocked(userId) || !isUserUnlocked(launcherUserId)) { throwIfUserLocked(launcherUserId); return null; } final ShortcutPackage p = getUserShortcutsLocked(userId) final ShortcutPackage p = getUserShortcutsLocked(userId) .getPackageShortcutsIfExists(packageName); .getPackageShortcutsIfExists(packageName); Loading @@ -2294,8 +2296,9 @@ public class ShortcutService extends IShortcutService.Stub { Preconditions.checkStringNotEmpty(packageName, "packageName"); Preconditions.checkStringNotEmpty(packageName, "packageName"); Preconditions.checkNotNull(shortcutIds, "shortcutIds"); Preconditions.checkNotNull(shortcutIds, "shortcutIds"); throwIfUserLocked(userId); if (!isUserUnlocked(userId) || !isUserUnlocked(launcherUserId)) { throwIfUserLocked(launcherUserId); return; } synchronized (mLock) { synchronized (mLock) { final ShortcutLauncher launcher = final ShortcutLauncher launcher = Loading @@ -2317,8 +2320,9 @@ public class ShortcutService extends IShortcutService.Stub { Preconditions.checkStringNotEmpty(packageName, "packageName can't be empty"); Preconditions.checkStringNotEmpty(packageName, "packageName can't be empty"); Preconditions.checkStringNotEmpty(shortcutId, "shortcutId can't be empty"); Preconditions.checkStringNotEmpty(shortcutId, "shortcutId can't be empty"); throwIfUserLocked(userId); if (!isUserUnlocked(userId) || !isUserUnlocked(launcherUserId)) { throwIfUserLocked(launcherUserId); return null; } synchronized (mLock) { synchronized (mLock) { getLauncherShortcutsLocked(callingPackage, userId, launcherUserId) getLauncherShortcutsLocked(callingPackage, userId, launcherUserId) Loading Loading @@ -2350,8 +2354,9 @@ public class ShortcutService extends IShortcutService.Stub { Preconditions.checkNotNull(packageName, "packageName"); Preconditions.checkNotNull(packageName, "packageName"); Preconditions.checkNotNull(shortcutId, "shortcutId"); Preconditions.checkNotNull(shortcutId, "shortcutId"); throwIfUserLocked(userId); if (!isUserUnlocked(userId) || !isUserUnlocked(launcherUserId)) { throwIfUserLocked(launcherUserId); return 0; } synchronized (mLock) { synchronized (mLock) { getLauncherShortcutsLocked(callingPackage, userId, launcherUserId) getLauncherShortcutsLocked(callingPackage, userId, launcherUserId) Loading @@ -2377,8 +2382,9 @@ public class ShortcutService extends IShortcutService.Stub { Preconditions.checkNotNull(packageName, "packageName"); Preconditions.checkNotNull(packageName, "packageName"); Preconditions.checkNotNull(shortcutId, "shortcutId"); Preconditions.checkNotNull(shortcutId, "shortcutId"); throwIfUserLocked(userId); if (!isUserUnlocked(userId) || !isUserUnlocked(launcherUserId)) { throwIfUserLocked(launcherUserId); return null; } synchronized (mLock) { synchronized (mLock) { getLauncherShortcutsLocked(callingPackage, userId, launcherUserId) getLauncherShortcutsLocked(callingPackage, userId, launcherUserId) Loading Loading @@ -2412,7 +2418,9 @@ public class ShortcutService extends IShortcutService.Stub { @Override @Override public boolean hasShortcutHostPermission(int launcherUserId, public boolean hasShortcutHostPermission(int launcherUserId, @NonNull String callingPackage) { @NonNull String callingPackage) { throwIfUserLocked(launcherUserId); if (!isUserUnlocked(launcherUserId)) { return false; } return ShortcutService.this.hasShortcutHostPermission(callingPackage, launcherUserId); return ShortcutService.this.hasShortcutHostPermission(callingPackage, launcherUserId); } } } } Loading Loading
core/java/android/content/pm/LauncherApps.java +21 −13 Original line number Original line Diff line number Diff line Loading @@ -492,7 +492,7 @@ public class LauncherApps { * If the calling launcher application contains pinned shortcuts, they will still work, * If the calling launcher application contains pinned shortcuts, they will still work, * even though the caller no longer has the shortcut host permission. * even though the caller no longer has the shortcut host permission. * * * @throws IllegalStateException when the user is locked. * <p>Returns {@code false} when the user is locked. * * * @see ShortcutManager * @see ShortcutManager */ */ Loading @@ -510,12 +510,13 @@ public class LauncherApps { * <p>Callers must be allowed to access the shortcut information, as defined in {@link * <p>Callers must be allowed to access the shortcut information, as defined in {@link * #hasShortcutHostPermission()}. * #hasShortcutHostPermission()}. * * * <p>Returns am empty list when the user is locked, or when the {@code user} user * is locked or not running. * * @param query result includes shortcuts matching this query. * @param query result includes shortcuts matching this query. * @param user The UserHandle of the profile. * @param user The UserHandle of the profile. * * * @return the IDs of {@link ShortcutInfo}s that match the query. * @return the IDs of {@link ShortcutInfo}s that match the query. * @throws IllegalStateException when the user is locked, or when the {@code user} user * is locked or not running. * * * @see ShortcutManager * @see ShortcutManager */ */ Loading Loading @@ -555,11 +556,12 @@ public class LauncherApps { * <p>The calling launcher application must be allowed to access the shortcut information, * <p>The calling launcher application must be allowed to access the shortcut information, * as defined in {@link #hasShortcutHostPermission()}. * as defined in {@link #hasShortcutHostPermission()}. * * * <p>Call will be ignored when the user is locked, or when the {@code user} user * is locked or not running. * * @param packageName The target package name. * @param packageName The target package name. * @param shortcutIds The IDs of the shortcut to be pinned. * @param shortcutIds The IDs of the shortcut to be pinned. * @param user The UserHandle of the profile. * @param user The UserHandle of the profile. * @throws IllegalStateException when the user is locked, or when the {@code user} user * is locked or not running. * * * @see ShortcutManager * @see ShortcutManager */ */ Loading Loading @@ -628,12 +630,13 @@ public class LauncherApps { * <p>The calling launcher application must be allowed to access the shortcut information, * <p>The calling launcher application must be allowed to access the shortcut information, * as defined in {@link #hasShortcutHostPermission()}. * as defined in {@link #hasShortcutHostPermission()}. * * * <p>Returns {@code null} when the user is locked, or when the user owning the shortcut * is locked or not running. * * @param density The preferred density of the icon, zero for default density. Use * @param density The preferred density of the icon, zero for default density. Use * density DPI values from {@link DisplayMetrics}. * density DPI values from {@link DisplayMetrics}. * * * @return The drawable associated with the shortcut. * @return The drawable associated with the shortcut. * @throws IllegalStateException when the user is locked, or when the {@code user} user * is locked or not running. * * * @see ShortcutManager * @see ShortcutManager * @see #getShortcutBadgedIconDrawable(ShortcutInfo, int) * @see #getShortcutBadgedIconDrawable(ShortcutInfo, int) Loading Loading @@ -678,10 +681,11 @@ public class LauncherApps { * <p>The calling launcher application must be allowed to access the shortcut information, * <p>The calling launcher application must be allowed to access the shortcut information, * as defined in {@link #hasShortcutHostPermission()}. * as defined in {@link #hasShortcutHostPermission()}. * * * <p>Returns {@code 0} when the user is locked, or when the user owning the shortcut * is locked or not running. * * @param density Optional density for the icon, or 0 to use the default density. Use * @param density Optional density for the icon, or 0 to use the default density. Use * @return A badged icon for the shortcut. * @return A badged icon for the shortcut. * @throws IllegalStateException when the user is locked, or when the {@code user} user * is locked or not running. * * * @see ShortcutManager * @see ShortcutManager * @see #getShortcutIconDrawable(ShortcutInfo, int) * @see #getShortcutIconDrawable(ShortcutInfo, int) Loading @@ -700,13 +704,15 @@ public class LauncherApps { * <p>The calling launcher application must be allowed to access the shortcut information, * <p>The calling launcher application must be allowed to access the shortcut information, * as defined in {@link #hasShortcutHostPermission()}. * as defined in {@link #hasShortcutHostPermission()}. * * * <p>Throws {@link android.content.ActivityNotFoundException} * when the user is locked, or when the {@code user} user * is locked or not running. * * @param packageName The target shortcut package name. * @param packageName The target shortcut package name. * @param shortcutId The target shortcut ID. * @param shortcutId The target shortcut ID. * @param sourceBounds The Rect containing the source bounds of the clicked icon. * @param sourceBounds The Rect containing the source bounds of the clicked icon. * @param startActivityOptions Options to pass to startActivity. * @param startActivityOptions Options to pass to startActivity. * @param user The UserHandle of the profile. * @param user The UserHandle of the profile. * @throws IllegalStateException when the user is locked, or when the {@code user} user * is locked or not running. * * * @throws android.content.ActivityNotFoundException failed to start shortcut. (e.g. * @throws android.content.ActivityNotFoundException failed to start shortcut. (e.g. * the shortcut no longer exists, is disabled, the intent receiver activity doesn't exist, etc) * the shortcut no longer exists, is disabled, the intent receiver activity doesn't exist, etc) Loading @@ -724,11 +730,13 @@ public class LauncherApps { * <p>The calling launcher application must be allowed to access the shortcut information, * <p>The calling launcher application must be allowed to access the shortcut information, * as defined in {@link #hasShortcutHostPermission()}. * as defined in {@link #hasShortcutHostPermission()}. * * * <p>Throws {@link android.content.ActivityNotFoundException} * when the user is locked, or when the user owning the shortcut * is locked or not running. * * @param shortcut The target shortcut. * @param shortcut The target shortcut. * @param sourceBounds The Rect containing the source bounds of the clicked icon. * @param sourceBounds The Rect containing the source bounds of the clicked icon. * @param startActivityOptions Options to pass to startActivity. * @param startActivityOptions Options to pass to startActivity. * @throws IllegalStateException when the user is locked, or when the {@code user} user * is locked or not running. * * * @throws android.content.ActivityNotFoundException failed to start shortcut. (e.g. * @throws android.content.ActivityNotFoundException failed to start shortcut. (e.g. * the shortcut no longer exists, is disabled, the intent receiver activity doesn't exist, etc) * the shortcut no longer exists, is disabled, the intent receiver activity doesn't exist, etc) Loading
services/core/java/com/android/server/pm/ShortcutService.java +24 −16 Original line number Original line Diff line number Diff line Loading @@ -2170,9 +2170,9 @@ public class ShortcutService extends IShortcutService.Stub { @Nullable ComponentName componentName, @Nullable ComponentName componentName, int queryFlags, int userId) { int queryFlags, int userId) { final ArrayList<ShortcutInfo> ret = new ArrayList<>(); final ArrayList<ShortcutInfo> ret = new ArrayList<>(); if (!isUserUnlocked(userId) || !isUserUnlocked(launcherUserId)) { throwIfUserLocked(userId); return ret; throwIfUserLocked(launcherUserId); } final boolean cloneKeyFieldOnly = final boolean cloneKeyFieldOnly = ((queryFlags & ShortcutQuery.FLAG_GET_KEY_FIELDS_ONLY) != 0); ((queryFlags & ShortcutQuery.FLAG_GET_KEY_FIELDS_ONLY) != 0); Loading Loading @@ -2251,8 +2251,9 @@ public class ShortcutService extends IShortcutService.Stub { Preconditions.checkStringNotEmpty(packageName, "packageName"); Preconditions.checkStringNotEmpty(packageName, "packageName"); Preconditions.checkStringNotEmpty(shortcutId, "shortcutId"); Preconditions.checkStringNotEmpty(shortcutId, "shortcutId"); throwIfUserLocked(userId); if (!isUserUnlocked(userId) || !isUserUnlocked(launcherUserId)) { throwIfUserLocked(launcherUserId); return false; } synchronized (mLock) { synchronized (mLock) { getLauncherShortcutsLocked(callingPackage, userId, launcherUserId) getLauncherShortcutsLocked(callingPackage, userId, launcherUserId) Loading @@ -2270,8 +2271,9 @@ public class ShortcutService extends IShortcutService.Stub { Preconditions.checkStringNotEmpty(packageName, "packageName"); Preconditions.checkStringNotEmpty(packageName, "packageName"); Preconditions.checkStringNotEmpty(shortcutId, "shortcutId"); Preconditions.checkStringNotEmpty(shortcutId, "shortcutId"); throwIfUserLocked(userId); if (!isUserUnlocked(userId) || !isUserUnlocked(launcherUserId)) { throwIfUserLocked(launcherUserId); return null; } final ShortcutPackage p = getUserShortcutsLocked(userId) final ShortcutPackage p = getUserShortcutsLocked(userId) .getPackageShortcutsIfExists(packageName); .getPackageShortcutsIfExists(packageName); Loading @@ -2294,8 +2296,9 @@ public class ShortcutService extends IShortcutService.Stub { Preconditions.checkStringNotEmpty(packageName, "packageName"); Preconditions.checkStringNotEmpty(packageName, "packageName"); Preconditions.checkNotNull(shortcutIds, "shortcutIds"); Preconditions.checkNotNull(shortcutIds, "shortcutIds"); throwIfUserLocked(userId); if (!isUserUnlocked(userId) || !isUserUnlocked(launcherUserId)) { throwIfUserLocked(launcherUserId); return; } synchronized (mLock) { synchronized (mLock) { final ShortcutLauncher launcher = final ShortcutLauncher launcher = Loading @@ -2317,8 +2320,9 @@ public class ShortcutService extends IShortcutService.Stub { Preconditions.checkStringNotEmpty(packageName, "packageName can't be empty"); Preconditions.checkStringNotEmpty(packageName, "packageName can't be empty"); Preconditions.checkStringNotEmpty(shortcutId, "shortcutId can't be empty"); Preconditions.checkStringNotEmpty(shortcutId, "shortcutId can't be empty"); throwIfUserLocked(userId); if (!isUserUnlocked(userId) || !isUserUnlocked(launcherUserId)) { throwIfUserLocked(launcherUserId); return null; } synchronized (mLock) { synchronized (mLock) { getLauncherShortcutsLocked(callingPackage, userId, launcherUserId) getLauncherShortcutsLocked(callingPackage, userId, launcherUserId) Loading Loading @@ -2350,8 +2354,9 @@ public class ShortcutService extends IShortcutService.Stub { Preconditions.checkNotNull(packageName, "packageName"); Preconditions.checkNotNull(packageName, "packageName"); Preconditions.checkNotNull(shortcutId, "shortcutId"); Preconditions.checkNotNull(shortcutId, "shortcutId"); throwIfUserLocked(userId); if (!isUserUnlocked(userId) || !isUserUnlocked(launcherUserId)) { throwIfUserLocked(launcherUserId); return 0; } synchronized (mLock) { synchronized (mLock) { getLauncherShortcutsLocked(callingPackage, userId, launcherUserId) getLauncherShortcutsLocked(callingPackage, userId, launcherUserId) Loading @@ -2377,8 +2382,9 @@ public class ShortcutService extends IShortcutService.Stub { Preconditions.checkNotNull(packageName, "packageName"); Preconditions.checkNotNull(packageName, "packageName"); Preconditions.checkNotNull(shortcutId, "shortcutId"); Preconditions.checkNotNull(shortcutId, "shortcutId"); throwIfUserLocked(userId); if (!isUserUnlocked(userId) || !isUserUnlocked(launcherUserId)) { throwIfUserLocked(launcherUserId); return null; } synchronized (mLock) { synchronized (mLock) { getLauncherShortcutsLocked(callingPackage, userId, launcherUserId) getLauncherShortcutsLocked(callingPackage, userId, launcherUserId) Loading Loading @@ -2412,7 +2418,9 @@ public class ShortcutService extends IShortcutService.Stub { @Override @Override public boolean hasShortcutHostPermission(int launcherUserId, public boolean hasShortcutHostPermission(int launcherUserId, @NonNull String callingPackage) { @NonNull String callingPackage) { throwIfUserLocked(launcherUserId); if (!isUserUnlocked(launcherUserId)) { return false; } return ShortcutService.this.hasShortcutHostPermission(callingPackage, launcherUserId); return ShortcutService.this.hasShortcutHostPermission(callingPackage, launcherUserId); } } } } Loading