commit | 6e64305274aa0454cad2641218c59d4daa0197be | [log] [tgz] |
---|---|---|
author | Chloris Kuo <chloriskuo@google.com> | Thu Oct 13 20:42:21 2022 +0000 |
committer | Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com> | Thu Oct 13 20:42:21 2022 +0000 |
tree | 6ff1599cd691c622d13e1798315d127d41cd6dfe | |
parent | 61cc95f7d1d9aada055db0b0f8f703b2948427ff [diff] | |
parent | 236eaed326bd5243efba2e39a2bfbd385b2385b3 [diff] |
Disable Enhanced notifications setting when default NAS is not available am: 236eaed326 Original change: https://googleplex-android-review.googlesource.com/c/platform/packages/apps/Settings/+/20188999 Change-Id: I68d337b4d5b947a7e0af817cb0c76039df18dbf8 Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
diff --git a/src/com/android/settings/notification/NotificationAssistantPreferenceController.java b/src/com/android/settings/notification/NotificationAssistantPreferenceController.java index 2c02db9..ee36273 100644 --- a/src/com/android/settings/notification/NotificationAssistantPreferenceController.java +++ b/src/com/android/settings/notification/NotificationAssistantPreferenceController.java
@@ -141,7 +141,10 @@ @Override public void updateState(Preference preference) { super.updateState(preference); - if (isNASSettingActivityAvailable()) { + 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
diff --git a/tests/robotests/src/com/android/settings/notification/NotificationAssistantPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/notification/NotificationAssistantPreferenceControllerTest.java index b594667..1dac399 100644 --- a/tests/robotests/src/com/android/settings/notification/NotificationAssistantPreferenceControllerTest.java +++ b/tests/robotests/src/com/android/settings/notification/NotificationAssistantPreferenceControllerTest.java
@@ -226,4 +226,14 @@ .setNASMigrationDoneAndResetDefault(eq(10), anyBoolean()); } + @Test + public void testNASUnavailable_settingDisabled() throws Exception { + when(mBackend.getDefaultNotificationAssistant()).thenReturn(null); + mPreferenceController.getDefaultNASIntent(); + mPreferenceController.updateState(mPreference); + + verify(mPreference, times(1)).setSwitchEnabled(eq(false)); + assertFalse(mPreference.isEnabled()); + } + }