Use HAL for switching drivers
Bug: 148115524
Test: atest CarUserServiceTest ExperimentalCarUserManagerUnitTest
Change-Id: I4dbc06127aeeb5db6ca3e5b329b17e3924061490
diff --git a/service/src/com/android/car/user/CarUserService.java b/service/src/com/android/car/user/CarUserService.java
index fc3d3a4..45494f7 100644
--- a/service/src/com/android/car/user/CarUserService.java
+++ b/service/src/com/android/car/user/CarUserService.java
@@ -416,29 +416,21 @@
* @see CarUserManager.switchDriver
*/
@Override
- public boolean switchDriver(@UserIdInt int driverId) {
+ public void switchDriver(@UserIdInt int driverId, AndroidFuture<UserSwitchResult> receiver) {
checkManageUsersPermission("switchDriver");
- if (driverId == UserHandle.USER_SYSTEM && UserManager.isHeadlessSystemUserMode()) {
+ if (UserHelper.isHeadlessSystemUser(driverId)) {
// System user doesn't associate with real person, can not be switched to.
Log.w(TAG_USER, "switching to system user in headless system user mode is not allowed");
- return false;
+ sendResult(receiver, UserSwitchResult.STATUS_INVALID_REQUEST);
+ return;
}
int userSwitchable = mUserManager.getUserSwitchability();
if (userSwitchable != UserManager.SWITCHABILITY_STATUS_OK) {
Log.w(TAG_USER, "current process is not allowed to switch user");
- return false;
+ sendResult(receiver, UserSwitchResult.STATUS_INVALID_REQUEST);
+ return;
}
- if (driverId == ActivityManager.getCurrentUser()) {
- // The current user is already the given user.
- return true;
- }
- try {
- return mAm.switchUser(driverId);
- } catch (RemoteException e) {
- // ignore
- Log.w(TAG_USER, "error while switching user", e);
- }
- return false;
+ switchUser(driverId, mHalTimeoutMs, receiver);
}
/**