From 418a8ff9f8fe3b982faf0620fe75ec62197a65e3 Mon Sep 17 00:00:00 2001 From: Julia Reynolds Date: Thu, 21 Mar 2019 10:45:10 -0400 Subject: [PATCH] Ignore disallowed adjustments Test: xts Bug: 127825514 Change-Id: I82da0ca798f164dc9a2954e8fb78597480d5e76b --- .../notification/NotificationManagerService.java | 14 +++++++++++--- .../NotificationManagerServiceTest.java | 3 ++- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/services/core/java/com/android/server/notification/NotificationManagerService.java b/services/core/java/com/android/server/notification/NotificationManagerService.java index ca3c826d77ddb..e43fc1f057b0a 100644 --- a/services/core/java/com/android/server/notification/NotificationManagerService.java +++ b/services/core/java/com/android/server/notification/NotificationManagerService.java @@ -4106,9 +4106,11 @@ public class NotificationManagerService extends SystemService { if (r == null) { return; } - if (adjustment.getSignals() != null) { - Bundle.setDefusable(adjustment.getSignals(), true); - r.addAdjustment(adjustment); + if (mAssistants.isAdjustmentAllowed(adjustment.getKey())) { + if (adjustment.getSignals() != null) { + Bundle.setDefusable(adjustment.getSignals(), true); + r.addAdjustment(adjustment); + } } } @@ -7313,6 +7315,12 @@ public class NotificationManagerService extends SystemService { } } + protected boolean isAdjustmentAllowed(String type) { + synchronized (mLock) { + return mAllowedAdjustments.contains(type); + } + } + protected void onNotificationsSeenLocked(ArrayList records) { // There should be only one, but it's a list, so while we enforce // singularity elsewhere, we keep it general here, to avoid surprises. diff --git a/services/tests/uiservicestests/src/com/android/server/notification/NotificationManagerServiceTest.java b/services/tests/uiservicestests/src/com/android/server/notification/NotificationManagerServiceTest.java index a8da80efa35fc..426122a830f12 100644 --- a/services/tests/uiservicestests/src/com/android/server/notification/NotificationManagerServiceTest.java +++ b/services/tests/uiservicestests/src/com/android/server/notification/NotificationManagerServiceTest.java @@ -353,7 +353,6 @@ public class NotificationManagerServiceTest extends UiServiceTestCase { FileOutputStream fos = mPolicyFile.startWrite(); fos.write(preupgradeXml.getBytes()); mPolicyFile.finishWrite(fos); - FileInputStream fStream = new FileInputStream(mFile); // Setup managed services mListener = mListeners.new ManagedServiceInfo( @@ -369,6 +368,8 @@ public class NotificationManagerServiceTest extends UiServiceTestCase { dndConfig.xmlTag = ConditionProviders.TAG_ENABLED_DND_APPS; when(mConditionProviders.getConfig()).thenReturn(dndConfig); + when(mAssistants.isAdjustmentAllowed(anyString())).thenReturn(true); + try { mService.init(mTestableLooper.getLooper(), mPackageManager, mPackageManagerClient, mockLightsManager,