Merge "Localize owner's name to current locale until changed" into nyc-dev

This commit is contained in:
Amith Yamasani
2016-03-23 22:33:15 +00:00
committed by Android (Google) Code Review
2 changed files with 28 additions and 9 deletions

View File

@@ -216,6 +216,7 @@ public class UserInfo implements Parcelable {
lastLoggedInTime = orig.lastLoggedInTime; lastLoggedInTime = orig.lastLoggedInTime;
partial = orig.partial; partial = orig.partial;
profileGroupId = orig.profileGroupId; profileGroupId = orig.profileGroupId;
restrictedProfileParentId = orig.restrictedProfileParentId;
guestToRemove = orig.guestToRemove; guestToRemove = orig.guestToRemove;
} }

View File

@@ -458,7 +458,7 @@ public class UserManagerService extends IUserManager.Stub {
continue; continue;
} }
if (!excludeDying || !mRemovingUserIds.get(ui.id)) { if (!excludeDying || !mRemovingUserIds.get(ui.id)) {
users.add(ui); users.add(userWithName(ui));
} }
} }
return users; return users;
@@ -500,7 +500,7 @@ public class UserManagerService extends IUserManager.Stub {
if (mRemovingUserIds.get(profile.id)) { if (mRemovingUserIds.get(profile.id)) {
continue; continue;
} }
users.add(profile); users.add(userWithName(profile));
} }
return users; return users;
} }
@@ -653,7 +653,21 @@ public class UserManagerService extends IUserManager.Stub {
public UserInfo getUserInfo(int userId) { public UserInfo getUserInfo(int userId) {
checkManageUsersPermission("query user"); checkManageUsersPermission("query user");
synchronized (mUsersLock) { synchronized (mUsersLock) {
return getUserInfoLU(userId); return userWithName(getUserInfoLU(userId));
}
}
/**
* Returns a UserInfo object with the name filled in, for Owner, or the original
* if the name is already set.
*/
private UserInfo userWithName(UserInfo orig) {
if (orig != null && orig.name == null && orig.id == UserHandle.USER_SYSTEM) {
UserInfo withName = new UserInfo(orig);
withName.name = getOwnerName();
return withName;
} else {
return orig;
} }
} }
@@ -1459,9 +1473,7 @@ public class UserManagerService extends IUserManager.Stub {
flags |= UserInfo.FLAG_ADMIN | UserInfo.FLAG_PRIMARY; flags |= UserInfo.FLAG_ADMIN | UserInfo.FLAG_PRIMARY;
} }
// Create the system user // Create the system user
UserInfo system = new UserInfo(UserHandle.USER_SYSTEM, UserInfo system = new UserInfo(UserHandle.USER_SYSTEM, null, null, flags);
mContext.getResources().getString(com.android.internal.R.string.owner_name), null,
flags);
UserData userData = new UserData(); UserData userData = new UserData();
userData.info = system; userData.info = system;
synchronized (mUsersLock) { synchronized (mUsersLock) {
@@ -1482,6 +1494,10 @@ public class UserManagerService extends IUserManager.Stub {
writeUserLP(userData); writeUserLP(userData);
} }
private String getOwnerName() {
return mContext.getResources().getString(com.android.internal.R.string.owner_name);
}
private void scheduleWriteUser(UserData UserData) { private void scheduleWriteUser(UserData UserData) {
if (DBG) { if (DBG) {
debug("scheduleWriteUser"); debug("scheduleWriteUser");
@@ -1551,9 +1567,11 @@ public class UserManagerService extends IUserManager.Stub {
serializer.attribute(null, ATTR_SEED_ACCOUNT_TYPE, userData.seedAccountType); serializer.attribute(null, ATTR_SEED_ACCOUNT_TYPE, userData.seedAccountType);
} }
} }
serializer.startTag(null, TAG_NAME); if (userInfo.name != null) {
serializer.text(userInfo.name); serializer.startTag(null, TAG_NAME);
serializer.endTag(null, TAG_NAME); serializer.text(userInfo.name);
serializer.endTag(null, TAG_NAME);
}
synchronized (mRestrictionsLock) { synchronized (mRestrictionsLock) {
UserRestrictionsUtils.writeRestrictions(serializer, UserRestrictionsUtils.writeRestrictions(serializer,
mBaseUserRestrictions.get(userInfo.id), TAG_RESTRICTIONS); mBaseUserRestrictions.get(userInfo.id), TAG_RESTRICTIONS);