Add CarGenericManager and refactor HVAC to use it
Change-Id: I0af862f8da2259069a5be0d17efb1f82a208fa76
diff --git a/service/src/com/android/car/ICarImpl.java b/service/src/com/android/car/ICarImpl.java
index 7d34f2b..05e8f59 100644
--- a/service/src/com/android/car/ICarImpl.java
+++ b/service/src/com/android/car/ICarImpl.java
@@ -245,49 +245,32 @@
}
public static void assertVehicleHalMockPermission(Context context) {
- if (context.checkCallingOrSelfPermission(Car.PERMISSION_MOCK_VEHICLE_HAL)
- != PackageManager.PERMISSION_GRANTED) {
- throw new SecurityException("requires CAR_MOCK_VEHICLE_HAL permission");
- }
+ assertPermission(context, Car.PERMISSION_MOCK_VEHICLE_HAL);
}
public static void assertCameraPermission(Context context) {
- if (context.checkCallingOrSelfPermission(Car.PERMISSION_CAR_CAMERA)
- != PackageManager.PERMISSION_GRANTED) {
- throw new SecurityException(
- "requires " + Car.PERMISSION_CAR_CAMERA);
- }
+ assertPermission(context, Car.PERMISSION_CAR_CAMERA);
}
public static void assertNavigationManagerPermission(Context context) {
- if (context.checkCallingOrSelfPermission(Car.PERMISSION_CAR_NAVIGATION_MANAGER)
- != PackageManager.PERMISSION_GRANTED) {
- throw new SecurityException(
- "requires " + Car.PERMISSION_CAR_NAVIGATION_MANAGER);
- }
+ assertPermission(context, Car.PERMISSION_CAR_NAVIGATION_MANAGER);
}
public static void assertHvacPermission(Context context) {
- if (context.checkCallingOrSelfPermission(Car.PERMISSION_CAR_HVAC)
- != PackageManager.PERMISSION_GRANTED) {
- throw new SecurityException(
- "requires " + Car.PERMISSION_CAR_HVAC);
- }
+ assertPermission(context, Car.PERMISSION_CAR_HVAC);
}
private static void assertRadioPermission(Context context) {
- if (context.checkCallingOrSelfPermission(Car.PERMISSION_CAR_RADIO)
- != PackageManager.PERMISSION_GRANTED) {
- throw new SecurityException(
- "requires permission " + Car.PERMISSION_CAR_RADIO);
- }
+ assertPermission(context, Car.PERMISSION_CAR_RADIO);
}
public static void assertProjectionPermission(Context context) {
- if (context.checkCallingOrSelfPermission(Car.PERMISSION_CAR_PROJECTION)
- != PackageManager.PERMISSION_GRANTED) {
- throw new SecurityException(
- "requires " + Car.PERMISSION_CAR_PROJECTION);
+ assertPermission(context, Car.PERMISSION_CAR_PROJECTION);
+ }
+
+ public static void assertPermission(Context context, String permission) {
+ if (context.checkCallingOrSelfPermission(permission) != PackageManager.PERMISSION_GRANTED) {
+ throw new SecurityException("requires " + permission);
}
}