OSDN Git Service

Finish unlocking user before touching apps.
authorJeff Sharkey <jsharkey@android.com>
Mon, 19 Feb 2018 23:30:17 +0000 (16:30 -0700)
committerJeff Sharkey <jsharkey@android.com>
Mon, 19 Feb 2018 23:30:20 +0000 (16:30 -0700)
Direct Boot unaware apps can end up calling back into the system,
racing with us pushing the user into the UNLOCKED state.  So make
sure we get the user actually UNLOCKED before telling apps that
we're unlocked.

Test: builds, boots
Bug: 73606555
Change-Id: I1501283f80a84d850364a5fc0e119893726618fa

services/core/java/com/android/server/am/UserController.java

index bfc787e..6134d05 100644 (file)
@@ -435,6 +435,14 @@ class UserController implements Handler.Callback {
         }
         mInjector.getUserManagerInternal().setUserState(userId, uss.state);
         uss.mUnlockProgress.finish();
+
+        // Get unaware persistent apps running and start any unaware providers
+        // in already-running apps that are partially aware
+        if (userId == UserHandle.USER_SYSTEM) {
+            mInjector.startPersistentApps(PackageManager.MATCH_DIRECT_BOOT_UNAWARE);
+        }
+        mInjector.installEncryptionUnawareProviders(userId);
+
         // Dispatch unlocked to external apps
         final Intent unlockedIntent = new Intent(Intent.ACTION_USER_UNLOCKED);
         unlockedIntent.putExtra(Intent.EXTRA_USER_HANDLE, userId);
@@ -1951,10 +1959,6 @@ class UserController implements Handler.Callback {
                 FgThread.getHandler().post(() -> {
                     mInjector.loadUserRecents(userId);
                 });
-                if (userId == UserHandle.USER_SYSTEM) {
-                    mInjector.startPersistentApps(PackageManager.MATCH_DIRECT_BOOT_UNAWARE);
-                }
-                mInjector.installEncryptionUnawareProviders(userId);
                 finishUserUnlocked((UserState) msg.obj);
                 break;
             case SYSTEM_USER_CURRENT_MSG: