Add user 0 unlock monitoring to postpone user 0 data access
- Car service and services launched from it are starting while user 0 data is not ready.
- Access to user0 data should be postponed until user0 is unlocked.
- More changes to postpone access will be added as separate CL.
Only instrument cluster service is changed as an example test case.
Bug: 124223557
Test: boot up and check crash / logs for data access
Change-Id: I7e610792742f0ad7b93b3bcf4caedb4f0c8b6d17
diff --git a/service/src/com/android/car/ICarImpl.java b/service/src/com/android/car/ICarImpl.java
index e2176d3..e02c65c 100644
--- a/service/src/com/android/car/ICarImpl.java
+++ b/service/src/com/android/car/ICarImpl.java
@@ -86,9 +86,8 @@
private final CarStorageMonitoringService mCarStorageMonitoringService;
private final CarConfigurationService mCarConfigurationService;
private final CarTrustAgentEnrollmentService mCarTrustAgentEnrollmentService;
-
private final CarUserManagerHelper mUserManagerHelper;
- private CarUserService mCarUserService;
+ private final CarUserService mCarUserService;
private final VmsClientManager mVmsClientManager;
private final VmsSubscriberService mVmsSubscriberService;
private final VmsPublisherService mVmsPublisherService;
@@ -116,6 +115,7 @@
mHal = new VehicleHal(vehicle);
mVehicleInterfaceName = vehicleInterfaceName;
mUserManagerHelper = new CarUserManagerHelper(serviceContext);
+ mCarUserService = new CarUserService(serviceContext, mUserManagerHelper);
mSystemActivityMonitoringService = new SystemActivityMonitoringService(serviceContext);
mCarPowerManagementService = new CarPowerManagementService(mContext, mHal.getPowerHal(),
systemInterface);
@@ -153,8 +153,11 @@
mContext, mCarPropertyService, mUserManagerHelper);
mCarTrustAgentEnrollmentService = new CarTrustAgentEnrollmentService(serviceContext);
+ CarLocalServices.addService(CarUserService.class, mCarUserService);
+
// Be careful with order. Service depending on other service should be inited later.
List<CarServiceBase> allServices = new ArrayList<>();
+ allServices.add(mCarUserService);
allServices.add(mSystemActivityMonitoringService);
allServices.add(mCarPowerManagementService);
allServices.add(mCarPropertyService);
@@ -178,9 +181,6 @@
allServices.add(mVmsSubscriberService);
allServices.add(mVmsPublisherService);
allServices.add(mCarTrustAgentEnrollmentService);
- if (mUserManagerHelper.isHeadlessSystemUser()) {
- allServices.add(new CarUserService(serviceContext, mUserManagerHelper));
- }
allServices.add(mCarLocationService);
mAllServices = allServices.toArray(new CarServiceBase[allServices.size()]);
}
@@ -204,6 +204,7 @@
mAllServices[i].release();
}
mHal.release();
+ CarLocalServices.removeAllServices();
}
void vehicleHalReconnected(IVehicle vehicle) {
@@ -226,6 +227,15 @@
}
@Override
+ public void setUserLockStatus(int userHandle, int unlocked) {
+ int uid = Binder.getCallingUid();
+ if (uid != Process.SYSTEM_UID) {
+ throw new SecurityException("Only allowed from system");
+ }
+ mCarUserService.setUserLockStatus(userHandle, unlocked == 1);
+ }
+
+ @Override
public IBinder getCarService(String serviceName) {
switch (serviceName) {
case Car.AUDIO_SERVICE: