summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Jay Aliomer <aaliomer@google.com> 2019-11-20 23:04:09 +0000
committer Android (Google) Code Review <android-gerrit@google.com> 2019-11-20 23:04:09 +0000
commita91e08f613f99b00ef518553f95dc97296813df9 (patch)
tree5bd423a41ab7fbe3ce33cddc0100f110abab321f
parent3688876ae6523214306db8994836d13d6e4bf754 (diff)
parent8ff1f0ac8a6bb26d3dd9de1e3941b54319990513 (diff)
Merge "Revert "Override default assistant""
-rwxr-xr-xservices/core/java/com/android/server/notification/NotificationManagerService.java15
-rwxr-xr-xservices/tests/uiservicestests/src/com/android/server/notification/NotificationManagerServiceTest.java38
2 files changed, 12 insertions, 41 deletions
diff --git a/services/core/java/com/android/server/notification/NotificationManagerService.java b/services/core/java/com/android/server/notification/NotificationManagerService.java
index c8b7570fa6e2..0ae4a8fdf297 100755
--- a/services/core/java/com/android/server/notification/NotificationManagerService.java
+++ b/services/core/java/com/android/server/notification/NotificationManagerService.java
@@ -573,6 +573,13 @@ public class NotificationManagerService extends SystemService {
ArraySet<String> assistants = new ArraySet<>();
+ String deviceAssistant = DeviceConfig.getProperty(
+ DeviceConfig.NAMESPACE_SYSTEMUI,
+ SystemUiDeviceConfigFlags.NAS_DEFAULT_SERVICE);
+ if (deviceAssistant != null) {
+ assistants.addAll(Arrays.asList(deviceAssistant.split(
+ ManagedServices.ENABLED_SERVICES_SEPARATOR)));
+ }
assistants.addAll(Arrays.asList(getContext().getResources().getString(
com.android.internal.R.string.config_defaultAssistantAccessComponent)
.split(ManagedServices.ENABLED_SERVICES_SEPARATOR)));
@@ -604,9 +611,11 @@ public class NotificationManagerService extends SystemService {
String overrideDefaultAssistantString = DeviceConfig.getProperty(
DeviceConfig.NAMESPACE_SYSTEMUI,
SystemUiDeviceConfigFlags.NAS_DEFAULT_SERVICE);
- ComponentName overrideDefaultAssistant =
- ComponentName.unflattenFromString(overrideDefaultAssistantString);
- if (allowAssistant(userId, overrideDefaultAssistant)) return;
+ if (overrideDefaultAssistantString != null) {
+ ComponentName overrideDefaultAssistant =
+ ComponentName.unflattenFromString(overrideDefaultAssistantString);
+ if (allowAssistant(userId, overrideDefaultAssistant)) return;
+ }
ArraySet<ComponentName> defaults = mAssistants.getDefaultComponents();
// We should have only one default assistant by default
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 028ce5094651..4d0cfbc6ad11 100755
--- a/services/tests/uiservicestests/src/com/android/server/notification/NotificationManagerServiceTest.java
+++ b/services/tests/uiservicestests/src/com/android/server/notification/NotificationManagerServiceTest.java
@@ -57,7 +57,6 @@ import static junit.framework.Assert.assertNull;
import static junit.framework.Assert.assertTrue;
import static junit.framework.Assert.fail;
-import static org.mockito.ArgumentMatchers.isNull;
import static org.mockito.Matchers.anyBoolean;
import static org.mockito.Matchers.anyLong;
import static org.mockito.Matchers.anyString;
@@ -754,43 +753,6 @@ public class NotificationManagerServiceTest extends UiServiceTestCase {
}
@Test
- public void testDefaultAssistant_overrideDefault() {
- final int userId = 0;
- final String testComponent = "package/class";
- final List<UserInfo> userInfos = new ArrayList<>();
- userInfos.add(new UserInfo(0, "", 0));
- final ArraySet<ComponentName> validAssistants = new ArraySet<>();
- validAssistants.add(ComponentName.unflattenFromString(testComponent));
- final String originalComponent = DeviceConfig.getProperty(
- DeviceConfig.NAMESPACE_SYSTEMUI,
- SystemUiDeviceConfigFlags.NAS_DEFAULT_SERVICE
- );
- DeviceConfig.setProperty(
- DeviceConfig.NAMESPACE_SYSTEMUI,
- SystemUiDeviceConfigFlags.NAS_DEFAULT_SERVICE,
- testComponent,
- false
- );
- when(mActivityManager.isLowRamDevice()).thenReturn(false);
- when(mAssistants.queryPackageForServices(isNull(), anyInt(), anyInt()))
- .thenReturn(validAssistants);
- when(mAssistants.getDefaultComponents()).thenReturn(new ArraySet<>());
- when(mUm.getEnabledProfiles(anyInt())).thenReturn(userInfos);
-
- mService.setDefaultAssistantForUser(userId);
-
- verify(mAssistants).setPackageOrComponentEnabled(
- eq(testComponent), eq(userId), eq(true), eq(true));
-
- DeviceConfig.setProperty(
- DeviceConfig.NAMESPACE_SYSTEMUI,
- SystemUiDeviceConfigFlags.NAS_DEFAULT_SERVICE,
- originalComponent,
- false
- );
- }
-
- @Test
public void testCreateNotificationChannels_IdenticalChannelsInListIgnoresSecond()
throws Exception {
final NotificationChannel channel1 =