Don't show policy transparency UI for cross-profile setting.

Also removes the switch if cross-profile calendar is disabled by admin.

Test: atest ManagedProfileSettingsTest
Fixes: 123930863
Change-Id: Ieeb9266e8833d7ca730fedb5e947b03ec7d18d3c
This commit is contained in:
Jonathan Scott
2019-04-15 15:36:17 +01:00
parent 3683a688f7
commit ed701572d7
6 changed files with 206 additions and 28 deletions

View File

@@ -17,6 +17,9 @@ package com.android.settings.accounts;
import static android.provider.Settings.Secure.CROSS_PROFILE_CALENDAR_ENABLED;
import static com.android.settings.core.BasePreferenceController.AVAILABLE;
import static com.android.settings.core.BasePreferenceController.DISABLED_FOR_USER;
import static com.google.common.truth.Truth.assertThat;
import static org.mockito.ArgumentMatchers.any;
@@ -117,30 +120,27 @@ public class CrossProfileCalendarPreferenceControllerTest {
}
@Test
public void updateState_noPackageAllowed_preferenceShouldBeDisabled() throws Exception {
public void getAvailabilityStatus_noPackageAllowed_shouldBeDisabledForUser() throws Exception {
dpm.setProfileOwner(TEST_COMPONENT_NAME);
mController.updateState(mPreference);
verify(mPreference).setDisabledByAdmin(any());
assertThat(mController.getAvailabilityStatus()).isEqualTo(DISABLED_FOR_USER);
}
@Test
public void updateState_somePackagesAllowed_preferenceShouldNotBeDisabled() throws Exception {
public void getAvailabilityStatus_somePackagesAllowed_shouldBeAvailable() throws Exception {
dpm.setProfileOwner(TEST_COMPONENT_NAME);
dpm.setCrossProfileCalendarPackages(TEST_COMPONENT_NAME,
Collections.singleton(TEST_PACKAGE_NAME));
mController.updateState(mPreference);
verify(mPreference).setDisabledByAdmin(null);
assertThat(mController.getAvailabilityStatus()).isEqualTo(AVAILABLE);
}
@Test
public void updateState_allPackagesAllowed_preferenceShouldNotBeDisabled() throws Exception {
public void getAvailabilityStatus_allPackagesAllowed_shouldBeAvailable() throws Exception {
dpm.setProfileOwner(TEST_COMPONENT_NAME);
dpm.setCrossProfileCalendarPackages(TEST_COMPONENT_NAME, null);
mController.updateState(mPreference);
verify(mPreference).setDisabledByAdmin(null);
assertThat(mController.getAvailabilityStatus()).isEqualTo(AVAILABLE);
}
@Test