From 306e2d9f84450a5f16c9b4bcdee3affca5d575bb Mon Sep 17 00:00:00 2001 From: Julia Reynolds Date: Tue, 22 May 2018 09:07:46 -0400 Subject: [PATCH] Don't reset channel field when loading the app Only save data that's changed. Change-Id: Iaa8265f543a7c1ec418d9d016986e0a253f28df6 Fixes: 79216856 Test: robo tests --- .../settings/notification/BlockPreferenceController.java | 6 ++++-- .../notification/BlockPreferenceControllerTest.java | 3 +-- 2 files changed, 5 insertions(+), 4 deletions(-) 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()); }