summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--core/java/android/content/pm/UserInfo.java10
-rw-r--r--packages/SystemUI/src/com/android/systemui/privacy/PrivacyItemController.kt11
-rw-r--r--packages/SystemUI/tests/src/com/android/systemui/privacy/PrivacyItemControllerFlagsTest.kt39
-rw-r--r--packages/SystemUI/tests/src/com/android/systemui/privacy/PrivacyItemControllerTest.kt1
-rw-r--r--services/core/java/com/android/server/pm/UserManagerService.java15
-rw-r--r--services/tests/servicestests/src/com/android/server/pm/UserManagerServiceUserInfoTest.java32
6 files changed, 75 insertions, 33 deletions
diff --git a/core/java/android/content/pm/UserInfo.java b/core/java/android/content/pm/UserInfo.java
index aca5b458a2d6..08b23b04f2ae 100644
--- a/core/java/android/content/pm/UserInfo.java
+++ b/core/java/android/content/pm/UserInfo.java
@@ -221,6 +221,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)" : "")
+ "]";
}
diff --git a/packages/SystemUI/src/com/android/systemui/privacy/PrivacyItemController.kt b/packages/SystemUI/src/com/android/systemui/privacy/PrivacyItemController.kt
index a46ecaff7719..59118bf3534e 100644
--- a/packages/SystemUI/src/com/android/systemui/privacy/PrivacyItemController.kt
+++ b/packages/SystemUI/src/com/android/systemui/privacy/PrivacyItemController.kt
@@ -72,8 +72,6 @@ class PrivacyItemController @Inject constructor(
private const val ALL_INDICATORS =
SystemUiDeviceConfigFlags.PROPERTY_PERMISSIONS_HUB_ENABLED
private const val MIC_CAMERA = SystemUiDeviceConfigFlags.PROPERTY_MIC_CAMERA_ENABLED
- private const val DEFAULT_ALL_INDICATORS = false
- private const val DEFAULT_MIC_CAMERA = true
}
@VisibleForTesting
@@ -83,12 +81,12 @@ class PrivacyItemController @Inject constructor(
fun isAllIndicatorsEnabled(): Boolean {
return deviceConfigProxy.getBoolean(DeviceConfig.NAMESPACE_PRIVACY,
- ALL_INDICATORS, DEFAULT_ALL_INDICATORS)
+ ALL_INDICATORS, false)
}
private fun isMicCameraEnabled(): Boolean {
return deviceConfigProxy.getBoolean(DeviceConfig.NAMESPACE_PRIVACY,
- MIC_CAMERA, DEFAULT_MIC_CAMERA)
+ MIC_CAMERA, false)
}
private var currentUserIds = emptyList<Int>()
@@ -120,13 +118,12 @@ class PrivacyItemController @Inject constructor(
// Running on the ui executor so can iterate on callbacks
if (properties.keyset.contains(ALL_INDICATORS)) {
- allIndicatorsAvailable = properties.getBoolean(ALL_INDICATORS,
- DEFAULT_ALL_INDICATORS)
+ allIndicatorsAvailable = properties.getBoolean(ALL_INDICATORS, false)
callbacks.forEach { it.get()?.onFlagAllChanged(allIndicatorsAvailable) }
}
if (properties.keyset.contains(MIC_CAMERA)) {
- micCameraAvailable = properties.getBoolean(MIC_CAMERA, DEFAULT_MIC_CAMERA)
+ micCameraAvailable = properties.getBoolean(MIC_CAMERA, false)
callbacks.forEach { it.get()?.onFlagMicCameraChanged(micCameraAvailable) }
}
internalUiExecutor.updateListeningState()
diff --git a/packages/SystemUI/tests/src/com/android/systemui/privacy/PrivacyItemControllerFlagsTest.kt b/packages/SystemUI/tests/src/com/android/systemui/privacy/PrivacyItemControllerFlagsTest.kt
index 25fb7d300b8f..4ba29e6e02a6 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/privacy/PrivacyItemControllerFlagsTest.kt
+++ b/packages/SystemUI/tests/src/com/android/systemui/privacy/PrivacyItemControllerFlagsTest.kt
@@ -96,24 +96,22 @@ class PrivacyItemControllerFlagsTest : SysuiTestCase() {
}
@Test
- fun testNotListeningAllByDefault() {
+ fun testNotListeningByDefault() {
assertFalse(privacyItemController.allIndicatorsAvailable)
- }
+ assertFalse(privacyItemController.micCameraAvailable)
- @Test
- fun testMicCameraListeningByDefault() {
- assertTrue(privacyItemController.micCameraAvailable)
+ verify(appOpsController, never()).addCallback(any(), any())
}
@Test
fun testMicCameraChanged() {
- changeMicCamera(false) // default is true
+ changeMicCamera(true)
executor.runAllReady()
- verify(callback).onFlagMicCameraChanged(false)
+ verify(callback).onFlagMicCameraChanged(true)
verify(callback, never()).onFlagAllChanged(anyBoolean())
- assertFalse(privacyItemController.micCameraAvailable)
+ assertTrue(privacyItemController.micCameraAvailable)
assertFalse(privacyItemController.allIndicatorsAvailable)
}
@@ -126,19 +124,20 @@ class PrivacyItemControllerFlagsTest : SysuiTestCase() {
verify(callback, never()).onFlagMicCameraChanged(anyBoolean())
assertTrue(privacyItemController.allIndicatorsAvailable)
+ assertFalse(privacyItemController.micCameraAvailable)
}
@Test
fun testBothChanged() {
changeAll(true)
- changeMicCamera(false)
+ changeMicCamera(true)
executor.runAllReady()
verify(callback, atLeastOnce()).onFlagAllChanged(true)
- verify(callback, atLeastOnce()).onFlagMicCameraChanged(false)
+ verify(callback, atLeastOnce()).onFlagMicCameraChanged(true)
assertTrue(privacyItemController.allIndicatorsAvailable)
- assertFalse(privacyItemController.micCameraAvailable)
+ assertTrue(privacyItemController.micCameraAvailable)
}
@Test
@@ -158,11 +157,18 @@ class PrivacyItemControllerFlagsTest : SysuiTestCase() {
}
@Test
+ fun testAll_listening() {
+ changeAll(true)
+ executor.runAllReady()
+
+ verify(appOpsController).addCallback(eq(PrivacyItemController.OPS), any())
+ }
+
+ @Test
fun testAllFalse_notListening() {
changeAll(true)
executor.runAllReady()
changeAll(false)
- changeMicCamera(false)
executor.runAllReady()
verify(appOpsController).removeCallback(any(), any())
@@ -170,8 +176,8 @@ class PrivacyItemControllerFlagsTest : SysuiTestCase() {
@Test
fun testSomeListening_stillListening() {
- // Mic and camera are true by default
changeAll(true)
+ changeMicCamera(true)
executor.runAllReady()
changeAll(false)
executor.runAllReady()
@@ -180,8 +186,7 @@ class PrivacyItemControllerFlagsTest : SysuiTestCase() {
}
@Test
- fun testAllDeleted_micCameraFalse_stopListening() {
- changeMicCamera(false)
+ fun testAllDeleted_stopListening() {
changeAll(true)
executor.runAllReady()
changeAll(null)
@@ -191,13 +196,13 @@ class PrivacyItemControllerFlagsTest : SysuiTestCase() {
}
@Test
- fun testMicDeleted_stillListening() {
+ fun testMicDeleted_stopListening() {
changeMicCamera(true)
executor.runAllReady()
changeMicCamera(null)
executor.runAllReady()
- verify(appOpsController, never()).removeCallback(any(), any())
+ verify(appOpsController).removeCallback(any(), any())
}
private fun changeMicCamera(value: Boolean?) = changeProperty(MIC_CAMERA, value)
diff --git a/packages/SystemUI/tests/src/com/android/systemui/privacy/PrivacyItemControllerTest.kt b/packages/SystemUI/tests/src/com/android/systemui/privacy/PrivacyItemControllerTest.kt
index 38e8823adfbb..5c5df2639cdd 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/privacy/PrivacyItemControllerTest.kt
+++ b/packages/SystemUI/tests/src/com/android/systemui/privacy/PrivacyItemControllerTest.kt
@@ -272,7 +272,6 @@ class PrivacyItemControllerTest : SysuiTestCase() {
@Test
fun testNotListeningWhenIndicatorsDisabled() {
changeAll(false)
- changeMicCamera(false)
privacyItemController.addCallback(callback)
executor.runAllReady()
verify(appOpsController, never()).addCallback(eq(PrivacyItemController.OPS),
diff --git a/services/core/java/com/android/server/pm/UserManagerService.java b/services/core/java/com/android/server/pm/UserManagerService.java
index 244818a6f311..f5d7d9eda1ba 100644
--- a/services/core/java/com/android/server/pm/UserManagerService.java
+++ b/services/core/java/com/android/server/pm/UserManagerService.java
@@ -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(" (");
diff --git a/services/tests/servicestests/src/com/android/server/pm/UserManagerServiceUserInfoTest.java b/services/tests/servicestests/src/com/android/server/pm/UserManagerServiceUserInfoTest.java
index 66ca839081bc..0ccc02663dc5 100644
--- a/services/tests/servicestests/src/com/android/server/pm/UserManagerServiceUserInfoTest.java
+++ b/services/tests/servicestests/src/com/android/server/pm/UserManagerServiceUserInfoTest.java
@@ -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);
+ }
}
}