Fix "Turn on phone calls" for guest user

Move "Turn on phone calls" from guest detail user screen to user screen.
Optimisation: Applying restrictions to default guest user has been moved
to UserManagerService -> setDefaultGuestRestrictions.

Following UX there is no need for confirmation dialog.

Bug: 191483069
Test: make RunSettingsRoboTests -j128 ROBOTEST_FILTER="com.android.settings.users.GuestTelephonyPreferenceControllerTest"
       make RunSettingsRoboTests -j128 ROBOTEST_FILTER="com.android.settings.users.UserSettingsTest"
Change-Id: Id7391d3f85954ea7f9c94791f24174105ec8073e
This commit is contained in:
Anna Bauza
2022-04-27 13:07:09 +00:00
parent 25fd957190
commit 935b735fb4
10 changed files with 286 additions and 100 deletions

View File

@@ -47,7 +47,6 @@ public class ShadowUserManager extends org.robolectric.shadows.ShadowUserManager
private static final int PRIMARY_USER_ID = 0;
private final List<String> mBaseRestrictions = new ArrayList<>();
private final List<String> mGuestRestrictions = new ArrayList<>();
private final Map<String, List<EnforcingUser>> mRestrictionSources = new HashMap<>();
private final List<UserInfo> mUserProfileInfos = new ArrayList<>();
private final Set<Integer> mManagedProfiles = new HashSet<>();
@@ -55,6 +54,7 @@ public class ShadowUserManager extends org.robolectric.shadows.ShadowUserManager
private boolean mIsQuietModeEnabled = false;
private int[] profileIdsForUser = new int[0];
private boolean mUserSwitchEnabled;
private Bundle mDefaultGuestUserRestriction = new Bundle();
private @UserManager.UserSwitchabilityResult int mSwitchabilityStatus =
UserManager.SWITCHABILITY_STATUS_OK;
@@ -99,15 +99,24 @@ public class ShadowUserManager extends org.robolectric.shadows.ShadowUserManager
@Implementation
protected Bundle getDefaultGuestRestrictions() {
Bundle bundle = new Bundle();
mGuestRestrictions.forEach(restriction -> bundle.putBoolean(restriction, true));
return bundle;
return mDefaultGuestUserRestriction;
}
@Implementation
protected void setDefaultGuestRestrictions(Bundle restrictions) {
mDefaultGuestUserRestriction = restrictions;
}
public void addGuestUserRestriction(String restriction) {
mGuestRestrictions.add(restriction);
mDefaultGuestUserRestriction.putBoolean(restriction, true);
}
public boolean hasGuestUserRestriction(String restriction, boolean expectedValue) {
return mDefaultGuestUserRestriction.containsKey(restriction)
&& mDefaultGuestUserRestriction.getBoolean(restriction) == expectedValue;
}
@Implementation
protected boolean hasUserRestriction(String restrictionKey) {
return hasUserRestriction(restrictionKey, UserHandle.of(UserHandle.myUserId()));