summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorYing Zheng2018-06-25 15:09:05 -0500
committerAndroid (Google) Code Review2018-06-25 15:09:05 -0500
commitd50321314e309f0062850733a6e7b5f582af5f8c (patch)
tree97446164589c82ce954b16aa76e9761427839333 /service
parentd2335e6a0cf7c47a3dd276ce8f95ab9ae64b494e (diff)
parentcf20f44f515ca802baad7d73f86cbd829e1a2183 (diff)
downloadplatform-packages-services-car-d50321314e309f0062850733a6e7b5f582af5f8c.tar.gz
platform-packages-services-car-d50321314e309f0062850733a6e7b5f582af5f8c.tar.xz
platform-packages-services-car-d50321314e309f0062850733a6e7b5f582af5f8c.zip
Merge "Update last active user." into pi-dev
Diffstat (limited to 'service')
-rw-r--r--service/src/com/android/car/user/CarUserService.java15
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 bc5f2025..cc305882 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;
23import android.content.Intent; 23import android.content.Intent;
24import android.content.IntentFilter; 24import android.content.IntentFilter;
25import android.content.pm.UserInfo; 25import android.content.pm.UserInfo;
26import android.os.UserHandle;
26import android.os.UserManager; 27import android.os.UserManager;
27import android.util.Log; 28import android.util.Log;
28 29
@@ -88,7 +89,7 @@ public class CarUserService extends BroadcastReceiver implements CarServiceBase
88 Log.d(TAG, "onReceive " + intent); 89 Log.d(TAG, "onReceive " + intent);
89 } 90 }
90 91
91 if (intent.getAction() == Intent.ACTION_LOCKED_BOOT_COMPLETED) { 92 if (Intent.ACTION_LOCKED_BOOT_COMPLETED.equals(intent.getAction())) {
92 if (mCarUserManagerHelper.getAllUsers().size() == 0) { 93 if (mCarUserManagerHelper.getAllUsers().size() == 0) {
93 // Disable adding accounts for user 0. 94 // Disable adding accounts for user 0.
94 mCarUserManagerHelper.setUserRestriction(mCarUserManagerHelper.getSystemUserInfo(), 95 mCarUserManagerHelper.setUserRestriction(mCarUserManagerHelper.getSystemUserInfo(),
@@ -101,13 +102,13 @@ public class CarUserService extends BroadcastReceiver implements CarServiceBase
101 } else { 102 } else {
102 mCarUserManagerHelper.switchToUserId(mCarUserManagerHelper.getInitialUser()); 103 mCarUserManagerHelper.switchToUserId(mCarUserManagerHelper.getInitialUser());
103 } 104 }
104 } 105 } else if (Intent.ACTION_USER_SWITCHED.equals(intent.getAction())) {
105 if (intent.getAction() == Intent.ACTION_USER_SWITCHED) { 106 // Update last active user if the switched-to user is a persistent, non-system user.
106 // Update last active user if foreground user is not ephemeral. 107 int currentUser = intent.getIntExtra(Intent.EXTRA_USER_HANDLE, -1);
107 if (!mCarUserManagerHelper.isForegroundUserEphemeral()) { 108 if (currentUser > UserHandle.USER_SYSTEM
109 && mCarUserManagerHelper.isPersistentUser(currentUser)) {
108 mCarUserManagerHelper.setLastActiveUser( 110 mCarUserManagerHelper.setLastActiveUser(
109 mCarUserManagerHelper.getCurrentForegroundUserId(), 111 currentUser, /* skipGlobalSetting= */ false);
110 /* skipGlobalSettings= */ false);
111 } 112 }
112 } 113 }
113 } 114 }