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:
@@ -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
|
||||
|
Reference in New Issue
Block a user