From 15c855f91d9907befa547f8b2153fb44a3c98329 Mon Sep 17 00:00:00 2001 From: Mehdi Alizadeh Date: Wed, 5 Feb 2020 10:59:15 -0800 Subject: [PATCH] Fixes NPE when calling getPackage on a null shortcut 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 Test: Launcher tests pass Bug: 148869137 Change-Id: Idf27108e6b40106f4604bb5fa9d8061b5b8ce8be --- services/core/java/com/android/server/pm/ShortcutService.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/services/core/java/com/android/server/pm/ShortcutService.java b/services/core/java/com/android/server/pm/ShortcutService.java index f7889ea6141c1..ead4dfb794dbc 100644 --- a/services/core/java/com/android/server/pm/ShortcutService.java +++ b/services/core/java/com/android/server/pm/ShortcutService.java @@ -1985,7 +1985,6 @@ public class ShortcutService extends IShortcutService.Stub { // 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) { @@ -1999,6 +1998,7 @@ public class ShortcutService extends IShortcutService.Stub { // someone already), then we just replace the existing one with this new one, // and then proceed the rest of the process. if (shortcut != null) { + final String shortcutPackage = shortcut.getPackage(); final ShortcutPackage ps = getPackageShortcutsForPublisherLocked( shortcutPackage, userId); final String id = shortcut.getId();