diff options
| author | 2020-01-31 19:26:29 -0800 | |
|---|---|---|
| committer | 2020-02-03 16:18:11 -0800 | |
| commit | 9854923028d67f97bf56a364d40f19148c90a8fe (patch) | |
| tree | c7b81c8ce1838961c04256ca7ccf825cd567b5e9 | |
| parent | 2a198f3bf510289a4be130e5fffb157c33dcf974 (diff) | |
Allow owners of ACCESS_SHORTCUTS pin shortcuts on behalf of other apps
Test: atest com.android.server.pm.ShortcutManagerTest1 \
com.android.server.pm.ShortcutManagerTest2 \
com.android.server.pm.ShortcutManagerTest3 \
com.android.server.pm.ShortcutManagerTest4 \
com.android.server.pm.ShortcutManagerTest5 \
com.android.server.pm.ShortcutManagerTest6 \
com.android.server.pm.ShortcutManagerTest7 \
com.android.server.pm.ShortcutManagerTest8 \
com.android.server.pm.ShortcutManagerTest9 \
com.android.server.pm.ShortcutManagerTest10
Bug: 148560664
Change-Id: I77f13d590dada20169ccf53a6fc4684ac25c77ea
| -rw-r--r-- | services/core/java/com/android/server/pm/ShortcutService.java | 15 |
1 files changed, 10 insertions, 5 deletions
diff --git a/services/core/java/com/android/server/pm/ShortcutService.java b/services/core/java/com/android/server/pm/ShortcutService.java index f368666a06ba..f7889ea6141c 100644 --- a/services/core/java/com/android/server/pm/ShortcutService.java +++ b/services/core/java/com/android/server/pm/ShortcutService.java @@ -1977,10 +1977,15 @@ public class ShortcutService extends IShortcutService.Stub { * After validating the caller, it passes the request to {@link #mShortcutRequestPinProcessor}. * Either {@param shortcut} or {@param appWidget} should be non-null. */ - private boolean requestPinItem(String packageName, int userId, ShortcutInfo shortcut, + private boolean requestPinItem(String callingPackage, int userId, ShortcutInfo shortcut, AppWidgetProviderInfo appWidget, Bundle extras, IntentSender resultIntent) { - verifyCaller(packageName, userId); - verifyShortcutInfoPackage(packageName, shortcut); + verifyCaller(callingPackage, userId); + if (shortcut == null || !injectHasAccessShortcutsPermission( + injectBinderCallingPid(), injectBinderCallingUid())) { + // Verify if caller is the shortcut owner, only if caller doesn't have ACCESS_SHORTCUTS. + verifyShortcutInfoPackage(callingPackage, shortcut); + } + final String shortcutPackage = shortcut.getPackage(); final boolean ret; synchronized (mLock) { @@ -1995,13 +2000,13 @@ public class ShortcutService extends IShortcutService.Stub { // and then proceed the rest of the process. if (shortcut != null) { final ShortcutPackage ps = getPackageShortcutsForPublisherLocked( - packageName, userId); + shortcutPackage, userId); final String id = shortcut.getId(); if (ps.isShortcutExistsAndInvisibleToPublisher(id)) { ps.updateInvisibleShortcutForPinRequestWith(shortcut); - packageShortcutsChanged(packageName, userId); + packageShortcutsChanged(shortcutPackage, userId); } } |