diff options
| -rw-r--r-- | core/res/res/values-en-rGB/strings.xml | 2 | ||||
| -rwxr-xr-x | core/res/res/values/strings.xml | 4 | ||||
| -rw-r--r-- | core/res/res/values/symbols.xml | 1 | ||||
| -rw-r--r-- | services/java/com/android/server/pm/UserManagerService.java | 40 |
4 files changed, 44 insertions, 3 deletions
diff --git a/core/res/res/values-en-rGB/strings.xml b/core/res/res/values-en-rGB/strings.xml index fdd35a163014..d63f85d23f73 100644 --- a/core/res/res/values-en-rGB/strings.xml +++ b/core/res/res/values-en-rGB/strings.xml @@ -585,7 +585,7 @@ <string name="permdesc_writeDictionary" msgid="8185385716255065291">"Allows the app to write new words into the user dictionary."</string> <string name="permlab_sdcardRead" product="nosdcard" msgid="8235341515605559677">"test access to protected storage"</string> <string name="permlab_sdcardRead" product="default" msgid="8235341515605559677">"test access to protected storage"</string> - <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> + <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> <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> <string name="permlab_sdcardWrite" product="nosdcard" msgid="8485979062254666748">"modify or delete the contents of your USB storage"</string> <string name="permlab_sdcardWrite" product="default" msgid="8805693630050458763">"modify or delete the contents of your SD card"</string> diff --git a/core/res/res/values/strings.xml b/core/res/res/values/strings.xml index f8dbd84da82c..47a8fc5af7f1 100755 --- a/core/res/res/values/strings.xml +++ b/core/res/res/values/strings.xml @@ -1721,7 +1721,7 @@ <!-- Title of an application permission, listed so the user can choose whether they want to allow the application to do this. --> <string name="permlab_sdcardRead" product="default">test access to protected storage</string> <!-- Description of an application permission, listed so the user can choose whether they want to allow the application to do this. [CHAR LIMIT=30] --> - <string name="permdesc_sdcardRead" product="nosdcard">Allows the app to test a permission for USB storage that will be availabe on future devices. </string> + <string name="permdesc_sdcardRead" product="nosdcard">Allows the app to test a permission for USB storage that will be available on future devices. </string> <!-- Description of an application permission, listed so the user can choose whether they want to allow the application to do this. --> <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> @@ -3950,5 +3950,7 @@ <string name="enable_accessibility_canceled">Accessibility canceled.</string> <!-- Text spoken when the current user is switched if accessibility is enabled. [CHAR LIMIT=none] --> <string name="user_switched">Current user <xliff:g id="name" example="Bob">%1$s</xliff:g>.</string> + <!-- Default name of the owner user [CHAR LIMIT=20] --> + <string name="owner_name" msgid="3879126011135546571">Owner</string> </resources> diff --git a/core/res/res/values/symbols.xml b/core/res/res/values/symbols.xml index 8ef91df1853b..632e33d0c67a 100644 --- a/core/res/res/values/symbols.xml +++ b/core/res/res/values/symbols.xml @@ -842,6 +842,7 @@ <java-symbol type="string" name="media_route_status_connecting" /> <java-symbol type="string" name="media_route_status_available" /> <java-symbol type="string" name="media_route_status_not_available" /> + <java-symbol type="string" name="owner_name" /> <java-symbol type="plurals" name="abbrev_in_num_days" /> <java-symbol type="plurals" name="abbrev_in_num_hours" /> diff --git a/services/java/com/android/server/pm/UserManagerService.java b/services/java/com/android/server/pm/UserManagerService.java index fb93d059a14b..e05442b3b905 100644 --- a/services/java/com/android/server/pm/UserManagerService.java +++ b/services/java/com/android/server/pm/UserManagerService.java @@ -26,6 +26,7 @@ import android.app.IStopUserCallback; import android.content.BroadcastReceiver; import android.content.Context; import android.content.Intent; +import android.content.SharedPreferences; import android.content.pm.PackageManager; import android.content.pm.UserInfo; import android.graphics.Bitmap; @@ -75,6 +76,7 @@ public class UserManagerService extends IUserManager.Stub { private static final String ATTR_SERIAL_NO = "serialNumber"; private static final String ATTR_NEXT_SERIAL_NO = "nextSerialNumber"; private static final String ATTR_PARTIAL = "partial"; + private static final String ATTR_USER_VERSION = "version"; private static final String TAG_USERS = "users"; private static final String TAG_USER = "user"; @@ -84,6 +86,8 @@ public class UserManagerService extends IUserManager.Stub { private static final int MIN_USER_ID = 10; + private static final int USER_VERSION = 1; + private static final long EPOCH_PLUS_30_YEARS = 30L * 365 * 24 * 60 * 60 * 1000L; // ms private final Context mContext; @@ -104,6 +108,7 @@ public class UserManagerService extends IUserManager.Stub { // This resets on a reboot. Otherwise it keeps incrementing so that user ids are // not reused in quick succession private int mNextUserId = MIN_USER_ID; + private int mUserVersion = 0; private static UserManagerService sInstance; @@ -432,12 +437,17 @@ public class UserManagerService extends IUserManager.Stub { if (lastSerialNumber != null) { mNextSerialNumber = Integer.parseInt(lastSerialNumber); } + String versionNumber = parser.getAttributeValue(null, ATTR_USER_VERSION); + if (versionNumber != null) { + mUserVersion = Integer.parseInt(versionNumber); + } } while ((type = parser.next()) != XmlPullParser.END_DOCUMENT) { if (type == XmlPullParser.START_TAG && parser.getName().equals(TAG_USER)) { String id = parser.getAttributeValue(null, ATTR_ID); UserInfo user = readUser(Integer.parseInt(id)); + if (user != null) { mUsers.put(user.id, user); if (user.isGuest()) { @@ -450,6 +460,7 @@ public class UserManagerService extends IUserManager.Stub { } } updateUserIdsLocked(); + upgradeIfNecessary(); } catch (IOException ioe) { fallbackToSingleUserLocked(); } catch (XmlPullParserException pe) { @@ -464,9 +475,35 @@ public class UserManagerService extends IUserManager.Stub { } } + /** + * This fixes an incorrect initialization of user name for the owner. + * TODO: Remove in the next release. + */ + private void upgradeIfNecessary() { + int userVersion = mUserVersion; + if (userVersion < 1) { + // Assign a proper name for the owner, if not initialized correctly before + UserInfo user = mUsers.get(UserHandle.USER_OWNER); + if ("Primary".equals(user.name)) { + user.name = mContext.getResources().getString(com.android.internal.R.string.owner_name); + writeUserLocked(user); + } + userVersion = 1; + } + + if (userVersion < USER_VERSION) { + Slog.w(LOG_TAG, "User version " + mUserVersion + " didn't upgrade as expected to " + + USER_VERSION); + } else { + mUserVersion = userVersion; + writeUserListLocked(); + } + } + private void fallbackToSingleUserLocked() { // Create the primary user - UserInfo primary = new UserInfo(0, "Primary", null, + UserInfo primary = new UserInfo(0, + mContext.getResources().getString(com.android.internal.R.string.owner_name), null, UserInfo.FLAG_ADMIN | UserInfo.FLAG_PRIMARY | UserInfo.FLAG_INITIALIZED); mUsers.put(0, primary); mNextSerialNumber = MIN_USER_ID; @@ -547,6 +584,7 @@ public class UserManagerService extends IUserManager.Stub { serializer.startTag(null, TAG_USERS); serializer.attribute(null, ATTR_NEXT_SERIAL_NO, Integer.toString(mNextSerialNumber)); + serializer.attribute(null, ATTR_USER_VERSION, Integer.toString(mUserVersion)); for (int i = 0; i < mUsers.size(); i++) { UserInfo user = mUsers.valueAt(i); |