Use Device Policy dialog in switchbar

We need to pop dialog when switchbar is disabled by Device Policy

Test: visual, robolectric
Fixes: 124855614
Change-Id: Ief65baa2c4912cb7c85d5eccc2c0f363d2fc898b
This commit is contained in:
Raff Tsai
2019-02-26 08:51:10 +08:00
parent d5a04e1912
commit 3fd80809cc
3 changed files with 118 additions and 4 deletions

View File

@@ -26,6 +26,7 @@ import org.robolectric.RuntimeEnvironment;
import org.robolectric.annotation.Implementation;
import org.robolectric.annotation.Implements;
import org.robolectric.shadow.api.Shadow;
import org.robolectric.annotation.Resetter;
import java.util.ArrayList;
import java.util.Collections;
@@ -38,6 +39,8 @@ import java.util.Set;
@Implements(value = UserManager.class)
public class ShadowUserManager extends org.robolectric.shadows.ShadowUserManager {
private static boolean sIsSupportsMultipleUsers;
private final List<String> mRestrictions = new ArrayList<>();
private final Map<String, List<EnforcingUser>> mRestrictionSources = new HashMap<>();
private final List<UserInfo> mUserProfileInfos = new ArrayList<>();
@@ -50,6 +53,11 @@ public class ShadowUserManager extends org.robolectric.shadows.ShadowUserManager
mUserProfileInfos.add(userInfo);
}
@Resetter
public static void reset() {
sIsSupportsMultipleUsers = false;
}
@Implementation
protected List<UserInfo> getProfiles(@UserIdInt int userHandle) {
return mUserProfileInfos;
@@ -124,4 +132,13 @@ public class ShadowUserManager extends org.robolectric.shadows.ShadowUserManager
public void setUserSwitcherEnabled(boolean userSwitchEnabled) {
mUserSwitchEnabled = userSwitchEnabled;
}
@Implementation
protected static boolean supportsMultipleUsers() {
return sIsSupportsMultipleUsers;
}
public void setSupportsMultipleUsers(boolean supports) {
sIsSupportsMultipleUsers = supports;
}
}