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
This commit is contained in:
Mehdi Alizadeh
2020-12-13 19:54:30 -08:00
parent 786d279f6c
commit 9d36cc2280

View File

@@ -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);
}
}
}