diff options
author | Ying Zheng <yizheng@google.com> | 2018-06-25 20:09:05 +0000 |
---|---|---|
committer | Android (Google) Code Review <android-gerrit@google.com> | 2018-06-25 20:09:05 +0000 |
commit | d50321314e309f0062850733a6e7b5f582af5f8c (patch) | |
tree | 97446164589c82ce954b16aa76e9761427839333 /service/src/com/android | |
parent | d2335e6a0cf7c47a3dd276ce8f95ab9ae64b494e (diff) | |
parent | cf20f44f515ca802baad7d73f86cbd829e1a2183 (diff) | |
download | Car-d50321314e309f0062850733a6e7b5f582af5f8c.tar.gz |
Merge "Update last active user." into pi-dev
Diffstat (limited to 'service/src/com/android')
-rw-r--r-- | service/src/com/android/car/user/CarUserService.java | 15 |
1 files changed, 8 insertions, 7 deletions
diff --git a/service/src/com/android/car/user/CarUserService.java b/service/src/com/android/car/user/CarUserService.java index bc5f2025f7..cc30588284 100644 --- a/service/src/com/android/car/user/CarUserService.java +++ b/service/src/com/android/car/user/CarUserService.java @@ -23,6 +23,7 @@ import android.content.Context; import android.content.Intent; import android.content.IntentFilter; import android.content.pm.UserInfo; +import android.os.UserHandle; import android.os.UserManager; import android.util.Log; @@ -88,7 +89,7 @@ public class CarUserService extends BroadcastReceiver implements CarServiceBase Log.d(TAG, "onReceive " + intent); } - if (intent.getAction() == Intent.ACTION_LOCKED_BOOT_COMPLETED) { + if (Intent.ACTION_LOCKED_BOOT_COMPLETED.equals(intent.getAction())) { if (mCarUserManagerHelper.getAllUsers().size() == 0) { // Disable adding accounts for user 0. mCarUserManagerHelper.setUserRestriction(mCarUserManagerHelper.getSystemUserInfo(), @@ -101,13 +102,13 @@ public class CarUserService extends BroadcastReceiver implements CarServiceBase } else { mCarUserManagerHelper.switchToUserId(mCarUserManagerHelper.getInitialUser()); } - } - if (intent.getAction() == Intent.ACTION_USER_SWITCHED) { - // Update last active user if foreground user is not ephemeral. - if (!mCarUserManagerHelper.isForegroundUserEphemeral()) { + } else if (Intent.ACTION_USER_SWITCHED.equals(intent.getAction())) { + // Update last active user if the switched-to user is a persistent, non-system user. + int currentUser = intent.getIntExtra(Intent.EXTRA_USER_HANDLE, -1); + if (currentUser > UserHandle.USER_SYSTEM + && mCarUserManagerHelper.isPersistentUser(currentUser)) { mCarUserManagerHelper.setLastActiveUser( - mCarUserManagerHelper.getCurrentForegroundUserId(), - /* skipGlobalSettings= */ false); + currentUser, /* skipGlobalSetting= */ false); } } } |