Make TrustAgentEnrollmentMgr available through Car API.
Instantiate the service from ICarImpl and make the Manager available
through car.getCarManager().
Bug: 122831352
Test: Ensure the new manager is available from car.getCarManager() API.
Change-Id: I4e8c906588b4ad37294a8537a275ea22ba072e72
diff --git a/car-lib/api/system-current.txt b/car-lib/api/system-current.txt
index d7305a8..a5965e9 100644
--- a/car-lib/api/system-current.txt
+++ b/car-lib/api/system-current.txt
@@ -3,6 +3,7 @@
public final class Car {
field public static final java.lang.String CABIN_SERVICE = "cabin";
field public static final java.lang.String CAR_DRIVING_STATE_SERVICE = "drivingstate";
+ field public static final java.lang.String CAR_TRUST_AGENT_ENROLLMENT_SERVICE = "trust_enroll";
field public static final java.lang.String DIAGNOSTIC_SERVICE = "diagnostic";
field public static final java.lang.String HVAC_SERVICE = "hvac";
field public static final java.lang.String PERMISSION_CAR_DIAGNOSTIC_CLEAR = "android.car.permission.CLEAR_CAR_DIAGNOSTICS";
diff --git a/car-lib/src/android/car/Car.java b/car-lib/src/android/car/Car.java
index 940c518..85f0ca5 100644
--- a/car-lib/src/android/car/Car.java
+++ b/car-lib/src/android/car/Car.java
@@ -35,6 +35,7 @@
import android.car.settings.CarConfigurationManager;
import android.car.storagemonitoring.CarStorageMonitoringManager;
import android.car.test.CarTestManagerBinderWrapper;
+import android.car.trust.CarTrustAgentEnrollmentManager;
import android.car.vms.VmsSubscriberManager;
import android.content.ComponentName;
import android.content.Context;
@@ -171,6 +172,13 @@
public static final String STORAGE_MONITORING_SERVICE = "storage_monitoring";
/**
+ * Service name for {@link android.car.trust.CarTrustAgentEnrollmentManager}
+ * @hide
+ */
+ @SystemApi
+ public static final String CAR_TRUST_AGENT_ENROLLMENT_SERVICE = "trust_enroll";
+
+ /**
* Service for testing. This is system app only feature.
* Service name for {@link CarTestManager}, to be used in {@link #getCarManager(String)}.
* @hide
@@ -720,6 +728,7 @@
* @return Matching service manager or null if there is no such service.
* @throws CarNotConnectedException if the connection to the car service has been lost.
*/
+ @Nullable
public Object getCarManager(String serviceName) throws CarNotConnectedException {
CarManagerBase manager;
ICar service = getICarOrThrow();
@@ -788,6 +797,7 @@
}
}
+ @Nullable
private CarManagerBase createCarManager(String serviceName, IBinder binder)
throws CarNotConnectedException {
CarManagerBase manager = null;
@@ -858,6 +868,9 @@
case CAR_CONFIGURATION_SERVICE:
manager = new CarConfigurationManager(binder);
break;
+ case CAR_TRUST_AGENT_ENROLLMENT_SERVICE:
+ manager = new CarTrustAgentEnrollmentManager(binder, mContext, mEventHandler);
+ break;
default:
break;
}
diff --git a/service/src/com/android/car/ICarImpl.java b/service/src/com/android/car/ICarImpl.java
index e3381a3..adcedf3 100644
--- a/service/src/com/android/car/ICarImpl.java
+++ b/service/src/com/android/car/ICarImpl.java
@@ -42,6 +42,7 @@
import com.android.car.internal.FeatureConfiguration;
import com.android.car.pm.CarPackageManagerService;
import com.android.car.systeminterface.SystemInterface;
+import com.android.car.trust.CarTrustAgentEnrollmentService;
import com.android.car.user.CarUserService;
import com.android.internal.annotations.GuardedBy;
import com.android.internal.car.ICarServiceHelper;
@@ -83,6 +84,7 @@
private final CarDiagnosticService mCarDiagnosticService;
private final CarStorageMonitoringService mCarStorageMonitoringService;
private final CarConfigurationService mCarConfigurationService;
+ private final CarTrustAgentEnrollmentService mCarTrustAgentEnrollmentService;
private final CarUserManagerHelper mUserManagerHelper;
private CarUserService mCarUserService;
@@ -144,6 +146,7 @@
new CarConfigurationService(serviceContext, new JsonReaderImpl());
mCarLocationService = new CarLocationService(
mContext, mCarPropertyService, mUserManagerHelper);
+ mCarTrustAgentEnrollmentService = new CarTrustAgentEnrollmentService(serviceContext);
// Be careful with order. Service depending on other service should be inited later.
List<CarServiceBase> allServices = new ArrayList<>();
@@ -168,6 +171,7 @@
allServices.add(mCarConfigurationService);
allServices.add(mVmsSubscriberService);
allServices.add(mVmsPublisherService);
+ allServices.add(mCarTrustAgentEnrollmentService);
if (mUserManagerHelper.isHeadlessSystemUser()) {
allServices.add(new CarUserService(serviceContext, mUserManagerHelper));
}
@@ -272,6 +276,9 @@
return mCarUXRestrictionsService;
case Car.CAR_CONFIGURATION_SERVICE:
return mCarConfigurationService;
+ case Car.CAR_TRUST_AGENT_ENROLLMENT_SERVICE:
+ assertTrustAgentEnrollmentPermission(mContext);
+ return mCarTrustAgentEnrollmentService;
default:
Log.w(CarLog.TAG_SERVICE, "getCarService for unknown service:" + serviceName);
return null;
@@ -334,6 +341,14 @@
assertPermission(context, Car.PERMISSION_VMS_SUBSCRIBER);
}
+ /**
+ * Ensures the caller has the permission to enroll a Trust Agent.
+ * @param context
+ */
+ public static void assertTrustAgentEnrollmentPermission(Context context) {
+ assertPermission(context, Car.PERMISSION_CAR_ENROLL_TRUST);
+ }
+
public static void assertPermission(Context context, String permission) {
if (context.checkCallingOrSelfPermission(permission) != PackageManager.PERMISSION_GRANTED) {
throw new SecurityException("requires " + permission);