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;
|
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
|
* 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.
|
* {@link #getDefaultUserType}; can only be used for user types handled there.
|
||||||
@@ -413,6 +421,7 @@ public class UserInfo implements Parcelable {
|
|||||||
lastLoggedInFingerprint = orig.lastLoggedInFingerprint;
|
lastLoggedInFingerprint = orig.lastLoggedInFingerprint;
|
||||||
partial = orig.partial;
|
partial = orig.partial;
|
||||||
preCreated = orig.preCreated;
|
preCreated = orig.preCreated;
|
||||||
|
convertedFromPreCreated = orig.convertedFromPreCreated;
|
||||||
profileGroupId = orig.profileGroupId;
|
profileGroupId = orig.profileGroupId;
|
||||||
restrictedProfileParentId = orig.restrictedProfileParentId;
|
restrictedProfileParentId = orig.restrictedProfileParentId;
|
||||||
guestToRemove = orig.guestToRemove;
|
guestToRemove = orig.guestToRemove;
|
||||||
@@ -440,6 +449,7 @@ public class UserInfo implements Parcelable {
|
|||||||
+ ", type=" + userType
|
+ ", type=" + userType
|
||||||
+ ", flags=" + flagsToString(flags)
|
+ ", flags=" + flagsToString(flags)
|
||||||
+ (preCreated ? " (pre-created)" : "")
|
+ (preCreated ? " (pre-created)" : "")
|
||||||
|
+ (convertedFromPreCreated ? " (converted)" : "")
|
||||||
+ (partial ? " (partial)" : "")
|
+ (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_NEXT_SERIAL_NO = "nextSerialNumber";
|
||||||
private static final String ATTR_PARTIAL = "partial";
|
private static final String ATTR_PARTIAL = "partial";
|
||||||
private static final String ATTR_PRE_CREATED = "preCreated";
|
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_GUEST_TO_REMOVE = "guestToRemove";
|
||||||
private static final String ATTR_USER_VERSION = "version";
|
private static final String ATTR_USER_VERSION = "version";
|
||||||
private static final String ATTR_PROFILE_GROUP_ID = "profileGroupId";
|
private static final String ATTR_PROFILE_GROUP_ID = "profileGroupId";
|
||||||
@@ -2896,6 +2897,9 @@ public class UserManagerService extends IUserManager.Stub {
|
|||||||
if (userInfo.preCreated) {
|
if (userInfo.preCreated) {
|
||||||
serializer.attribute(null, ATTR_PRE_CREATED, "true");
|
serializer.attribute(null, ATTR_PRE_CREATED, "true");
|
||||||
}
|
}
|
||||||
|
if (userInfo.convertedFromPreCreated) {
|
||||||
|
serializer.attribute(null, ATTR_CONVERTED_FROM_PRE_CREATED, "true");
|
||||||
|
}
|
||||||
if (userInfo.guestToRemove) {
|
if (userInfo.guestToRemove) {
|
||||||
serializer.attribute(null, ATTR_GUEST_TO_REMOVE, "true");
|
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;
|
int restrictedProfileParentId = UserInfo.NO_PROFILE_GROUP_ID;
|
||||||
boolean partial = false;
|
boolean partial = false;
|
||||||
boolean preCreated = false;
|
boolean preCreated = false;
|
||||||
|
boolean converted = false;
|
||||||
boolean guestToRemove = false;
|
boolean guestToRemove = false;
|
||||||
boolean persistSeedData = false;
|
boolean persistSeedData = false;
|
||||||
String seedAccountName = null;
|
String seedAccountName = null;
|
||||||
@@ -3104,6 +3109,10 @@ public class UserManagerService extends IUserManager.Stub {
|
|||||||
if ("true".equals(valueString)) {
|
if ("true".equals(valueString)) {
|
||||||
preCreated = true;
|
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);
|
valueString = parser.getAttributeValue(null, ATTR_GUEST_TO_REMOVE);
|
||||||
if ("true".equals(valueString)) {
|
if ("true".equals(valueString)) {
|
||||||
guestToRemove = true;
|
guestToRemove = true;
|
||||||
@@ -3161,6 +3170,7 @@ public class UserManagerService extends IUserManager.Stub {
|
|||||||
userInfo.lastLoggedInFingerprint = lastLoggedInFingerprint;
|
userInfo.lastLoggedInFingerprint = lastLoggedInFingerprint;
|
||||||
userInfo.partial = partial;
|
userInfo.partial = partial;
|
||||||
userInfo.preCreated = preCreated;
|
userInfo.preCreated = preCreated;
|
||||||
|
userInfo.convertedFromPreCreated = converted;
|
||||||
userInfo.guestToRemove = guestToRemove;
|
userInfo.guestToRemove = guestToRemove;
|
||||||
userInfo.profileGroupId = profileGroupId;
|
userInfo.profileGroupId = profileGroupId;
|
||||||
userInfo.profileBadge = profileBadge;
|
userInfo.profileBadge = profileBadge;
|
||||||
@@ -3607,6 +3617,7 @@ public class UserManagerService extends IUserManager.Stub {
|
|||||||
preCreatedUser.name = name;
|
preCreatedUser.name = name;
|
||||||
preCreatedUser.flags = newFlags;
|
preCreatedUser.flags = newFlags;
|
||||||
preCreatedUser.preCreated = false;
|
preCreatedUser.preCreated = false;
|
||||||
|
preCreatedUser.convertedFromPreCreated = true;
|
||||||
preCreatedUser.creationTime = getCreationTime();
|
preCreatedUser.creationTime = getCreationTime();
|
||||||
|
|
||||||
synchronized (mPackagesLock) {
|
synchronized (mPackagesLock) {
|
||||||
@@ -4669,6 +4680,7 @@ public class UserManagerService extends IUserManager.Stub {
|
|||||||
running ? " (running)" : "",
|
running ? " (running)" : "",
|
||||||
user.partial ? " (partial)" : "",
|
user.partial ? " (partial)" : "",
|
||||||
user.preCreated ? " (pre-created)" : "",
|
user.preCreated ? " (pre-created)" : "",
|
||||||
|
user.convertedFromPreCreated ? " (converted)" : "",
|
||||||
current ? " (current)" : "");
|
current ? " (current)" : "");
|
||||||
} else {
|
} else {
|
||||||
// NOTE: the standard "list users" command is used by integration tests and
|
// 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) {
|
if (userInfo.preCreated) {
|
||||||
pw.print(" <pre-created>");
|
pw.print(" <pre-created>");
|
||||||
}
|
}
|
||||||
|
if (userInfo.convertedFromPreCreated) {
|
||||||
|
pw.print(" <converted>");
|
||||||
|
}
|
||||||
pw.println();
|
pw.println();
|
||||||
pw.print(" Type: "); pw.println(userInfo.userType);
|
pw.print(" Type: "); pw.println(userInfo.userType);
|
||||||
pw.print(" Flags: "); pw.print(userInfo.flags); pw.print(" (");
|
pw.print(" Flags: "); pw.print(userInfo.flags); pw.print(" (");
|
||||||
|
|||||||
@@ -105,7 +105,7 @@ public class UserManagerServiceUserInfoTest {
|
|||||||
UserData read = mUserManagerService.readUserLP(
|
UserData read = mUserManagerService.readUserLP(
|
||||||
data.info.id, new ByteArrayInputStream(bytes));
|
data.info.id, new ByteArrayInputStream(bytes));
|
||||||
|
|
||||||
assertUserInfoEquals(data.info, read.info);
|
assertUserInfoEquals(data.info, read.info, /* parcelCopy= */ false);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@@ -123,7 +123,16 @@ public class UserManagerServiceUserInfoTest {
|
|||||||
UserInfo read = UserInfo.CREATOR.createFromParcel(in);
|
UserInfo read = UserInfo.CREATOR.createFromParcel(in);
|
||||||
in.recycle();
|
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
|
@Test
|
||||||
@@ -227,10 +236,11 @@ public class UserManagerServiceUserInfoTest {
|
|||||||
user.partial = true;
|
user.partial = true;
|
||||||
user.guestToRemove = true;
|
user.guestToRemove = true;
|
||||||
user.preCreated = true;
|
user.preCreated = true;
|
||||||
|
user.convertedFromPreCreated = true;
|
||||||
return user;
|
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("Id not preserved", one.id, two.id);
|
||||||
assertEquals("Name not preserved", one.name, two.name);
|
assertEquals("Name not preserved", one.name, two.name);
|
||||||
assertEquals("Icon path not preserved", one.iconPath, two.iconPath);
|
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("UserType not preserved", one.userType, two.userType);
|
||||||
assertEquals("profile group not preserved", one.profileGroupId,
|
assertEquals("profile group not preserved", one.profileGroupId,
|
||||||
two.profileGroupId);
|
two.profileGroupId);
|
||||||
assertEquals("restricted profile parent not preseved", one.restrictedProfileParentId,
|
assertEquals("restricted profile parent not preserved", one.restrictedProfileParentId,
|
||||||
two.restrictedProfileParentId);
|
two.restrictedProfileParentId);
|
||||||
assertEquals("profile badge not preseved", one.profileBadge, two.profileBadge);
|
assertEquals("profile badge not preserved", one.profileBadge, two.profileBadge);
|
||||||
assertEquals("partial not preseved", one.partial, two.partial);
|
assertEquals("partial not preserved", one.partial, two.partial);
|
||||||
assertEquals("guestToRemove not preseved", one.guestToRemove, two.guestToRemove);
|
assertEquals("guestToRemove not preserved", one.guestToRemove, two.guestToRemove);
|
||||||
assertEquals("preCreated not preseved", one.preCreated, two.preCreated);
|
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