Merge "Address failing tests for CtsMultiUserHostTest."
diff --git a/services/core/java/com/android/server/ambientcontext/AmbientContextManagerService.java b/services/core/java/com/android/server/ambientcontext/AmbientContextManagerService.java
index a0c7ee6..5c18827 100644
--- a/services/core/java/com/android/server/ambientcontext/AmbientContextManagerService.java
+++ b/services/core/java/com/android/server/ambientcontext/AmbientContextManagerService.java
@@ -219,11 +219,10 @@
List<AmbientContextManagerPerUserService> serviceList =
new ArrayList<>(serviceNames.length);
- if (!isDefaultServiceEnabled(resolvedUserId)) {
+ if (serviceNames.length == 2) {
Slog.i(TAG, "Not using default services, "
+ "services provided for testing should be exactly two services.");
- if (serviceNames.length == 2) {
- // Expecting two services for testing, first being the default and second wearable.
+ if (!isDefaultService(serviceNames[0]) && !isDefaultWearableService(serviceNames[1])) {
serviceList.add(new DefaultAmbientContextManagerPerUserService(
this, mLock, resolvedUserId,
AmbientContextManagerPerUserService.ServiceType.DEFAULT, serviceNames[0]));
@@ -231,10 +230,10 @@
this, mLock, resolvedUserId,
AmbientContextManagerPerUserService.ServiceType.WEARABLE,
serviceNames[1]));
- } else {
- Slog.i(TAG, "Incorrect number of services provided for testing.");
}
return serviceList;
+ } else {
+ Slog.i(TAG, "Incorrect number of services provided for testing.");
}
for (String serviceName : serviceNames) {
@@ -428,6 +427,24 @@
return AmbientContextManagerPerUserService.ServiceType.DEFAULT;
}
+ private boolean isDefaultService(String serviceName) {
+ final String defaultService = mContext.getResources()
+ .getString(R.string.config_defaultAmbientContextDetectionService);
+ if (defaultService != null && defaultService.equals(serviceName)) {
+ return true;
+ }
+ return false;
+ }
+
+ private boolean isDefaultWearableService(String serviceName) {
+ final String wearableService = mContext.getResources()
+ .getString(R.string.config_defaultWearableSensingService);
+ if (wearableService != null && wearableService.equals(serviceName)) {
+ return true;
+ }
+ return false;
+ }
+
private AmbientContextManagerPerUserService getServiceForType(int userId,
AmbientContextManagerPerUserService.ServiceType serviceType) {
Slog.d(TAG, "getServiceForType with userid: "