Support Private profile in profile modal selector

Profile selector modal with work profile
https://screenshot.googleplex.com/8ugpsT7nZA75VPa

Modal without work profile
https://screenshot.googleplex.com/9bPFbFG2DKBHhvS

Bug: 309635228
Test: manual
Change-Id: Id7533f101d2b5693c419c9591d59751925a4b7ce
This commit is contained in:
Manish Singh
2023-11-08 16:46:58 +00:00
parent 6ce9c37701
commit 94cffad6c2
2 changed files with 22 additions and 9 deletions

View File

@@ -25,7 +25,9 @@ import android.content.DialogInterface.OnDismissListener;
import android.content.DialogInterface.OnShowListener;
import android.content.Intent;
import android.content.pm.UserInfo;
import android.content.pm.UserProperties;
import android.os.Bundle;
import android.os.Flags;
import android.os.UserHandle;
import android.os.UserManager;
import android.util.Log;
@@ -183,7 +185,10 @@ public class ProfileSelectDialog extends DialogFragment implements UserAdapter.O
final UserManager userManager = UserManager.get(context);
for (int i = userHandles.size() - 1; i >= 0; i--) {
UserInfo userInfo = userManager.getUserInfo(userHandles.get(i).getIdentifier());
if (userInfo == null || userInfo.isCloneProfile()) {
if (userInfo == null
|| userInfo.isCloneProfile()
|| (Flags.allowPrivateProfile()
&& shouldHideUserInQuietMode(userHandles.get(i), userManager))) {
if (DEBUG) {
Log.d(TAG, "Delete the user: " + userHandles.get(i).getIdentifier());
}
@@ -214,7 +219,10 @@ public class ProfileSelectDialog extends DialogFragment implements UserAdapter.O
final UserManager userManager = UserManager.get(context);
for (UserHandle userHandle : List.copyOf(tile.pendingIntentMap.keySet())) {
UserInfo userInfo = userManager.getUserInfo(userHandle.getIdentifier());
if (userInfo == null || userInfo.isCloneProfile()) {
if (userInfo == null
|| userInfo.isCloneProfile()
|| (Flags.allowPrivateProfile()
&& shouldHideUserInQuietMode(userHandle, userManager))) {
if (DEBUG) {
Log.d(TAG, "Delete the user: " + userHandle.getIdentifier());
}
@@ -223,4 +231,11 @@ public class ProfileSelectDialog extends DialogFragment implements UserAdapter.O
}
}
}
private static boolean shouldHideUserInQuietMode(
UserHandle userHandle, UserManager userManager) {
UserProperties userProperties = userManager.getUserProperties(userHandle);
return userProperties.getHideInSettingsInQuietMode()
&& userManager.isQuietModeEnabled(userHandle);
}
}