Show a separate tab for the Private Space
This covers all the known Settings pages using the tabbed view model. https://docs.google.com/document/d/1CdjUjAE84-5ZEPRIfw5KYFjLVHtEZxc_sF0w95su8DA/edit?resourcekey=0-dAACT9HRexY1IyoxMmkVlw#heading=h.58jd58rmznte Screenshots: all apps https://screenshot.googleplex.com/3E5Jm7Pi2JfN64r with work tab: https://screenshot.googleplex.com/8egk4yHK5jSENjR PS Apps Special media management apps https://screenshot.googleplex.com/BHHafqW7bgUwSGg with work tab: https://screenshot.googleplex.com/3cocdhruEmCCh5k PS Location Services tab view https://screenshot.googleplex.com/3DqJcT2BFTEpvYT with work tab: https://screenshot.googleplex.com/6Avpx6hxSrdGJw5 PS on screen keyboard tab view https://screenshot.googleplex.com/4FzVNnBWwbUeJNw with work tab: https://screenshot.googleplex.com/8E8UhpWq8PL5nxU PS password account tab view https://screenshot.googleplex.com/6bDR4AKtth2S3EW with work tab: https://screenshot.googleplex.com/9msXV2TdHdJapch PS storage tab view https://screenshot.googleplex.com/5Nk2FTxwdmpEv3B with work tab: https://screenshot.googleplex.com/79tw2EaWZKfMsnC PS appl_languages_work https://screenshot.googleplex.com/3qrREeg3RQdHhhH Bug: 302278487 Test: manual Change-Id: I8cd39170827fbe251bc4075ef306206020b3a022
This commit is contained in:
@@ -18,6 +18,9 @@ package com.android.settings;
|
||||
|
||||
import static android.content.Intent.EXTRA_USER;
|
||||
import static android.content.Intent.EXTRA_USER_ID;
|
||||
import static android.os.UserManager.USER_TYPE_FULL_SYSTEM;
|
||||
import static android.os.UserManager.USER_TYPE_PROFILE_MANAGED;
|
||||
import static android.os.UserManager.USER_TYPE_PROFILE_PRIVATE;
|
||||
import static android.text.format.DateUtils.FORMAT_ABBREV_MONTH;
|
||||
import static android.text.format.DateUtils.FORMAT_SHOW_DATE;
|
||||
|
||||
@@ -63,6 +66,7 @@ import android.os.BatteryManager;
|
||||
import android.os.Binder;
|
||||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
import android.os.Flags;
|
||||
import android.os.IBinder;
|
||||
import android.os.INetworkManagementService;
|
||||
import android.os.RemoteException;
|
||||
@@ -111,6 +115,7 @@ import com.android.internal.util.ArrayUtils;
|
||||
import com.android.internal.widget.LockPatternUtils;
|
||||
import com.android.settings.dashboard.profileselector.ProfileFragmentBridge;
|
||||
import com.android.settings.dashboard.profileselector.ProfileSelectFragment;
|
||||
import com.android.settings.dashboard.profileselector.ProfileSelectFragment.ProfileType;
|
||||
import com.android.settings.password.ChooseLockSettingsHelper;
|
||||
import com.android.settingslib.widget.ActionBarShadowController;
|
||||
import com.android.settingslib.widget.AdaptiveIcon;
|
||||
@@ -118,6 +123,7 @@ import com.android.settingslib.widget.AdaptiveIcon;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.Objects;
|
||||
import java.util.Set;
|
||||
|
||||
public final class Utils extends com.android.settingslib.Utils {
|
||||
@@ -440,6 +446,38 @@ public final class Utils extends com.android.settingslib.Utils {
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the profile of userType of the current user or {@code null} if none is found or a
|
||||
* profile exists, but it is disabled.
|
||||
*/
|
||||
@Nullable
|
||||
public static UserHandle getProfileOfType(
|
||||
@NonNull UserManager userManager, @ProfileType int userType) {
|
||||
final List<UserHandle> userProfiles = userManager.getUserProfiles();
|
||||
String umUserType = getUmUserType(userType);
|
||||
for (UserHandle profile : userProfiles) {
|
||||
if (profile.getIdentifier() == UserHandle.myUserId()) {
|
||||
continue;
|
||||
}
|
||||
final UserInfo userInfo = userManager.getUserInfo(profile.getIdentifier());
|
||||
if (Objects.equals(umUserType, userInfo.userType)) {
|
||||
return profile;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private static String getUmUserType(@ProfileType int userType) throws IllegalArgumentException {
|
||||
if (userType == ProfileType.WORK) {
|
||||
return USER_TYPE_PROFILE_MANAGED;
|
||||
} else if (userType == ProfileType.PRIVATE) {
|
||||
return USER_TYPE_PROFILE_PRIVATE;
|
||||
} else if (userType == ProfileType.PERSONAL) {
|
||||
return USER_TYPE_FULL_SYSTEM;
|
||||
}
|
||||
throw new IllegalArgumentException("Cannot get user type for ALL types");
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the managed profile of the current user or {@code null} if none is found. Unlike
|
||||
* {@link #getManagedProfile} this method returns enabled and disabled managed profiles.
|
||||
@@ -479,15 +517,20 @@ public final class Utils extends com.android.settingslib.Utils {
|
||||
return UserHandle.USER_NULL;
|
||||
}
|
||||
|
||||
/** Returns user ID of current user, throws IllegalStateException if it's not available. */
|
||||
public static int getCurrentUserId(UserManager userManager, boolean isWorkProfile)
|
||||
throws IllegalStateException {
|
||||
if (isWorkProfile) {
|
||||
final UserHandle managedUserHandle = getManagedProfile(userManager);
|
||||
if (managedUserHandle == null) {
|
||||
throw new IllegalStateException("Work profile user ID is not available.");
|
||||
/**
|
||||
* Returns user ID of the user of specified type under the current context, throws
|
||||
* IllegalStateException if it's not available.
|
||||
*/
|
||||
public static int getCurrentUserIdOfType(
|
||||
@NonNull UserManager userManager,
|
||||
@ProfileType int userType) throws IllegalStateException {
|
||||
if (userType != ProfileType.PERSONAL) {
|
||||
final UserHandle userHandle = getProfileOfType(userManager, userType);
|
||||
if (userHandle == null) {
|
||||
throw new IllegalStateException("User ID of requested profile type is not "
|
||||
+ "available.");
|
||||
}
|
||||
return managedUserHandle.getIdentifier();
|
||||
return userHandle.getIdentifier();
|
||||
}
|
||||
return UserHandle.myUserId();
|
||||
}
|
||||
@@ -1223,8 +1266,10 @@ public final class Utils extends com.android.settingslib.Utils {
|
||||
List<UserHandle> profiles = userManager.getUserProfiles();
|
||||
for (UserHandle userHandle : profiles) {
|
||||
UserProperties userProperties = userManager.getUserProperties(userHandle);
|
||||
if (userProperties.getShowInSettings()
|
||||
== UserProperties.SHOW_IN_SETTINGS_SEPARATE) {
|
||||
if (userProperties.getShowInSettings() == UserProperties.SHOW_IN_SETTINGS_SEPARATE) {
|
||||
if (Flags.allowPrivateProfile() && userProperties.getHideInSettingsInQuietMode()) {
|
||||
return !userManager.isQuietModeEnabled(userHandle);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user