diff options
| author | Yasin Kilicdere <tyk@google.com> | 2022-02-10 23:04:56 +0000 |
|---|---|---|
| committer | Yasin Kilicdere <tyk@google.com> | 2022-03-03 18:32:23 +0000 |
| commit | d03224f32646e6bcb68f0c9fa12fe63d2502e88c (patch) | |
| tree | 7f5b590b8b4b196c13048e7dea8729f775bbfae2 /core/java/android/os/UserManager.java | |
| parent | c4c1ac53fdb8217e3d15dded3e882617236c1fee (diff) | |
Fix Guest string was not translated in UMS.userWithName()
Guest users name was stuck with the language when it was created,
and it wasn't changing with the active language setting.
To solve that, removed name parameter from UM.createGuest() and
created the guest user with a null name, then made changes
in UMS.userWithName() to fill the name of guest user with the active
language's translation when it has a null name.
Creating a guest with a specific name is still supported
through UM.createUser API.
Bug: 185309160
Test: atest com.android.server.pm.UserManagerTest
Change-Id: I2745aed0ea722765a11c6da40fb4159146da54c7
Merged-In: I2745aed0ea722765a11c6da40fb4159146da54c7
(cherry picked from commit c556777ca4af81c2dde2fa383baae20398e3029e)
Diffstat (limited to 'core/java/android/os/UserManager.java')
| -rw-r--r-- | core/java/android/os/UserManager.java | 10 |
1 files changed, 4 insertions, 6 deletions
diff --git a/core/java/android/os/UserManager.java b/core/java/android/os/UserManager.java index e56f214e30d9..5c6a75c7af22 100644 --- a/core/java/android/os/UserManager.java +++ b/core/java/android/os/UserManager.java @@ -3322,7 +3322,7 @@ public class UserManager { * * <p>This method can be used by OEMs to "warm" up the user creation by pre-creating some users * at the first boot, so they when the "real" user is created (for example, - * by {@link #createUser(String, String, int)} or {@link #createGuest(Context, String)}), it + * by {@link #createUser(String, String, int)} or {@link #createGuest(Context)}), it * takes less time. * * <p>This method completes the majority of work necessary for user creation: it @@ -3359,7 +3359,6 @@ public class UserManager { /** * Creates a guest user and configures it. * @param context an application context - * @param name the name to set for the user * @return the {@link UserInfo} object for the created user, or {@code null} if the user * could not be created. * @@ -3367,20 +3366,19 @@ public class UserManager { */ @RequiresPermission(anyOf = {Manifest.permission.MANAGE_USERS, Manifest.permission.CREATE_USERS}) - public UserInfo createGuest(Context context, String name) { - UserInfo guest = null; + public UserInfo createGuest(Context context) { try { - guest = mService.createUserWithThrow(name, USER_TYPE_FULL_GUEST, 0); + final UserInfo guest = mService.createUserWithThrow(null, USER_TYPE_FULL_GUEST, 0); if (guest != null) { Settings.Secure.putStringForUser(context.getContentResolver(), Settings.Secure.SKIP_FIRST_USE_HINTS, "1", guest.id); } + return guest; } catch (ServiceSpecificException e) { return null; } catch (RemoteException re) { throw re.rethrowFromSystemServer(); } - return guest; } /** |
