Loading services/core/java/com/android/server/pm/ShortcutService.java +235 −199 Original line number Diff line number Diff line Loading @@ -1889,6 +1889,7 @@ public class ShortcutService extends IShortcutService.Stub { @Override public void setDynamicShortcuts(String packageName, ParceledListSlice shortcutInfoList, @UserIdInt int userId, @NonNull AndroidFuture callback) { try { verifyCaller(packageName, userId); final List<ShortcutInfo> newShortcuts = (List<ShortcutInfo>) shortcutInfoList.getList(); Loading @@ -1904,7 +1905,8 @@ public class ShortcutService extends IShortcutService.Stub { synchronized (mLock) { throwIfUserLockedL(userId); final ShortcutPackage ps = getPackageShortcutsForPublisherLocked(packageName, userId); final ShortcutPackage ps = getPackageShortcutsForPublisherLocked(packageName, userId); ps.ensureImmutableShortcutsNotIncluded(newShortcuts, /*ignoreInvisible=*/ true); ps.ensureNoBitmapIconIfShortcutIsLongLived(newShortcuts); Loading @@ -1916,6 +1918,7 @@ public class ShortcutService extends IShortcutService.Stub { // Throttling. if (!ps.tryApiCall(unlimited)) { callback.complete(false); return; } // Initialize the implicit ranks for ShortcutPackage.adjustRanks(). Loading Loading @@ -1952,11 +1955,15 @@ public class ShortcutService extends IShortcutService.Stub { verifyStates(); callback.complete(true); } catch (Exception e) { callback.completeExceptionally(e); } } @Override public void updateShortcuts(String packageName, ParceledListSlice shortcutInfoList, @UserIdInt int userId, AndroidFuture callback) { try { verifyCaller(packageName, userId); final List<ShortcutInfo> newShortcuts = (List<ShortcutInfo>) shortcutInfoList.getList(); Loading @@ -1971,7 +1978,8 @@ public class ShortcutService extends IShortcutService.Stub { synchronized (mLock) { throwIfUserLockedL(userId); final ShortcutPackage ps = getPackageShortcutsForPublisherLocked(packageName, userId); final ShortcutPackage ps = getPackageShortcutsForPublisherLocked(packageName, userId); ps.ensureImmutableShortcutsNotIncluded(newShortcuts, /*ignoreInvisible=*/ true); ps.ensureNoBitmapIconIfShortcutIsLongLived(newShortcuts); Loading Loading @@ -2002,13 +2010,14 @@ public class ShortcutService extends IShortcutService.Stub { } if (target.isEnabled() != source.isEnabled()) { Slog.w(TAG, "ShortcutInfo.enabled cannot be changed with updateShortcuts()"); Slog.w(TAG, "ShortcutInfo.enabled cannot be changed with" + " updateShortcuts()"); } if (target.isLongLived() != source.isLongLived()) { Slog.w(TAG, "ShortcutInfo.longLived cannot be changed with updateShortcuts()"); "ShortcutInfo.longLived cannot be changed with" + " updateShortcuts()"); } // When updating the rank, we need to insert between existing ranks, so set Loading @@ -2031,8 +2040,8 @@ public class ShortcutService extends IShortcutService.Stub { saveIconAndFixUpShortcutLocked(target); } // When we're updating any resource related fields, re-extract the res names and // the values. // When we're updating any resource related fields, re-extract the res // names and the values. if (replacingIcon || source.hasStringResources()) { fixUpShortcutResourceNamesAndValues(target); } Loading @@ -2050,11 +2059,15 @@ public class ShortcutService extends IShortcutService.Stub { verifyStates(); callback.complete(true); } catch (Exception e) { callback.completeExceptionally(e); } } @Override public void addDynamicShortcuts(String packageName, ParceledListSlice shortcutInfoList, @UserIdInt int userId, AndroidFuture callback) { try { verifyCaller(packageName, userId); final List<ShortcutInfo> newShortcuts = (List<ShortcutInfo>) shortcutInfoList.getList(); Loading @@ -2069,7 +2082,8 @@ public class ShortcutService extends IShortcutService.Stub { synchronized (mLock) { throwIfUserLockedL(userId); final ShortcutPackage ps = getPackageShortcutsForPublisherLocked(packageName, userId); final ShortcutPackage ps = getPackageShortcutsForPublisherLocked(packageName, userId); ps.ensureImmutableShortcutsNotIncluded(newShortcuts, /*ignoreInvisible=*/ true); ps.ensureNoBitmapIconIfShortcutIsLongLived(newShortcuts); Loading Loading @@ -2114,6 +2128,9 @@ public class ShortcutService extends IShortcutService.Stub { verifyStates(); callback.complete(true); } catch (Exception e) { callback.completeExceptionally(e); } } @Override Loading Loading @@ -2180,16 +2197,22 @@ public class ShortcutService extends IShortcutService.Stub { @Override public void requestPinShortcut(String packageName, ShortcutInfo shortcut, IntentSender resultIntent, int userId, AndroidFuture callback) { try { Objects.requireNonNull(shortcut); Objects.requireNonNull(callback); Preconditions.checkArgument(shortcut.isEnabled(), "Shortcut must be enabled"); callback.complete(requestPinItem(packageName, userId, shortcut, null, null, resultIntent)); callback.complete( requestPinItem(packageName, userId, shortcut, null, null, resultIntent)); } catch (Exception e) { callback.completeExceptionally(e); } } @Override public void createShortcutResultIntent(String packageName, ShortcutInfo shortcut, int userId, AndroidFuture callback) throws RemoteException { try { Objects.requireNonNull(shortcut); Preconditions.checkArgument(shortcut.isEnabled(), "Shortcut must be enabled"); verifyCaller(packageName, userId); Loading @@ -2205,6 +2228,9 @@ public class ShortcutService extends IShortcutService.Stub { verifyStates(); callback.complete(ret); } catch (Exception e) { callback.completeExceptionally(e); } } /** Loading Loading @@ -2464,6 +2490,7 @@ public class ShortcutService extends IShortcutService.Stub { public void getShortcuts(String packageName, @ShortcutManager.ShortcutMatchFlags int matchFlags, @UserIdInt int userId, AndroidFuture<ParceledListSlice<ShortcutInfo>> callback) { try { verifyCaller(packageName, userId); synchronized (mLock) { Loading @@ -2471,7 +2498,8 @@ public class ShortcutService extends IShortcutService.Stub { final boolean matchDynamic = (matchFlags & ShortcutManager.FLAG_MATCH_DYNAMIC) != 0; final boolean matchPinned = (matchFlags & ShortcutManager.FLAG_MATCH_PINNED) != 0; final boolean matchManifest = (matchFlags & ShortcutManager.FLAG_MATCH_MANIFEST) != 0; final boolean matchManifest = (matchFlags & ShortcutManager.FLAG_MATCH_MANIFEST) != 0; final boolean matchCached = (matchFlags & ShortcutManager.FLAG_MATCH_CACHED) != 0; final int shortcutFlags = (matchDynamic ? ShortcutInfo.FLAG_DYNAMIC : 0) Loading @@ -2484,11 +2512,15 @@ public class ShortcutService extends IShortcutService.Stub { (ShortcutInfo si) -> si.isVisibleToPublisher() && (si.getFlags() & shortcutFlags) != 0)); } } catch (Exception e) { callback.completeExceptionally(e); } } @Override public void getShareTargets(String packageName, IntentFilter filter, @UserIdInt int userId, AndroidFuture<ParceledListSlice> callback) { try { Preconditions.checkStringNotEmpty(packageName, "packageName"); Objects.requireNonNull(filter, "intentFilter"); Loading @@ -2502,10 +2534,14 @@ public class ShortcutService extends IShortcutService.Stub { final List<ShortcutManager.ShareShortcutInfo> shortcutInfoList = new ArrayList<>(); final ShortcutUser user = getUserShortcutsLocked(userId); user.forAllPackages(p -> shortcutInfoList.addAll(p.getMatchingShareTargets(filter))); user.forAllPackages( p -> shortcutInfoList.addAll(p.getMatchingShareTargets(filter))); callback.complete(new ParceledListSlice<>(shortcutInfoList)); } } catch (Exception e) { callback.completeExceptionally(e); } } @Override Loading Loading
services/core/java/com/android/server/pm/ShortcutService.java +235 −199 Original line number Diff line number Diff line Loading @@ -1889,6 +1889,7 @@ public class ShortcutService extends IShortcutService.Stub { @Override public void setDynamicShortcuts(String packageName, ParceledListSlice shortcutInfoList, @UserIdInt int userId, @NonNull AndroidFuture callback) { try { verifyCaller(packageName, userId); final List<ShortcutInfo> newShortcuts = (List<ShortcutInfo>) shortcutInfoList.getList(); Loading @@ -1904,7 +1905,8 @@ public class ShortcutService extends IShortcutService.Stub { synchronized (mLock) { throwIfUserLockedL(userId); final ShortcutPackage ps = getPackageShortcutsForPublisherLocked(packageName, userId); final ShortcutPackage ps = getPackageShortcutsForPublisherLocked(packageName, userId); ps.ensureImmutableShortcutsNotIncluded(newShortcuts, /*ignoreInvisible=*/ true); ps.ensureNoBitmapIconIfShortcutIsLongLived(newShortcuts); Loading @@ -1916,6 +1918,7 @@ public class ShortcutService extends IShortcutService.Stub { // Throttling. if (!ps.tryApiCall(unlimited)) { callback.complete(false); return; } // Initialize the implicit ranks for ShortcutPackage.adjustRanks(). Loading Loading @@ -1952,11 +1955,15 @@ public class ShortcutService extends IShortcutService.Stub { verifyStates(); callback.complete(true); } catch (Exception e) { callback.completeExceptionally(e); } } @Override public void updateShortcuts(String packageName, ParceledListSlice shortcutInfoList, @UserIdInt int userId, AndroidFuture callback) { try { verifyCaller(packageName, userId); final List<ShortcutInfo> newShortcuts = (List<ShortcutInfo>) shortcutInfoList.getList(); Loading @@ -1971,7 +1978,8 @@ public class ShortcutService extends IShortcutService.Stub { synchronized (mLock) { throwIfUserLockedL(userId); final ShortcutPackage ps = getPackageShortcutsForPublisherLocked(packageName, userId); final ShortcutPackage ps = getPackageShortcutsForPublisherLocked(packageName, userId); ps.ensureImmutableShortcutsNotIncluded(newShortcuts, /*ignoreInvisible=*/ true); ps.ensureNoBitmapIconIfShortcutIsLongLived(newShortcuts); Loading Loading @@ -2002,13 +2010,14 @@ public class ShortcutService extends IShortcutService.Stub { } if (target.isEnabled() != source.isEnabled()) { Slog.w(TAG, "ShortcutInfo.enabled cannot be changed with updateShortcuts()"); Slog.w(TAG, "ShortcutInfo.enabled cannot be changed with" + " updateShortcuts()"); } if (target.isLongLived() != source.isLongLived()) { Slog.w(TAG, "ShortcutInfo.longLived cannot be changed with updateShortcuts()"); "ShortcutInfo.longLived cannot be changed with" + " updateShortcuts()"); } // When updating the rank, we need to insert between existing ranks, so set Loading @@ -2031,8 +2040,8 @@ public class ShortcutService extends IShortcutService.Stub { saveIconAndFixUpShortcutLocked(target); } // When we're updating any resource related fields, re-extract the res names and // the values. // When we're updating any resource related fields, re-extract the res // names and the values. if (replacingIcon || source.hasStringResources()) { fixUpShortcutResourceNamesAndValues(target); } Loading @@ -2050,11 +2059,15 @@ public class ShortcutService extends IShortcutService.Stub { verifyStates(); callback.complete(true); } catch (Exception e) { callback.completeExceptionally(e); } } @Override public void addDynamicShortcuts(String packageName, ParceledListSlice shortcutInfoList, @UserIdInt int userId, AndroidFuture callback) { try { verifyCaller(packageName, userId); final List<ShortcutInfo> newShortcuts = (List<ShortcutInfo>) shortcutInfoList.getList(); Loading @@ -2069,7 +2082,8 @@ public class ShortcutService extends IShortcutService.Stub { synchronized (mLock) { throwIfUserLockedL(userId); final ShortcutPackage ps = getPackageShortcutsForPublisherLocked(packageName, userId); final ShortcutPackage ps = getPackageShortcutsForPublisherLocked(packageName, userId); ps.ensureImmutableShortcutsNotIncluded(newShortcuts, /*ignoreInvisible=*/ true); ps.ensureNoBitmapIconIfShortcutIsLongLived(newShortcuts); Loading Loading @@ -2114,6 +2128,9 @@ public class ShortcutService extends IShortcutService.Stub { verifyStates(); callback.complete(true); } catch (Exception e) { callback.completeExceptionally(e); } } @Override Loading Loading @@ -2180,16 +2197,22 @@ public class ShortcutService extends IShortcutService.Stub { @Override public void requestPinShortcut(String packageName, ShortcutInfo shortcut, IntentSender resultIntent, int userId, AndroidFuture callback) { try { Objects.requireNonNull(shortcut); Objects.requireNonNull(callback); Preconditions.checkArgument(shortcut.isEnabled(), "Shortcut must be enabled"); callback.complete(requestPinItem(packageName, userId, shortcut, null, null, resultIntent)); callback.complete( requestPinItem(packageName, userId, shortcut, null, null, resultIntent)); } catch (Exception e) { callback.completeExceptionally(e); } } @Override public void createShortcutResultIntent(String packageName, ShortcutInfo shortcut, int userId, AndroidFuture callback) throws RemoteException { try { Objects.requireNonNull(shortcut); Preconditions.checkArgument(shortcut.isEnabled(), "Shortcut must be enabled"); verifyCaller(packageName, userId); Loading @@ -2205,6 +2228,9 @@ public class ShortcutService extends IShortcutService.Stub { verifyStates(); callback.complete(ret); } catch (Exception e) { callback.completeExceptionally(e); } } /** Loading Loading @@ -2464,6 +2490,7 @@ public class ShortcutService extends IShortcutService.Stub { public void getShortcuts(String packageName, @ShortcutManager.ShortcutMatchFlags int matchFlags, @UserIdInt int userId, AndroidFuture<ParceledListSlice<ShortcutInfo>> callback) { try { verifyCaller(packageName, userId); synchronized (mLock) { Loading @@ -2471,7 +2498,8 @@ public class ShortcutService extends IShortcutService.Stub { final boolean matchDynamic = (matchFlags & ShortcutManager.FLAG_MATCH_DYNAMIC) != 0; final boolean matchPinned = (matchFlags & ShortcutManager.FLAG_MATCH_PINNED) != 0; final boolean matchManifest = (matchFlags & ShortcutManager.FLAG_MATCH_MANIFEST) != 0; final boolean matchManifest = (matchFlags & ShortcutManager.FLAG_MATCH_MANIFEST) != 0; final boolean matchCached = (matchFlags & ShortcutManager.FLAG_MATCH_CACHED) != 0; final int shortcutFlags = (matchDynamic ? ShortcutInfo.FLAG_DYNAMIC : 0) Loading @@ -2484,11 +2512,15 @@ public class ShortcutService extends IShortcutService.Stub { (ShortcutInfo si) -> si.isVisibleToPublisher() && (si.getFlags() & shortcutFlags) != 0)); } } catch (Exception e) { callback.completeExceptionally(e); } } @Override public void getShareTargets(String packageName, IntentFilter filter, @UserIdInt int userId, AndroidFuture<ParceledListSlice> callback) { try { Preconditions.checkStringNotEmpty(packageName, "packageName"); Objects.requireNonNull(filter, "intentFilter"); Loading @@ -2502,10 +2534,14 @@ public class ShortcutService extends IShortcutService.Stub { final List<ShortcutManager.ShareShortcutInfo> shortcutInfoList = new ArrayList<>(); final ShortcutUser user = getUserShortcutsLocked(userId); user.forAllPackages(p -> shortcutInfoList.addAll(p.getMatchingShareTargets(filter))); user.forAllPackages( p -> shortcutInfoList.addAll(p.getMatchingShareTargets(filter))); callback.complete(new ParceledListSlice<>(shortcutInfoList)); } } catch (Exception e) { callback.completeExceptionally(e); } } @Override Loading