diff options
author | Julia Reynolds <juliacr@google.com> | 2019-04-19 11:05:55 -0700 |
---|---|---|
committer | android-build-merger <android-build-merger@google.com> | 2019-04-19 11:05:55 -0700 |
commit | 24b5930f6ebd338c8d24a0a7978d09463f1e01a6 (patch) | |
tree | 38462cb8dc4e38b3b46040db7d849b76971c1cb2 | |
parent | 0796af3045de98075044d7391bdb3194ed91b98e (diff) | |
parent | 76d5fb3f6c57da22e94dabdb9e119c185950c4c4 (diff) |
Merge "Update clearData flow for notification settings" into qt-dev am: a2620b9c97
am: 76d5fb3f6c
Change-Id: Idbe1de34c738bf0b3a17ce9e68dfb3c67b151b9c
3 files changed, 49 insertions, 2 deletions
diff --git a/services/core/java/com/android/server/notification/NotificationManagerService.java b/services/core/java/com/android/server/notification/NotificationManagerService.java index 6c111570938b..3e3a4f2fde6c 100644 --- a/services/core/java/com/android/server/notification/NotificationManagerService.java +++ b/services/core/java/com/android/server/notification/NotificationManagerService.java @@ -2864,8 +2864,7 @@ public class NotificationManagerService extends SystemService { // Reset notification preferences if (!fromApp) { - mPreferencesHelper.onPackagesChanged( - true, UserHandle.getCallingUserId(), packages, uids); + mPreferencesHelper.clearData(packageName, uid); } handleSavePolicyFile(); diff --git a/services/core/java/com/android/server/notification/PreferencesHelper.java b/services/core/java/com/android/server/notification/PreferencesHelper.java index 642fa7fc3ba6..b57063f0584c 100644 --- a/services/core/java/com/android/server/notification/PreferencesHelper.java +++ b/services/core/java/com/android/server/notification/PreferencesHelper.java @@ -1717,6 +1717,22 @@ public class PreferencesHelper implements RankingConfig { } } + public void clearData(String pkg, int uid) { + synchronized (mPackagePreferences) { + PackagePreferences p = getPackagePreferencesLocked(pkg, uid); + p.channels = new ArrayMap<>(); + p.groups = new ArrayMap<>(); + p.delegate = null; + p.lockedAppFields = DEFAULT_LOCKED_APP_FIELDS; + p.allowBubble = DEFAULT_ALLOW_BUBBLE; + p.importance = DEFAULT_IMPORTANCE; + p.priority = DEFAULT_PRIORITY; + p.visibility = DEFAULT_VISIBILITY; + p.showBadge = DEFAULT_SHOW_BADGE; + + } + } + private LogMaker getChannelLog(NotificationChannel channel, String pkg) { return new LogMaker( com.android.internal.logging.nano.MetricsProto.MetricsEvent diff --git a/services/tests/uiservicestests/src/com/android/server/notification/PreferencesHelperTest.java b/services/tests/uiservicestests/src/com/android/server/notification/PreferencesHelperTest.java index b34bd2595287..1a06490195aa 100644 --- a/services/tests/uiservicestests/src/com/android/server/notification/PreferencesHelperTest.java +++ b/services/tests/uiservicestests/src/com/android/server/notification/PreferencesHelperTest.java @@ -1644,6 +1644,38 @@ public class PreferencesHelperTest extends UiServiceTestCase { } @Test + public void testClearData() { + ArraySet<String> pkg = new ArraySet<>(); + pkg.add(PKG_O); + mHelper.createNotificationChannel(PKG_O, UID_O, getChannel(), true, false); + mHelper.createNotificationChannelGroup( + PKG_O, UID_O, new NotificationChannelGroup("1", "bye"), true); + mHelper.lockChannelsForOEM(pkg.toArray(new String[]{})); + mHelper.updateDefaultApps(UserHandle.getUserId(UID_O), null, pkg); + mHelper.setNotificationDelegate(PKG_O, UID_O, "", 1); + mHelper.setImportance(PKG_O, UID_O, IMPORTANCE_NONE); + mHelper.setBubblesAllowed(PKG_O, UID_O, false); + mHelper.setShowBadge(PKG_O, UID_O, false); + mHelper.setAppImportanceLocked(PKG_O, UID_O); + + mHelper.clearData(PKG_O, UID_O); + + assertEquals(IMPORTANCE_UNSPECIFIED, mHelper.getImportance(PKG_O, UID_O)); + assertTrue(mHelper.areBubblesAllowed(PKG_O, UID_O)); + assertTrue(mHelper.canShowBadge(PKG_O, UID_O)); + assertNull(mHelper.getNotificationDelegate(PKG_O, UID_O)); + assertEquals(0, mHelper.getAppLockedFields(PKG_O, UID_O)); + assertEquals(0, mHelper.getNotificationChannels(PKG_O, UID_O, true).getList().size()); + assertEquals(0, mHelper.getNotificationChannelGroups(PKG_O, UID_O).size()); + + NotificationChannel channel = getChannel(); + mHelper.createNotificationChannel(PKG_O, UID_O, channel, true, false); + + assertTrue(channel.isImportanceLockedByCriticalDeviceFunction()); + assertTrue(channel.isImportanceLockedByOEM()); + } + + @Test public void testRecordDefaults() throws Exception { assertEquals(NotificationManager.IMPORTANCE_UNSPECIFIED, mHelper.getImportance(PKG_N_MR1, UID_N_MR1)); |