Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 02b075ea authored by Yuri Lin's avatar Yuri Lin
Browse files

Don't show summaries work profile switch if there's no work profile

Fixes: 420844666
Test: manual + SummarizationCombinedPreferenceControllerTest
Flag: android.app.nm_summarization_ui
Change-Id: I9b6e1e82471f9d36c1a083c06bbb1c61f2d73691
parent 21578f0d
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -86,6 +86,7 @@ public class SummarizationCombinedPreferenceController extends BasePreferenceCon

        mWorkPref = category.findPreference(WORK_PREF_KEY);
        if (mWorkPref != null) {
            mWorkPref.setVisible(hasManagedProfile());
            mWorkPref.setOnPreferenceChangeListener(mWorkPrefListener);
        }

+13 −0
Original line number Diff line number Diff line
@@ -112,6 +112,19 @@ public class SummarizationCombinedPreferenceControllerTest {
        assertThat(mGlobalSwitch.isChecked()).isFalse();
    }

    @Test
    public void updateState_workSwitch_notVisibleWhenNoManagedProfile() {
        when(mBackend.isNotificationSummarizationEnabled(anyInt())).thenReturn(true);
        mController.setManagedProfile(null);
        mController.updateState(mPrefCategory);

        // The controller + main switch should be functional, but the work switch should not be
        // visible
        assertThat(mController.isAvailable()).isTrue();
        assertThat(mGlobalSwitch.isChecked()).isTrue();
        assertThat(mWorkSwitch.isVisible()).isFalse();
    }

    @Test
    public void updateState_hasManagedProfile_reflectsSettings() {
        // setup: has a work profile with summarization enabled