summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xservices/core/java/com/android/server/notification/NotificationManagerService.java13
-rw-r--r--services/tests/uiservicestests/src/com/android/server/notification/NotificationAssistantsTest.java19
2 files changed, 32 insertions, 0 deletions
diff --git a/services/core/java/com/android/server/notification/NotificationManagerService.java b/services/core/java/com/android/server/notification/NotificationManagerService.java
index cee40e2991b8..0a1b16107a42 100755
--- a/services/core/java/com/android/server/notification/NotificationManagerService.java
+++ b/services/core/java/com/android/server/notification/NotificationManagerService.java
@@ -9473,6 +9473,19 @@ public class NotificationManagerService extends SystemService {
}
}
+ @Override
+ protected void addApprovedList(String approved, int userId, boolean isPrimary,
+ String userSet) {
+ if (!TextUtils.isEmpty(approved)) {
+ String[] approvedArray = approved.split(ENABLED_SERVICES_SEPARATOR);
+ if (approvedArray.length > 1) {
+ Slog.d(TAG, "More than one approved assistants");
+ approved = approvedArray[0];
+ }
+ }
+ super.addApprovedList(approved, userId, isPrimary, userSet);
+ }
+
public NotificationAssistants(Context context, Object lock, UserProfiles up,
IPackageManager pm) {
super(context, lock, up, pm);
diff --git a/services/tests/uiservicestests/src/com/android/server/notification/NotificationAssistantsTest.java b/services/tests/uiservicestests/src/com/android/server/notification/NotificationAssistantsTest.java
index feb924ce6cfa..054a401d41af 100644
--- a/services/tests/uiservicestests/src/com/android/server/notification/NotificationAssistantsTest.java
+++ b/services/tests/uiservicestests/src/com/android/server/notification/NotificationAssistantsTest.java
@@ -178,6 +178,25 @@ public class NotificationAssistantsTest extends UiServiceTestCase {
}
@Test
+ public void testReadXml_multiApproved() throws Exception {
+ String xml = "<enabled_assistants version=\"4\" defaults=\"b/b\">"
+ + "<service_listing approved=\"a/a:b/b\" user=\"0\" primary=\"true\""
+ + "user_changed=\"true\"/>"
+ + "</enabled_assistants>";
+
+ final TypedXmlPullParser parser = Xml.newFastPullParser();
+ parser.setInput(new BufferedInputStream(
+ new ByteArrayInputStream(xml.toString().getBytes())), null);
+
+ parser.nextTag();
+ mAssistants.readXml(parser, null, false, UserHandle.USER_ALL);
+
+ assertEquals(1, mAssistants.getAllowedComponents(0).size());
+ assertEquals(new ArrayList(Arrays.asList(new ComponentName("a", "a"))),
+ mAssistants.getAllowedComponents(0));
+ }
+
+ @Test
public void testXmlUpgradeExistingApprovedComponents() throws Exception {
String xml = "<enabled_assistants version=\"2\" defaults=\"b\\b\">"
+ "<service_listing approved=\"b/b\" user=\"10\" primary=\"true\" />"