summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--services/devicepolicy/java/com/android/server/devicepolicy/Owners.java4
-rw-r--r--services/tests/servicestests/src/com/android/server/devicepolicy/OwnersTest.java13
2 files changed, 14 insertions, 3 deletions
diff --git a/services/devicepolicy/java/com/android/server/devicepolicy/Owners.java b/services/devicepolicy/java/com/android/server/devicepolicy/Owners.java
index 3ca158dc9c96..194647fda92c 100644
--- a/services/devicepolicy/java/com/android/server/devicepolicy/Owners.java
+++ b/services/devicepolicy/java/com/android/server/devicepolicy/Owners.java
@@ -120,7 +120,9 @@ class Owners {
} else {
mDeviceStateCache.setDeviceOwnerType(NO_DEVICE_OWNER);
}
-
+ for (int userId : usersIds) {
+ mDeviceStateCache.setHasProfileOwner(userId, hasProfileOwner(userId));
+ }
} else {
mUserManagerInternal.setDeviceManaged(hasDeviceOwner());
for (int userId : usersIds) {
diff --git a/services/tests/servicestests/src/com/android/server/devicepolicy/OwnersTest.java b/services/tests/servicestests/src/com/android/server/devicepolicy/OwnersTest.java
index 85a2446cc316..375b52d2d5e4 100644
--- a/services/tests/servicestests/src/com/android/server/devicepolicy/OwnersTest.java
+++ b/services/tests/servicestests/src/com/android/server/devicepolicy/OwnersTest.java
@@ -21,6 +21,7 @@ import static android.app.admin.DevicePolicyManager.DEVICE_OWNER_TYPE_FINANCED;
import static android.app.admin.SystemUpdatePolicy.TYPE_INSTALL_WINDOWED;
import static com.google.common.truth.Truth.assertThat;
+import static com.google.common.truth.Truth.assertWithMessage;
import android.content.ComponentName;
import android.os.IpcDataCache;
@@ -43,6 +44,7 @@ import org.junit.runner.RunWith;
@RunWith(AndroidJUnit4.class)
public class OwnersTest extends DpmTestBase {
+ private static final int TEST_PO_USER = 10;
private static final String TESTDPC_PACKAGE = "com.afwsamples.testdpc";
private final DeviceStateCacheImpl mDeviceStateCache = new DeviceStateCacheImpl();
@@ -55,11 +57,11 @@ public class OwnersTest extends DpmTestBase {
@Test
public void loadProfileOwner() throws Exception {
- getServices().addUsers(10);
+ getServices().addUsers(TEST_PO_USER);
final Owners owners = makeOwners();
- DpmTestUtils.writeToFile(owners.getProfileOwnerFile(10),
+ DpmTestUtils.writeToFile(owners.getProfileOwnerFile(TEST_PO_USER),
DpmTestUtils.readAsset(mRealTestContext, "OwnersTest/profile_owner_1.xml"));
owners.load();
@@ -71,6 +73,9 @@ public class OwnersTest extends DpmTestBase {
assertThat(owners.getProfileOwnerComponent(10))
.isEqualTo(new ComponentName(TESTDPC_PACKAGE,
"com.afwsamples.testdpc.DeviceAdminReceiver"));
+
+ assertWithMessage("Profile owner data in DeviceStateCache wasn't populated")
+ .that(mDeviceStateCache.isUserOrganizationManaged(TEST_PO_USER)).isTrue();
}
@Test
@@ -90,6 +95,10 @@ public class OwnersTest extends DpmTestBase {
"com.afwsamples.testdpc.DeviceAdminReceiver"));
assertThat(owners.getSystemUpdatePolicy().getPolicyType()).isEqualTo(TYPE_INSTALL_WINDOWED);
+
+ assertWithMessage("Device owner data in DeviceStateCache wasn't populated")
+ .that(mDeviceStateCache.isUserOrganizationManaged(owners.getDeviceOwnerUserId()))
+ .isTrue();
}
@Test