From 155e5d6de7059198b21f3f220fbff7bf0baf306c Mon Sep 17 00:00:00 2001 From: Jeff Sharkey Date: Mon, 11 Apr 2016 12:13:06 -0600 Subject: [PATCH] Send USER_UNLOCKED broadcasts before PRE_BOOT. Apps handling the PRE_BOOT_COMPLETED broadcast expect the user to be fully unlocked and working. Most system internals are using the SystemServer interface, and we dispatch the unlocked event through them before starting the PRE_BOOT process. However, there are still some system internals that haven't been converted to SystemServer, so we need to also send USER_UNLOCKED for them to pick up before starting PRE_BOOT work. Bug: 28086245 Change-Id: Ie847b463ea55a6dddcc49d243ef8fb308e5179a7 --- .../com/android/server/am/UserController.java | 50 +++++++++---------- 1 file changed, 25 insertions(+), 25 deletions(-) diff --git a/services/core/java/com/android/server/am/UserController.java b/services/core/java/com/android/server/am/UserController.java index 514c6c54bdcc5..5ebb9a7553ad6 100644 --- a/services/core/java/com/android/server/am/UserController.java +++ b/services/core/java/com/android/server/am/UserController.java @@ -278,6 +278,31 @@ final class UserController { // Dispatch unlocked to system services mHandler.sendMessage(mHandler.obtainMessage(SYSTEM_USER_UNLOCK_MSG, userId, 0)); + // Dispatch unlocked to external apps + final Intent unlockedIntent = new Intent(Intent.ACTION_USER_UNLOCKED); + unlockedIntent.putExtra(Intent.EXTRA_USER_HANDLE, userId); + unlockedIntent.addFlags( + Intent.FLAG_RECEIVER_REGISTERED_ONLY | Intent.FLAG_RECEIVER_FOREGROUND); + mService.broadcastIntentLocked(null, null, unlockedIntent, null, null, 0, null, + null, null, AppOpsManager.OP_NONE, null, false, false, MY_PID, SYSTEM_UID, + userId); + + if (getUserInfo(userId).isManagedProfile()) { + UserInfo parent = getUserManager().getProfileParent(userId); + if (parent != null) { + final Intent profileUnlockedIntent = new Intent( + Intent.ACTION_MANAGED_PROFILE_UNLOCKED); + profileUnlockedIntent.putExtra(Intent.EXTRA_USER, UserHandle.of(userId)); + profileUnlockedIntent.addFlags( + Intent.FLAG_RECEIVER_REGISTERED_ONLY + | Intent.FLAG_RECEIVER_FOREGROUND); + mService.broadcastIntentLocked(null, null, profileUnlockedIntent, + null, null, 0, null, null, null, AppOpsManager.OP_NONE, + null, false, false, MY_PID, SYSTEM_UID, + parent.id); + } + } + // Send PRE_BOOT broadcasts if fingerprint changed final UserInfo info = getUserInfo(userId); if (!Objects.equals(info.lastLoggedInFingerprint, Build.FINGERPRINT)) { @@ -320,31 +345,6 @@ final class UserController { // Remember that we logged in mUserManager.onUserLoggedIn(userId); - // Dispatch unlocked to external apps - final Intent unlockedIntent = new Intent(Intent.ACTION_USER_UNLOCKED); - unlockedIntent.putExtra(Intent.EXTRA_USER_HANDLE, userId); - unlockedIntent.addFlags( - Intent.FLAG_RECEIVER_REGISTERED_ONLY | Intent.FLAG_RECEIVER_FOREGROUND); - mService.broadcastIntentLocked(null, null, unlockedIntent, null, null, 0, null, - null, null, AppOpsManager.OP_NONE, null, false, false, MY_PID, SYSTEM_UID, - userId); - - if (getUserInfo(userId).isManagedProfile()) { - UserInfo parent = getUserManager().getProfileParent(userId); - if (parent != null) { - final Intent profileUnlockedIntent = new Intent( - Intent.ACTION_MANAGED_PROFILE_UNLOCKED); - profileUnlockedIntent.putExtra(Intent.EXTRA_USER, UserHandle.of(userId)); - profileUnlockedIntent.addFlags( - Intent.FLAG_RECEIVER_REGISTERED_ONLY - | Intent.FLAG_RECEIVER_FOREGROUND); - mService.broadcastIntentLocked(null, null, profileUnlockedIntent, - null, null, 0, null, null, null, AppOpsManager.OP_NONE, - null, false, false, MY_PID, SYSTEM_UID, - parent.id); - } - } - final Intent bootIntent = new Intent(Intent.ACTION_BOOT_COMPLETED, null); bootIntent.putExtra(Intent.EXTRA_USER_HANDLE, userId); bootIntent.addFlags(Intent.FLAG_RECEIVER_NO_ABORT