Create CarPropertyService and CarPropertyManager
CarPropertyService replaces Cabin, Hvac, Info, Sensor,
and VendorExtension services.
Bug: 78782959
Bug: 36649684
Bug: 68056035
Test: runtest -x packages/services/Car/tests/android_car_api_test
runtest -x packages/services/Car/tests/carservice_unit_test
Change-Id: Ic0a94805f83cc0222fb2bcf9674b6031bc050986
(cherry picked from commit c9ee6cda8a5ed73d82a0cdbd0e3154d76ec3db01)
diff --git a/service/src/com/android/car/ICarImpl.java b/service/src/com/android/car/ICarImpl.java
index 9db071b..6c2ba36 100644
--- a/service/src/com/android/car/ICarImpl.java
+++ b/service/src/com/android/car/ICarImpl.java
@@ -61,21 +61,17 @@
private final CarPowerManagementService mCarPowerManagementService;
private final CarPackageManagerService mCarPackageManagerService;
private final CarInputService mCarInputService;
- private final CarSensorService mCarSensorService;
private final CarDrivingStateService mCarDrivingStateService;
private final CarUxRestrictionsManagerService mCarUXRestrictionsService;
- private final CarInfoService mCarInfoService;
private final CarAudioService mCarAudioService;
private final CarProjectionService mCarProjectionService;
- private final CarCabinService mCarCabinService;
- private final CarHvacService mCarHvacService;
+ private final CarPropertyService mCarPropertyService;
private final CarNightService mCarNightService;
private final AppFocusService mAppFocusService;
private final GarageModeService mGarageModeService;
private final InstrumentClusterService mInstrumentClusterService;
private final CarLocationService mCarLocationService;
private final SystemStateControllerService mSystemStateControllerService;
- private final CarVendorExtensionService mCarVendorExtensionService;
private final CarBluetoothService mCarBluetoothService;
private final PerUserCarServiceHelper mPerUserCarServiceHelper;
private final CarDiagnosticService mCarDiagnosticService;
@@ -110,10 +106,10 @@
mSystemActivityMonitoringService = new SystemActivityMonitoringService(serviceContext);
mCarPowerManagementService = new CarPowerManagementService(mContext, mHal.getPowerHal(),
systemInterface);
- mCarSensorService = new CarSensorService(serviceContext, mHal.getSensorHal());
- mCarDrivingStateService = new CarDrivingStateService(serviceContext, mCarSensorService);
+ mCarPropertyService = new CarPropertyService(serviceContext, mHal.getPropertyHal());
+ mCarDrivingStateService = new CarDrivingStateService(serviceContext, mCarPropertyService);
mCarUXRestrictionsService = new CarUxRestrictionsManagerService(serviceContext,
- mCarDrivingStateService, mCarSensorService);
+ mCarDrivingStateService, mCarPropertyService);
mCarPackageManagerService = new CarPackageManagerService(serviceContext,
mCarUXRestrictionsService,
mSystemActivityMonitoringService);
@@ -121,22 +117,17 @@
mCarProjectionService = new CarProjectionService(serviceContext, mCarInputService);
mGarageModeService = new GarageModeService(mContext, mCarPowerManagementService);
mCarLocationService = new CarLocationService(mContext, mCarPowerManagementService,
- mCarSensorService);
- mCarInfoService = new CarInfoService(serviceContext, mHal.getInfoHal());
+ mCarPropertyService);
mAppFocusService = new AppFocusService(serviceContext, mSystemActivityMonitoringService);
mCarAudioService = new CarAudioService(serviceContext);
- mCarCabinService = new CarCabinService(serviceContext, mHal.getCabinHal());
- mCarHvacService = new CarHvacService(serviceContext, mHal.getHvacHal());
- mCarNightService = new CarNightService(serviceContext, mCarSensorService);
+ mCarNightService = new CarNightService(serviceContext, mCarPropertyService);
mInstrumentClusterService = new InstrumentClusterService(serviceContext,
mAppFocusService, mCarInputService);
mSystemStateControllerService = new SystemStateControllerService(serviceContext,
mCarPowerManagementService, mCarAudioService, this);
- mCarVendorExtensionService = new CarVendorExtensionService(serviceContext,
- mHal.getVendorExtensionHal());
mPerUserCarServiceHelper = new PerUserCarServiceHelper(serviceContext);
- mCarBluetoothService = new CarBluetoothService(serviceContext, mCarCabinService,
- mCarSensorService, mPerUserCarServiceHelper, mCarUXRestrictionsService);
+ mCarBluetoothService = new CarBluetoothService(serviceContext, mCarPropertyService,
+ mPerUserCarServiceHelper, mCarUXRestrictionsService);
mVmsSubscriberService = new VmsSubscriberService(serviceContext, mHal.getVmsHal());
mVmsPublisherService = new VmsPublisherService(serviceContext, mHal.getVmsHal());
mCarDiagnosticService = new CarDiagnosticService(serviceContext, mHal.getDiagnosticHal());
@@ -149,23 +140,19 @@
mAllServices = new CarServiceBase[] {
mSystemActivityMonitoringService,
mCarPowerManagementService,
- mCarSensorService,
+ mCarPropertyService,
mCarDrivingStateService,
mCarUXRestrictionsService,
mCarPackageManagerService,
mCarInputService,
mCarLocationService,
mGarageModeService,
- mCarInfoService,
mAppFocusService,
mCarAudioService,
- mCarCabinService,
- mCarHvacService,
mCarNightService,
mInstrumentClusterService,
mCarProjectionService,
mSystemStateControllerService,
- mCarVendorExtensionService,
mCarBluetoothService,
mCarDiagnosticService,
mPerUserCarServiceHelper,
@@ -220,26 +207,23 @@
switch (serviceName) {
case Car.AUDIO_SERVICE:
return mCarAudioService;
- case Car.SENSOR_SERVICE:
- return mCarSensorService;
- case Car.INFO_SERVICE:
- return mCarInfoService;
case Car.APP_FOCUS_SERVICE:
return mAppFocusService;
case Car.PACKAGE_SERVICE:
return mCarPackageManagerService;
- case Car.CABIN_SERVICE:
- assertCabinPermission(mContext);
- return mCarCabinService;
case Car.DIAGNOSTIC_SERVICE:
assertAnyDiagnosticPermission(mContext);
return mCarDiagnosticService;
- case Car.HVAC_SERVICE:
- assertHvacPermission(mContext);
- return mCarHvacService;
case Car.POWER_SERVICE:
assertPowerPermission(mContext);
return mCarPowerManagementService;
+ case Car.CABIN_SERVICE:
+ case Car.HVAC_SERVICE:
+ case Car.INFO_SERVICE:
+ case Car.PROPERTY_SERVICE:
+ case Car.SENSOR_SERVICE:
+ case Car.VENDOR_EXTENSION_SERVICE:
+ return mCarPropertyService;
case Car.CAR_NAVIGATION_SERVICE:
assertNavigationManagerPermission(mContext);
IInstrumentClusterNavigation navService =
@@ -251,9 +235,6 @@
case Car.PROJECTION_SERVICE:
assertProjectionPermission(mContext);
return mCarProjectionService;
- case Car.VENDOR_EXTENSION_SERVICE:
- assertVendorExtensionPermission(mContext);
- return mCarVendorExtensionService;
case Car.VMS_SUBSCRIBER_SERVICE:
assertVmsSubscriberPermission(mContext);
return mVmsSubscriberService;
@@ -306,10 +287,6 @@
assertPermission(context, Car.PERMISSION_MOCK_VEHICLE_HAL);
}
- public static void assertCabinPermission(Context context) {
- assertPermission(context, Car.PERMISSION_ADJUST_CAR_CABIN);
- }
-
public static void assertNavigationManagerPermission(Context context) {
assertPermission(context, Car.PERMISSION_CAR_NAVIGATION_MANAGER);
}
@@ -318,10 +295,6 @@
assertPermission(context, Car.PERMISSION_CAR_INSTRUMENT_CLUSTER_CONTROL);
}
- public static void assertHvacPermission(Context context) {
- assertPermission(context, Car.PERMISSION_CONTROL_CAR_CLIMATE);
- }
-
public static void assertPowerPermission(Context context) {
assertPermission(context, Car.PERMISSION_CAR_POWER);
}
@@ -330,10 +303,6 @@
assertPermission(context, Car.PERMISSION_CAR_PROJECTION);
}
- public static void assertVendorExtensionPermission(Context context) {
- assertPermission(context, Car.PERMISSION_VENDOR_EXTENSION);
- }
-
public static void assertAnyDiagnosticPermission(Context context) {
assertAnyPermission(context,
Car.PERMISSION_CAR_DIAGNOSTIC_READ_ALL,
@@ -358,6 +327,18 @@
}
}
+ /**
+ * Checks to see if the caller has a permission.
+ * @param context
+ * @param permission
+ *
+ * @return boolean TRUE if caller has the permission.
+ */
+ public static boolean hasPermission(Context context, String permission) {
+ return context.checkCallingOrSelfPermission(permission)
+ == PackageManager.PERMISSION_GRANTED;
+ }
+
public static void assertAnyPermission(Context context, String... permissions) {
for (String permission : permissions) {
if (context.checkCallingOrSelfPermission(permission) ==