Merge "Don't reset channel field when loading the app" into pi-dev
diff --git a/src/com/android/settings/notification/BlockPreferenceController.java b/src/com/android/settings/notification/BlockPreferenceController.java
index 7c6201e..5e56852 100644
--- a/src/com/android/settings/notification/BlockPreferenceController.java
+++ b/src/com/android/settings/notification/BlockPreferenceController.java
@@ -103,8 +103,10 @@
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 fbc9689..a13946e 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 @@
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());
}