From 7679fec17ec53d7a58f0b9c0c1ca68b92892ca12 Mon Sep 17 00:00:00 2001 From: Julia Reynolds Date: Wed, 25 Oct 2023 13:01:57 -0400 Subject: [PATCH] Remove duel switch from NAS switch Test: NotificationAssistantPreferenceControllerTest Fixes: 301340325 Change-Id: Id41fad70bdcda6de75b59befe3654b733dbf66e3 --- res/xml/configure_notification_settings.xml | 2 +- ...ficationAssistantPreferenceController.java | 18 --------- ...tionAssistantPreferenceControllerTest.java | 38 ------------------- 3 files changed, 1 insertion(+), 57 deletions(-) diff --git a/res/xml/configure_notification_settings.xml b/res/xml/configure_notification_settings.xml index ee88215985f..4550e1333d6 100644 --- a/res/xml/configure_notification_settings.xml +++ b/res/xml/configure_notification_settings.xml @@ -174,7 +174,7 @@ android:title="@string/notification_pulse_title" settings:controller="com.android.settings.notification.PulseNotificationPreferenceController"/> - resolved = mPackageManager.queryIntentActivities(mNASSettingIntent, - PackageManager.ResolveInfoFlags.of(PackageManager.MATCH_ALL)); - return (resolved != null && !resolved.isEmpty()); - } - @Override public void updateState(Preference preference) { super.updateState(preference); if (mDefaultNASComponent == null) { preference.setEnabled(false); ((PrimarySwitchPreference) preference).setSwitchEnabled(false); - } else if (isNASSettingActivityAvailable()) { - preference.setIntent(mNASSettingIntent); - } else { - // Cannot find settings activity from the default NAS app - preference.setIntent(null); - preference.setOnPreferenceClickListener( - preference1 -> { - onPreferenceChange(preference1, !isChecked()); - ((PrimarySwitchPreference) preference1).setChecked(isChecked()); - return true; - } - ); } } } diff --git a/tests/robotests/src/com/android/settings/notification/NotificationAssistantPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/notification/NotificationAssistantPreferenceControllerTest.java index 54a6bd42375..5f506b8ac0b 100644 --- a/tests/robotests/src/com/android/settings/notification/NotificationAssistantPreferenceControllerTest.java +++ b/tests/robotests/src/com/android/settings/notification/NotificationAssistantPreferenceControllerTest.java @@ -154,34 +154,6 @@ public class NotificationAssistantPreferenceControllerTest { verify(mBackend, times(1)).setNotificationAssistantGranted(null); } - @Test - public void testUpdateState_SettingActivityAvailable() throws Exception { - mPreferenceController.updateState(mPreference); - assertNotNull(mPreference.getIntent()); - - mPreference.performClick(); - Intent nextIntent = Shadows.shadowOf( - (Application) ApplicationProvider.getApplicationContext()).getNextStartedActivity(); - assertEquals(nextIntent.getAction(), ACTION_NOTIFICATION_ASSISTANT_DETAIL_SETTINGS); - } - - @Test - public void testUpdateState_SettingActivityUnavailable() throws Exception { - when(mPackageManager.queryIntentActivities(any(Intent.class), any())) - .thenReturn(null); - mPreferenceController.updateState(mPreference); - assertNull(mPreference.getIntent()); - - mPreference.performClick(); - Intent nextIntent = Shadows.shadowOf( - (Application) ApplicationProvider.getApplicationContext()).getNextStartedActivity(); - assertNull(nextIntent); - // Verify a dialog is shown - verify(mFragmentTransaction).add( - any(NotificationAssistantDialogFragment.class), anyString()); - verify(mBackend, times(0)).setNotificationAssistantGranted(any()); - } - @Test @Config(shadows = ShadowSecureSettings.class) public void testMigrationFromSetting_userEnable_multiProfile() throws Exception { @@ -229,14 +201,4 @@ public class NotificationAssistantPreferenceControllerTest { verify(mBackend, never()) .setNASMigrationDoneAndResetDefault(eq(10), anyBoolean()); } - - @Test - public void testNASUnavailable_settingDisabled() throws Exception { - when(mBackend.getDefaultNotificationAssistant()).thenReturn(null); - mPreferenceController.getDefaultNASIntent(); - mPreferenceController.updateState(mPreference); - - verify(mPreference, atLeastOnce()).setSwitchEnabled(eq(false)); - assertFalse(mPreference.isEnabled()); - } }