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/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);