Merge "Added UserInfo.convertedFromPreCreated" into rvc-qpr-dev am: 7d2354bdc5
Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/12495367 Change-Id: I164ccf69a41291610cf7f87f8cbbb453aa2aba2b
This commit is contained in:
@@ -220,6 +220,14 @@ public class UserInfo implements Parcelable {
|
||||
*/
|
||||
public boolean preCreated;
|
||||
|
||||
/**
|
||||
* When {@code true}, it indicates this user was created by converting a {@link #preCreated}
|
||||
* user.
|
||||
*
|
||||
* <p><b>NOTE: </b>only used for debugging purposes, it's not set when marshalled to a parcel.
|
||||
*/
|
||||
public boolean convertedFromPreCreated;
|
||||
|
||||
/**
|
||||
* Creates a UserInfo whose user type is determined automatically by the flags according to
|
||||
* {@link #getDefaultUserType}; can only be used for user types handled there.
|
||||
@@ -413,6 +421,7 @@ public class UserInfo implements Parcelable {
|
||||
lastLoggedInFingerprint = orig.lastLoggedInFingerprint;
|
||||
partial = orig.partial;
|
||||
preCreated = orig.preCreated;
|
||||
convertedFromPreCreated = orig.convertedFromPreCreated;
|
||||
profileGroupId = orig.profileGroupId;
|
||||
restrictedProfileParentId = orig.restrictedProfileParentId;
|
||||
guestToRemove = orig.guestToRemove;
|
||||
@@ -440,6 +449,7 @@ public class UserInfo implements Parcelable {
|
||||
+ ", type=" + userType
|
||||
+ ", flags=" + flagsToString(flags)
|
||||
+ (preCreated ? " (pre-created)" : "")
|
||||
+ (convertedFromPreCreated ? " (converted)" : "")
|
||||
+ (partial ? " (partial)" : "")
|
||||
+ "]";
|
||||
}
|
||||
|
||||
@@ -173,6 +173,7 @@ public class UserManagerService extends IUserManager.Stub {
|
||||
private static final String ATTR_NEXT_SERIAL_NO = "nextSerialNumber";
|
||||
private static final String ATTR_PARTIAL = "partial";
|
||||
private static final String ATTR_PRE_CREATED = "preCreated";
|
||||
private static final String ATTR_CONVERTED_FROM_PRE_CREATED = "convertedFromPreCreated";
|
||||
private static final String ATTR_GUEST_TO_REMOVE = "guestToRemove";
|
||||
private static final String ATTR_USER_VERSION = "version";
|
||||
private static final String ATTR_PROFILE_GROUP_ID = "profileGroupId";
|
||||
@@ -2896,6 +2897,9 @@ public class UserManagerService extends IUserManager.Stub {
|
||||
if (userInfo.preCreated) {
|
||||
serializer.attribute(null, ATTR_PRE_CREATED, "true");
|
||||
}
|
||||
if (userInfo.convertedFromPreCreated) {
|
||||
serializer.attribute(null, ATTR_CONVERTED_FROM_PRE_CREATED, "true");
|
||||
}
|
||||
if (userInfo.guestToRemove) {
|
||||
serializer.attribute(null, ATTR_GUEST_TO_REMOVE, "true");
|
||||
}
|
||||
@@ -3053,6 +3057,7 @@ public class UserManagerService extends IUserManager.Stub {
|
||||
int restrictedProfileParentId = UserInfo.NO_PROFILE_GROUP_ID;
|
||||
boolean partial = false;
|
||||
boolean preCreated = false;
|
||||
boolean converted = false;
|
||||
boolean guestToRemove = false;
|
||||
boolean persistSeedData = false;
|
||||
String seedAccountName = null;
|
||||
@@ -3104,6 +3109,10 @@ public class UserManagerService extends IUserManager.Stub {
|
||||
if ("true".equals(valueString)) {
|
||||
preCreated = true;
|
||||
}
|
||||
valueString = parser.getAttributeValue(null, ATTR_CONVERTED_FROM_PRE_CREATED);
|
||||
if ("true".equals(valueString)) {
|
||||
converted = true;
|
||||
}
|
||||
valueString = parser.getAttributeValue(null, ATTR_GUEST_TO_REMOVE);
|
||||
if ("true".equals(valueString)) {
|
||||
guestToRemove = true;
|
||||
@@ -3161,6 +3170,7 @@ public class UserManagerService extends IUserManager.Stub {
|
||||
userInfo.lastLoggedInFingerprint = lastLoggedInFingerprint;
|
||||
userInfo.partial = partial;
|
||||
userInfo.preCreated = preCreated;
|
||||
userInfo.convertedFromPreCreated = converted;
|
||||
userInfo.guestToRemove = guestToRemove;
|
||||
userInfo.profileGroupId = profileGroupId;
|
||||
userInfo.profileBadge = profileBadge;
|
||||
@@ -3607,6 +3617,7 @@ public class UserManagerService extends IUserManager.Stub {
|
||||
preCreatedUser.name = name;
|
||||
preCreatedUser.flags = newFlags;
|
||||
preCreatedUser.preCreated = false;
|
||||
preCreatedUser.convertedFromPreCreated = true;
|
||||
preCreatedUser.creationTime = getCreationTime();
|
||||
|
||||
synchronized (mPackagesLock) {
|
||||
@@ -4669,6 +4680,7 @@ public class UserManagerService extends IUserManager.Stub {
|
||||
running ? " (running)" : "",
|
||||
user.partial ? " (partial)" : "",
|
||||
user.preCreated ? " (pre-created)" : "",
|
||||
user.convertedFromPreCreated ? " (converted)" : "",
|
||||
current ? " (current)" : "");
|
||||
} else {
|
||||
// NOTE: the standard "list users" command is used by integration tests and
|
||||
@@ -4753,6 +4765,9 @@ public class UserManagerService extends IUserManager.Stub {
|
||||
if (userInfo.preCreated) {
|
||||
pw.print(" <pre-created>");
|
||||
}
|
||||
if (userInfo.convertedFromPreCreated) {
|
||||
pw.print(" <converted>");
|
||||
}
|
||||
pw.println();
|
||||
pw.print(" Type: "); pw.println(userInfo.userType);
|
||||
pw.print(" Flags: "); pw.print(userInfo.flags); pw.print(" (");
|
||||
|
||||
@@ -105,7 +105,7 @@ public class UserManagerServiceUserInfoTest {
|
||||
UserData read = mUserManagerService.readUserLP(
|
||||
data.info.id, new ByteArrayInputStream(bytes));
|
||||
|
||||
assertUserInfoEquals(data.info, read.info);
|
||||
assertUserInfoEquals(data.info, read.info, /* parcelCopy= */ false);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -123,7 +123,16 @@ public class UserManagerServiceUserInfoTest {
|
||||
UserInfo read = UserInfo.CREATOR.createFromParcel(in);
|
||||
in.recycle();
|
||||
|
||||
assertUserInfoEquals(info, read);
|
||||
assertUserInfoEquals(info, read, /* parcelCopy= */ true);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testCopyConstructor() throws Exception {
|
||||
UserInfo info = createUser();
|
||||
|
||||
UserInfo copy = new UserInfo(info);
|
||||
|
||||
assertUserInfoEquals(info, copy, /* parcelCopy= */ false);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -227,10 +236,11 @@ public class UserManagerServiceUserInfoTest {
|
||||
user.partial = true;
|
||||
user.guestToRemove = true;
|
||||
user.preCreated = true;
|
||||
user.convertedFromPreCreated = true;
|
||||
return user;
|
||||
}
|
||||
|
||||
private void assertUserInfoEquals(UserInfo one, UserInfo two) {
|
||||
private void assertUserInfoEquals(UserInfo one, UserInfo two, boolean parcelCopy) {
|
||||
assertEquals("Id not preserved", one.id, two.id);
|
||||
assertEquals("Name not preserved", one.name, two.name);
|
||||
assertEquals("Icon path not preserved", one.iconPath, two.iconPath);
|
||||
@@ -238,11 +248,17 @@ public class UserManagerServiceUserInfoTest {
|
||||
assertEquals("UserType not preserved", one.userType, two.userType);
|
||||
assertEquals("profile group not preserved", one.profileGroupId,
|
||||
two.profileGroupId);
|
||||
assertEquals("restricted profile parent not preseved", one.restrictedProfileParentId,
|
||||
assertEquals("restricted profile parent not preserved", one.restrictedProfileParentId,
|
||||
two.restrictedProfileParentId);
|
||||
assertEquals("profile badge not preseved", one.profileBadge, two.profileBadge);
|
||||
assertEquals("partial not preseved", one.partial, two.partial);
|
||||
assertEquals("guestToRemove not preseved", one.guestToRemove, two.guestToRemove);
|
||||
assertEquals("preCreated not preseved", one.preCreated, two.preCreated);
|
||||
assertEquals("profile badge not preserved", one.profileBadge, two.profileBadge);
|
||||
assertEquals("partial not preserved", one.partial, two.partial);
|
||||
assertEquals("guestToRemove not preserved", one.guestToRemove, two.guestToRemove);
|
||||
assertEquals("preCreated not preserved", one.preCreated, two.preCreated);
|
||||
if (parcelCopy) {
|
||||
assertFalse("convertedFromPreCreated should not be set", two.convertedFromPreCreated);
|
||||
} else {
|
||||
assertEquals("convertedFromPreCreated not preserved", one.convertedFromPreCreated,
|
||||
two.convertedFromPreCreated);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user