summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorandroid-build-team Robot <android-build-team-robot@google.com>2019-09-12 03:18:41 +0000
committerandroid-build-team Robot <android-build-team-robot@google.com>2019-09-12 03:18:41 +0000
commitf40e9bf7fb51fa7f44263b28554357cb6905b568 (patch)
treefd363aec6d806243669e24edb6b5c2c8e3c82903
parent4bf06aa7b2b2ab09f163ea1f96f2cfd6ddde7bdf (diff)
parent81903dfbc7813dd20303427733f43f80ecd0ce58 (diff)
downloadservices-android10-qpr1-d-release.tar.gz
Change-Id: Idda1c5bcfaa77755878623eb95a02a92dc6f83b8
-rw-r--r--src/com/android/internal/car/CarServiceHelperService.java54
1 files changed, 30 insertions, 24 deletions
diff --git a/src/com/android/internal/car/CarServiceHelperService.java b/src/com/android/internal/car/CarServiceHelperService.java
index f8842d4..160d248 100644
--- a/src/com/android/internal/car/CarServiceHelperService.java
+++ b/src/com/android/internal/car/CarServiceHelperService.java
@@ -16,6 +16,7 @@
package com.android.internal.car;
+import android.annotation.NonNull;
import android.app.ActivityManager;
import android.app.IActivityManager;
import android.app.admin.DevicePolicyManager;
@@ -275,45 +276,50 @@ public class CarServiceHelperService extends SystemService {
Slog.wtf(TAG, "cannot get ActivityManagerService");
return;
}
- TimingsTraceLog traceLog = new TimingsTraceLog("SystemServerTiming",
- Trace.TRACE_TAG_SYSTEM_SERVER);
- traceLog.traceBegin("User0Unlock");
+ TimingsTraceLog t = new TimingsTraceLog(TAG, Trace.TRACE_TAG_SYSTEM_SERVER);
+ unlockSystemUser(t, am);
+
+ t.traceBegin("ForegroundUserStart" + targetUserId);
try {
- // This is for force changing state into RUNNING_LOCKED. Otherwise unlock does not
- // update the state and user 0 unlock happens twice.
- if (!am.startUserInBackground(UserHandle.USER_SYSTEM)) {
- // cannot start user
- Slog.w(TAG, "cannot start system user");
- } else if (!am.unlockUser(UserHandle.USER_SYSTEM, null, null, null)) {
- // unlocking system user failed. But still continue for other setup.
- Slog.w(TAG, "cannot unlock system user");
+ if (!am.startUserInForegroundWithListener(targetUserId, null)) {
+ Slog.e(TAG, "cannot start foreground user:" + targetUserId);
} else {
- // user 0 started and unlocked
- handleUserLockStatusChange(UserHandle.USER_SYSTEM, true);
+ mCarUserManagerHelper.setLastActiveUser(targetUserId);
}
} catch (RemoteException e) {
// should not happen for local call.
Slog.wtf("RemoteException from AMS", e);
}
- traceLog.traceEnd();
- // Do not unlock here to allow other stuffs done. Unlock will happen
- // when system completes the boot.
- // TODO(b/124460424) Unlock earlier?
- traceLog.traceBegin("ForegroundUserStart");
+ t.traceEnd();
+ }
+
+ private void unlockSystemUser(@NonNull TimingsTraceLog t, @NonNull IActivityManager am) {
+ t.traceBegin("UnlockSystemUser");
try {
- if (!am.startUserInForegroundWithListener(targetUserId, null)) {
- Slog.e(TAG, "cannot start foreground user:" + targetUserId);
- } else {
- mCarUserManagerHelper.setLastActiveUser(targetUserId);
+ // This is for force changing state into RUNNING_LOCKED. Otherwise unlock does not
+ // update the state and user 0 unlock happens twice.
+ boolean started = am.startUserInBackground(UserHandle.USER_SYSTEM);
+ if (!started) {
+ Slog.w(TAG, "could not restart system user in foreground; trying unlock instead");
+ t.traceBegin("forceUnlockSystemUser");
+ boolean unlocked = am.unlockUser(UserHandle.USER_SYSTEM,
+ /* token= */ null, /* secret= */ null, /* listner= */ null);
+ t.traceEnd();
+ if (!unlocked) {
+ Slog.w(TAG, "could not unlock system user neither");
+ return;
+ }
}
+ // System user started and unlocked
+ handleUserLockStatusChange(UserHandle.USER_SYSTEM, true);
} catch (RemoteException e) {
// should not happen for local call.
Slog.wtf("RemoteException from AMS", e);
+ } finally {
+ t.traceEnd();
}
- traceLog.traceEnd();
}
-
private void notifyAllUnlockedUsers() {
// only care about unlocked users
LinkedList<Integer> users = new LinkedList<>();