Fix an assumption that UserHandle.myUserId() always returns the main
user. In some cases, e.g. in Private Space Storage Info fragment it returns the Private profile id and this was leading to a crash, see b/378471943. Bug: 378471943 Test: Manually and presubmit Flag: com.android.settings.flags.utils_return_user_handle_for_current_user_id Change-Id: I5f7bedc66ebcac8b0ae265b7189dd1821edb3cd7
This commit is contained in:
@@ -70,3 +70,13 @@ flag {
|
|||||||
description: "Flag for catalyst service"
|
description: "Flag for catalyst service"
|
||||||
bug: "323791114"
|
bug: "323791114"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
flag {
|
||||||
|
name: "utils_return_user_handle_for_current_user_id"
|
||||||
|
namespace: "profile_experiences"
|
||||||
|
description: "Don't ignore the current user id when checking for existing profiles."
|
||||||
|
bug: "378471943"
|
||||||
|
metadata {
|
||||||
|
purpose: PURPOSE_BUGFIX
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@@ -424,7 +424,8 @@ public final class Utils extends com.android.settingslib.Utils {
|
|||||||
final List<UserHandle> userProfiles = userManager.getUserProfiles();
|
final List<UserHandle> userProfiles = userManager.getUserProfiles();
|
||||||
String umUserType = getUmUserType(userType);
|
String umUserType = getUmUserType(userType);
|
||||||
for (UserHandle profile : userProfiles) {
|
for (UserHandle profile : userProfiles) {
|
||||||
if (profile.getIdentifier() == UserHandle.myUserId()) {
|
if (!com.android.settings.flags.Flags.utilsReturnUserHandleForCurrentUserId()
|
||||||
|
&& profile.getIdentifier() == UserHandle.myUserId()) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
final UserInfo userInfo = userManager.getUserInfo(profile.getIdentifier());
|
final UserInfo userInfo = userManager.getUserInfo(profile.getIdentifier());
|
||||||
|
Reference in New Issue
Block a user