Skip to content

Commit 369f1c9

Browse files
Amith YamasaniAndroid Git Automerger
authored andcommitted
am 0848245: Merge "Fix the user name for the owner." into jb-mr1-dev
* commit '084824548f9706db8356ed4480c282288ffc0bd0': Fix the user name for the owner.
2 parents b8a220c + 0848245 commit 369f1c9

File tree

4 files changed

+44
-3
lines changed

4 files changed

+44
-3
lines changed

core/res/res/values-en-rGB/strings.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -585,7 +585,7 @@
585585
<string name="permdesc_writeDictionary" msgid="8185385716255065291">"Allows the app to write new words into the user dictionary."</string>
586586
<string name="permlab_sdcardRead" product="nosdcard" msgid="8235341515605559677">"test access to protected storage"</string>
587587
<string name="permlab_sdcardRead" product="default" msgid="8235341515605559677">"test access to protected storage"</string>
588-
<string name="permdesc_sdcardRead" product="nosdcard" msgid="5791957130190763289">"Allows the app to test a permission for USB storage that will be availabe on future devices."</string>
588+
<string name="permdesc_sdcardRead" product="nosdcard" msgid="5791957130190763289">"Allows the app to test a permission for USB storage that will be available on future devices."</string>
589589
<string name="permdesc_sdcardRead" product="default" msgid="5914402684685848828">"Allows the app to test a permission for the SD card that will be available on future devices."</string>
590590
<string name="permlab_sdcardWrite" product="nosdcard" msgid="8485979062254666748">"modify or delete the contents of your USB storage"</string>
591591
<string name="permlab_sdcardWrite" product="default" msgid="8805693630050458763">"modify or delete the contents of your SD card"</string>

core/res/res/values/strings.xml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1721,7 +1721,7 @@
17211721
<!-- Title of an application permission, listed so the user can choose whether they want to allow the application to do this. -->
17221722
<string name="permlab_sdcardRead" product="default">test access to protected storage</string>
17231723
<!-- Description of an application permission, listed so the user can choose whether they want to allow the application to do this. [CHAR LIMIT=30] -->
1724-
<string name="permdesc_sdcardRead" product="nosdcard">Allows the app to test a permission for USB storage that will be availabe on future devices. </string>
1724+
<string name="permdesc_sdcardRead" product="nosdcard">Allows the app to test a permission for USB storage that will be available on future devices. </string>
17251725
<!-- Description of an application permission, listed so the user can choose whether they want to allow the application to do this. -->
17261726
<string name="permdesc_sdcardRead" product="default">Allows the app to test a permission for the SD card that will be available on future devices.</string>
17271727

@@ -3950,5 +3950,7 @@
39503950
<string name="enable_accessibility_canceled">Accessibility canceled.</string>
39513951
<!-- Text spoken when the current user is switched if accessibility is enabled. [CHAR LIMIT=none] -->
39523952
<string name="user_switched">Current user <xliff:g id="name" example="Bob">%1$s</xliff:g>.</string>
3953+
<!-- Default name of the owner user [CHAR LIMIT=20] -->
3954+
<string name="owner_name" msgid="3879126011135546571">Owner</string>
39533955

39543956
</resources>

core/res/res/values/symbols.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -842,6 +842,7 @@
842842
<java-symbol type="string" name="media_route_status_connecting" />
843843
<java-symbol type="string" name="media_route_status_available" />
844844
<java-symbol type="string" name="media_route_status_not_available" />
845+
<java-symbol type="string" name="owner_name" />
845846

846847
<java-symbol type="plurals" name="abbrev_in_num_days" />
847848
<java-symbol type="plurals" name="abbrev_in_num_hours" />

services/java/com/android/server/pm/UserManagerService.java

Lines changed: 39 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
import android.content.BroadcastReceiver;
2727
import android.content.Context;
2828
import android.content.Intent;
29+
import android.content.SharedPreferences;
2930
import android.content.pm.PackageManager;
3031
import android.content.pm.UserInfo;
3132
import android.graphics.Bitmap;
@@ -75,6 +76,7 @@ public class UserManagerService extends IUserManager.Stub {
7576
private static final String ATTR_SERIAL_NO = "serialNumber";
7677
private static final String ATTR_NEXT_SERIAL_NO = "nextSerialNumber";
7778
private static final String ATTR_PARTIAL = "partial";
79+
private static final String ATTR_USER_VERSION = "version";
7880
private static final String TAG_USERS = "users";
7981
private static final String TAG_USER = "user";
8082

@@ -84,6 +86,8 @@ public class UserManagerService extends IUserManager.Stub {
8486

8587
private static final int MIN_USER_ID = 10;
8688

89+
private static final int USER_VERSION = 1;
90+
8791
private static final long EPOCH_PLUS_30_YEARS = 30L * 365 * 24 * 60 * 60 * 1000L; // ms
8892

8993
private final Context mContext;
@@ -104,6 +108,7 @@ public class UserManagerService extends IUserManager.Stub {
104108
// This resets on a reboot. Otherwise it keeps incrementing so that user ids are
105109
// not reused in quick succession
106110
private int mNextUserId = MIN_USER_ID;
111+
private int mUserVersion = 0;
107112

108113
private static UserManagerService sInstance;
109114

@@ -432,12 +437,17 @@ private void readUserListLocked() {
432437
if (lastSerialNumber != null) {
433438
mNextSerialNumber = Integer.parseInt(lastSerialNumber);
434439
}
440+
String versionNumber = parser.getAttributeValue(null, ATTR_USER_VERSION);
441+
if (versionNumber != null) {
442+
mUserVersion = Integer.parseInt(versionNumber);
443+
}
435444
}
436445

437446
while ((type = parser.next()) != XmlPullParser.END_DOCUMENT) {
438447
if (type == XmlPullParser.START_TAG && parser.getName().equals(TAG_USER)) {
439448
String id = parser.getAttributeValue(null, ATTR_ID);
440449
UserInfo user = readUser(Integer.parseInt(id));
450+
441451
if (user != null) {
442452
mUsers.put(user.id, user);
443453
if (user.isGuest()) {
@@ -450,6 +460,7 @@ private void readUserListLocked() {
450460
}
451461
}
452462
updateUserIdsLocked();
463+
upgradeIfNecessary();
453464
} catch (IOException ioe) {
454465
fallbackToSingleUserLocked();
455466
} catch (XmlPullParserException pe) {
@@ -464,9 +475,35 @@ private void readUserListLocked() {
464475
}
465476
}
466477

478+
/**
479+
* This fixes an incorrect initialization of user name for the owner.
480+
* TODO: Remove in the next release.
481+
*/
482+
private void upgradeIfNecessary() {
483+
int userVersion = mUserVersion;
484+
if (userVersion < 1) {
485+
// Assign a proper name for the owner, if not initialized correctly before
486+
UserInfo user = mUsers.get(UserHandle.USER_OWNER);
487+
if ("Primary".equals(user.name)) {
488+
user.name = mContext.getResources().getString(com.android.internal.R.string.owner_name);
489+
writeUserLocked(user);
490+
}
491+
userVersion = 1;
492+
}
493+
494+
if (userVersion < USER_VERSION) {
495+
Slog.w(LOG_TAG, "User version " + mUserVersion + " didn't upgrade as expected to "
496+
+ USER_VERSION);
497+
} else {
498+
mUserVersion = userVersion;
499+
writeUserListLocked();
500+
}
501+
}
502+
467503
private void fallbackToSingleUserLocked() {
468504
// Create the primary user
469-
UserInfo primary = new UserInfo(0, "Primary", null,
505+
UserInfo primary = new UserInfo(0,
506+
mContext.getResources().getString(com.android.internal.R.string.owner_name), null,
470507
UserInfo.FLAG_ADMIN | UserInfo.FLAG_PRIMARY | UserInfo.FLAG_INITIALIZED);
471508
mUsers.put(0, primary);
472509
mNextSerialNumber = MIN_USER_ID;
@@ -547,6 +584,7 @@ private void writeUserListLocked() {
547584

548585
serializer.startTag(null, TAG_USERS);
549586
serializer.attribute(null, ATTR_NEXT_SERIAL_NO, Integer.toString(mNextSerialNumber));
587+
serializer.attribute(null, ATTR_USER_VERSION, Integer.toString(mUserVersion));
550588

551589
for (int i = 0; i < mUsers.size(); i++) {
552590
UserInfo user = mUsers.valueAt(i);

0 commit comments

Comments
 (0)