diff --git a/src/com/android/settings/notification/BlockPreferenceController.java b/src/com/android/settings/notification/BlockPreferenceController.java index 7c6201eeedf..5e568524d6f 100644 --- a/src/com/android/settings/notification/BlockPreferenceController.java +++ b/src/com/android/settings/notification/BlockPreferenceController.java @@ -103,8 +103,10 @@ public class BlockPreferenceController extends NotificationPreferenceController saveChannel(); } if (mBackend.onlyHasDefaultChannel(mAppRow.pkg, mAppRow.uid)) { - mAppRow.banned = blocked; - mBackend.setNotificationsEnabledForPackage(mAppRow.pkg, mAppRow.uid, !blocked); + if (mAppRow.banned != blocked) { + mAppRow.banned = blocked; + mBackend.setNotificationsEnabledForPackage(mAppRow.pkg, mAppRow.uid, !blocked); + } } } else if (mChannelGroup != null) { mChannelGroup.setBlocked(blocked); diff --git a/tests/robotests/src/com/android/settings/notification/BlockPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/notification/BlockPreferenceControllerTest.java index fbc9689f620..a13946e775e 100644 --- a/tests/robotests/src/com/android/settings/notification/BlockPreferenceControllerTest.java +++ b/tests/robotests/src/com/android/settings/notification/BlockPreferenceControllerTest.java @@ -250,8 +250,7 @@ public class BlockPreferenceControllerTest { verify(mBackend, times(2)).updateChannel(any(), anyInt(), any()); - // 2 calls for onSwitchChanged + once when calling updateState originally - verify(mBackend, times(3)).setNotificationsEnabledForPackage( + verify(mBackend, times(2)).setNotificationsEnabledForPackage( anyString(), anyInt(), anyBoolean()); }