Merge "Add isSystemUser() in UserSwitcherController."
This commit is contained in:
committed by
Android (Google) Code Review
commit
87fcbb3189
@@ -455,6 +455,13 @@ public class UserSwitcherController implements Dumpable {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns whether the current user is a system user.
|
||||
*/
|
||||
public boolean isSystemUser() {
|
||||
return mUserTracker.getUserId() == UserHandle.USER_SYSTEM;
|
||||
}
|
||||
|
||||
public void removeUserId(int userId) {
|
||||
if (userId == UserHandle.USER_SYSTEM) {
|
||||
Log.w(TAG, "User " + userId + " could not removed.");
|
||||
|
||||
@@ -400,4 +400,16 @@ class UserSwitcherControllerTest : SysuiTestCase() {
|
||||
|
||||
assertEquals(fgUserName, userSwitcherController.currentUserName)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun isSystemUser_currentUserIsSystemUser_shouldReturnTrue() {
|
||||
`when`(userTracker.userId).thenReturn(UserHandle.USER_SYSTEM)
|
||||
assertEquals(true, userSwitcherController.isSystemUser)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun isSystemUser_currentUserIsNotSystemUser_shouldReturnFalse() {
|
||||
`when`(userTracker.userId).thenReturn(1)
|
||||
assertEquals(false, userSwitcherController.isSystemUser)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user