summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorbkchoi <bkchoi@google.com>2023-01-12 15:52:45 -0800
committerAndroid Build Coastguard Worker <android-build-coastguard-worker@google.com>2023-01-24 01:30:27 +0000
commit746d2338b3776118a162ed9b445d23154a572789 (patch)
tree0f70c3f39b373121b06dd63001df113249d60ec5
parent34696dcb976697688c8238fcc7260be3d47d72c2 (diff)
downloadbase-746d2338b3776118a162ed9b445d23154a572789.tar.gz
Send system user broadcasts in headless system user mode.
In headless system user mode, USER_STARTING, USER_STARTED, and USER_SWITCHED broadcasts were not sent for the system user. It had caused issues for other parts of the system which are expecting such broadcast messages. For example, VpnManagerService expects USER_STARTED event for system user but was not receiving it. This change will only affect headless system user mode. No behavior changes for phones. Bug: 263439429 Bug: 242195409 Test: atest com.android.cts.devicepolicy.MixedDeviceOwnerTest Change-Id: I4a101418c10a2c959c2bfae01b95863aebd521e8 (cherry picked from commit ba0f9f3ad2de99e8f96075db4571e6bf25d6c310) Merged-In: I4a101418c10a2c959c2bfae01b95863aebd521e8
-rw-r--r--services/core/java/com/android/server/am/ActivityManagerService.java14
1 files changed, 8 insertions, 6 deletions
diff --git a/services/core/java/com/android/server/am/ActivityManagerService.java b/services/core/java/com/android/server/am/ActivityManagerService.java
index 19b5cc93932b..5d4dc39341a1 100644
--- a/services/core/java/com/android/server/am/ActivityManagerService.java
+++ b/services/core/java/com/android/server/am/ActivityManagerService.java
@@ -8196,15 +8196,13 @@ public class ActivityManagerService extends IActivityManager.Stub
t.traceEnd();
}
+ boolean isBootingSystemUser = currentUserId == UserHandle.USER_SYSTEM;
+
// Some systems - like automotive - will explicitly unlock system user then switch
- // to a secondary user. Hence, we don't want to send duplicate broadcasts for
- // the system user here.
+ // to a secondary user.
// TODO(b/242195409): this workaround shouldn't be necessary once we move
// the headless-user start logic to UserManager-land.
- final boolean isBootingSystemUser = (currentUserId == UserHandle.USER_SYSTEM)
- && !UserManager.isHeadlessSystemUserMode();
-
- if (isBootingSystemUser) {
+ if (isBootingSystemUser && !UserManager.isHeadlessSystemUserMode()) {
t.traceBegin("startHomeOnAllDisplays");
mAtmInternal.startHomeOnAllDisplays(currentUserId, "systemReady");
t.traceEnd();
@@ -8216,6 +8214,10 @@ public class ActivityManagerService extends IActivityManager.Stub
if (isBootingSystemUser) {
+ // Need to send the broadcasts for the system user here because
+ // UserController#startUserInternal will not send them for the system user starting,
+ // It checks if the user state already exists, which is always the case for the
+ // system user.
t.traceBegin("sendUserStartBroadcast");
final int callingUid = Binder.getCallingUid();
final int callingPid = Binder.getCallingPid();