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

Commit b152c2d3 authored by Matías Hernández's avatar Matías Hernández
Browse files

Fix stray ProfileSelectDialog when only one profile exists

Fixes: 377829434
Test: atest ZenModePrioritySendersPreferenceControllerTest
Flag: android.app.modes_ui
Change-Id: Ia5f667fd937107af98dfb3a073cadeb935ff8a8a
parent 2c4aec3a
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -299,6 +299,7 @@ class ZenModePrioritySendersPreferenceController
        List<UserHandle> userProfiles = mUserManager.getEnabledProfiles();
        if (userProfiles.size() <= 1) {
            mContext.startActivity(intent);
            return;
        }

        mProfileSelectDialog = ProfileSelectDialog.createDialog(mContext, userProfiles,
+15 −0
Original line number Diff line number Diff line
@@ -1545,6 +1545,21 @@ public final class ZenModePrioritySendersPreferenceControllerTest {
        assertThat(nextActivity.getAction()).isEqualTo(Intent.ACTION_MAIN);
    }

    @Test
    public void contactsSettingsClick_singleProfile_opensActivityWithoutDialog() {
        String contactsPackage = mContext.getString(R.string.config_contacts_package_name);
        setUpContactsApp(contactsPackage, /* withPreciseIntents= */ true);

        mCallsController.displayPreference(mPreferenceScreen);
        mCallsController.updateZenMode(mCallsPrefCategory, TestModeBuilder.EXAMPLE);
        SelectorWithWidgetPreference contactsPref = getBoundSelectorPreference(KEY_CONTACTS);

        contactsPref.getExtraWidget().performClick();

        assertThat(ShadowDialog.getLatestDialog()).isNull();
        assertThat(shadowOf(mActivity).getNextStartedActivity()).isNotNull();
    }

    @Test
    public void contactsSettingsClick_multipleProfiles_showsProfileChooserDialog() {
        String contactsPackage = mContext.getString(R.string.config_contacts_package_name);