Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 7eb3a2db authored by Charlie Wang's avatar Charlie Wang Committed by Android (Google) Code Review
Browse files

Merge "Address failing tests for CtsMultiUserHostTest."

parents d65df22f ae8d3d62
Loading
Loading
Loading
Loading
+22 −5
Original line number Diff line number Diff line
@@ -219,11 +219,10 @@ public class AmbientContextManagerService extends

        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 @@ public class AmbientContextManagerService extends
                        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 @@ public class AmbientContextManagerService extends
        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: "