From 9d36cc2280289c570945cc6aa1df84f919df8a2d Mon Sep 17 00:00:00 2001 From: Mehdi Alizadeh Date: Sun, 13 Dec 2020 19:54:30 -0800 Subject: [PATCH] Don't reset default launcher if the user is not loaded If the user is not loaded in ShortcutService, there is no need to reset the current default launcher. This is to prevent any unnecessary file IO when the default launcher changes. Bug: 173614832 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 com.android.server.pm.ShortcutManagerTest11 atest CtsShortcutHostTestCases atest CtsShortcutManagerTestCases Change-Id: Ic3bbb0f7b4d308bddbff1d586a8700388f317f6b --- services/core/java/com/android/server/pm/ShortcutService.java | 4 +++- 1 file changed, 3 insertions(+), 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 c68fe81d0565b..56fb5e8fd449c 100644 --- a/services/core/java/com/android/server/pm/ShortcutService.java +++ b/services/core/java/com/android/server/pm/ShortcutService.java @@ -537,7 +537,9 @@ public class ShortcutService extends IShortcutService.Stub { synchronized (mLock) { // Clear the launcher cache for this user. It will be set again next time the default // launcher is read from RoleManager. - getUserShortcutsLocked(userId).setCachedLauncher(null); + if (isUserLoadedLocked(userId)) { + getUserShortcutsLocked(userId).setCachedLauncher(null); + } } }