1/* 2 * Copyright (C) 2018 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17package com.android.car.hal; 18 19import android.annotation.Nullable; 20import android.car.Car; 21import android.hardware.automotive.vehicle.V2_0.VehicleProperty; 22import android.hardware.automotive.vehicle.V2_0.VehiclePropertyGroup; 23import android.util.Pair; 24import android.util.SparseArray; 25 26/** 27 * Helper class to define which property IDs are used by PropertyHalService. This class binds the 28 * read and write permissions to the property ID. 29 */ 30public class PropertyHalServiceIds { 31 // Index (key is propertyId, and the value is readPermission, writePermission 32 private final SparseArray<Pair<String, String>> mProps; 33 34 public PropertyHalServiceIds() { 35 mProps = new SparseArray<>(); 36 37 // Add propertyId and read/write permissions 38 // Cabin Properties 39 mProps.put(VehicleProperty.DOOR_POS, new Pair<>( 40 Car.PERMISSION_CONTROL_CAR_DOORS, 41 Car.PERMISSION_CONTROL_CAR_DOORS)); 42 mProps.put(VehicleProperty.DOOR_MOVE, new Pair<>( 43 Car.PERMISSION_CONTROL_CAR_DOORS, 44 Car.PERMISSION_CONTROL_CAR_DOORS)); 45 mProps.put(VehicleProperty.DOOR_LOCK, new Pair<>( 46 Car.PERMISSION_CONTROL_CAR_DOORS, 47 Car.PERMISSION_CONTROL_CAR_DOORS)); 48 mProps.put(VehicleProperty.MIRROR_Z_POS, new Pair<>( 49 Car.PERMISSION_CONTROL_CAR_MIRRORS, 50 Car.PERMISSION_CONTROL_CAR_MIRRORS)); 51 mProps.put(VehicleProperty.MIRROR_Z_MOVE, new Pair<>( 52 Car.PERMISSION_CONTROL_CAR_MIRRORS, 53 Car.PERMISSION_CONTROL_CAR_MIRRORS)); 54 mProps.put(VehicleProperty.MIRROR_Y_POS, new Pair<>( 55 Car.PERMISSION_CONTROL_CAR_MIRRORS, 56 Car.PERMISSION_CONTROL_CAR_MIRRORS)); 57 mProps.put(VehicleProperty.MIRROR_Y_MOVE, new Pair<>( 58 Car.PERMISSION_CONTROL_CAR_MIRRORS, 59 Car.PERMISSION_CONTROL_CAR_MIRRORS)); 60 mProps.put(VehicleProperty.MIRROR_LOCK, new Pair<>( 61 Car.PERMISSION_CONTROL_CAR_MIRRORS, 62 Car.PERMISSION_CONTROL_CAR_MIRRORS)); 63 mProps.put(VehicleProperty.MIRROR_FOLD, new Pair<>( 64 Car.PERMISSION_CONTROL_CAR_MIRRORS, 65 Car.PERMISSION_CONTROL_CAR_MIRRORS)); 66 mProps.put(VehicleProperty.SEAT_MEMORY_SELECT, new Pair<>( 67 Car.PERMISSION_CONTROL_CAR_SEATS, 68 Car.PERMISSION_CONTROL_CAR_SEATS)); 69 mProps.put(VehicleProperty.SEAT_MEMORY_SET, new Pair<>( 70 Car.PERMISSION_CONTROL_CAR_SEATS, 71 Car.PERMISSION_CONTROL_CAR_SEATS)); 72 mProps.put(VehicleProperty.SEAT_BELT_BUCKLED, new Pair<>( 73 Car.PERMISSION_CONTROL_CAR_SEATS, 74 Car.PERMISSION_CONTROL_CAR_SEATS)); 75 mProps.put(VehicleProperty.SEAT_BELT_HEIGHT_POS, new Pair<>( 76 Car.PERMISSION_CONTROL_CAR_SEATS, 77 Car.PERMISSION_CONTROL_CAR_SEATS)); 78 mProps.put(VehicleProperty.SEAT_BELT_HEIGHT_MOVE, new Pair<>( 79 Car.PERMISSION_CONTROL_CAR_SEATS, 80 Car.PERMISSION_CONTROL_CAR_SEATS)); 81 mProps.put(VehicleProperty.SEAT_FORE_AFT_POS, new Pair<>( 82 Car.PERMISSION_CONTROL_CAR_SEATS, 83 Car.PERMISSION_CONTROL_CAR_SEATS)); 84 mProps.put(VehicleProperty.SEAT_FORE_AFT_MOVE, new Pair<>( 85 Car.PERMISSION_CONTROL_CAR_SEATS, 86 Car.PERMISSION_CONTROL_CAR_SEATS)); 87 mProps.put(VehicleProperty.SEAT_BACKREST_ANGLE_1_POS, new Pair<>( 88 Car.PERMISSION_CONTROL_CAR_SEATS, 89 Car.PERMISSION_CONTROL_CAR_SEATS)); 90 mProps.put(VehicleProperty.SEAT_BACKREST_ANGLE_1_MOVE, new Pair<>( 91 Car.PERMISSION_CONTROL_CAR_SEATS, 92 Car.PERMISSION_CONTROL_CAR_SEATS)); 93 mProps.put(VehicleProperty.SEAT_BACKREST_ANGLE_2_POS, new Pair<>( 94 Car.PERMISSION_CONTROL_CAR_SEATS, 95 Car.PERMISSION_CONTROL_CAR_SEATS)); 96 mProps.put(VehicleProperty.SEAT_BACKREST_ANGLE_2_MOVE, new Pair<>( 97 Car.PERMISSION_CONTROL_CAR_SEATS, 98 Car.PERMISSION_CONTROL_CAR_SEATS)); 99 mProps.put(VehicleProperty.SEAT_HEIGHT_POS, new Pair<>( 100 Car.PERMISSION_CONTROL_CAR_SEATS, 101 Car.PERMISSION_CONTROL_CAR_SEATS)); 102 mProps.put(VehicleProperty.SEAT_HEIGHT_MOVE, new Pair<>( 103 Car.PERMISSION_CONTROL_CAR_SEATS, 104 Car.PERMISSION_CONTROL_CAR_SEATS)); 105 mProps.put(VehicleProperty.SEAT_DEPTH_POS, new Pair<>( 106 Car.PERMISSION_CONTROL_CAR_SEATS, 107 Car.PERMISSION_CONTROL_CAR_SEATS)); 108 mProps.put(VehicleProperty.SEAT_DEPTH_MOVE, new Pair<>( 109 Car.PERMISSION_CONTROL_CAR_SEATS, 110 Car.PERMISSION_CONTROL_CAR_SEATS)); 111 mProps.put(VehicleProperty.SEAT_TILT_POS, new Pair<>( 112 Car.PERMISSION_CONTROL_CAR_SEATS, 113 Car.PERMISSION_CONTROL_CAR_SEATS)); 114 mProps.put(VehicleProperty.SEAT_TILT_MOVE, new Pair<>( 115 Car.PERMISSION_CONTROL_CAR_SEATS, 116 Car.PERMISSION_CONTROL_CAR_SEATS)); 117 mProps.put(VehicleProperty.SEAT_LUMBAR_FORE_AFT_POS, new Pair<>( 118 Car.PERMISSION_CONTROL_CAR_SEATS, 119 Car.PERMISSION_CONTROL_CAR_SEATS)); 120 mProps.put(VehicleProperty.SEAT_LUMBAR_FORE_AFT_MOVE, new Pair<>( 121 Car.PERMISSION_CONTROL_CAR_SEATS, 122 Car.PERMISSION_CONTROL_CAR_SEATS)); 123 mProps.put(VehicleProperty.SEAT_LUMBAR_SIDE_SUPPORT_POS, new Pair<>( 124 Car.PERMISSION_CONTROL_CAR_SEATS, 125 Car.PERMISSION_CONTROL_CAR_SEATS)); 126 mProps.put(VehicleProperty.SEAT_LUMBAR_SIDE_SUPPORT_MOVE, new Pair<>( 127 Car.PERMISSION_CONTROL_CAR_SEATS, 128 Car.PERMISSION_CONTROL_CAR_SEATS)); 129 mProps.put(VehicleProperty.SEAT_HEADREST_HEIGHT_POS, new Pair<>( 130 Car.PERMISSION_CONTROL_CAR_SEATS, 131 Car.PERMISSION_CONTROL_CAR_SEATS)); 132 mProps.put(VehicleProperty.SEAT_HEADREST_HEIGHT_MOVE, new Pair<>( 133 Car.PERMISSION_CONTROL_CAR_SEATS, 134 Car.PERMISSION_CONTROL_CAR_SEATS)); 135 mProps.put(VehicleProperty.SEAT_HEADREST_ANGLE_POS, new Pair<>( 136 Car.PERMISSION_CONTROL_CAR_SEATS, 137 Car.PERMISSION_CONTROL_CAR_SEATS)); 138 mProps.put(VehicleProperty.SEAT_HEADREST_ANGLE_MOVE, new Pair<>( 139 Car.PERMISSION_CONTROL_CAR_SEATS, 140 Car.PERMISSION_CONTROL_CAR_SEATS)); 141 mProps.put(VehicleProperty.SEAT_HEADREST_FORE_AFT_POS, new Pair<>( 142 Car.PERMISSION_CONTROL_CAR_SEATS, 143 Car.PERMISSION_CONTROL_CAR_SEATS)); 144 mProps.put(VehicleProperty.SEAT_HEADREST_FORE_AFT_MOVE, new Pair<>( 145 Car.PERMISSION_CONTROL_CAR_SEATS, 146 Car.PERMISSION_CONTROL_CAR_SEATS)); 147 mProps.put(VehicleProperty.WINDOW_POS, new Pair<>( 148 Car.PERMISSION_CONTROL_CAR_WINDOWS, 149 Car.PERMISSION_CONTROL_CAR_WINDOWS)); 150 mProps.put(VehicleProperty.WINDOW_MOVE, new Pair<>( 151 Car.PERMISSION_CONTROL_CAR_WINDOWS, 152 Car.PERMISSION_CONTROL_CAR_WINDOWS)); 153 mProps.put(VehicleProperty.WINDOW_LOCK, new Pair<>( 154 Car.PERMISSION_CONTROL_CAR_WINDOWS, 155 Car.PERMISSION_CONTROL_CAR_WINDOWS)); 156 157 // HVAC properties 158 mProps.put(VehicleProperty.HVAC_FAN_SPEED, new Pair<>( 159 Car.PERMISSION_CONTROL_CAR_CLIMATE, 160 Car.PERMISSION_CONTROL_CAR_CLIMATE)); 161 mProps.put(VehicleProperty.HVAC_FAN_DIRECTION, new Pair<>( 162 Car.PERMISSION_CONTROL_CAR_CLIMATE, 163 Car.PERMISSION_CONTROL_CAR_CLIMATE)); 164 mProps.put(VehicleProperty.HVAC_TEMPERATURE_CURRENT, new Pair<>( 165 Car.PERMISSION_CONTROL_CAR_CLIMATE, 166 Car.PERMISSION_CONTROL_CAR_CLIMATE)); 167 mProps.put(VehicleProperty.HVAC_TEMPERATURE_SET, new Pair<>( 168 Car.PERMISSION_CONTROL_CAR_CLIMATE, 169 Car.PERMISSION_CONTROL_CAR_CLIMATE)); 170 mProps.put(VehicleProperty.HVAC_DEFROSTER, new Pair<>( 171 Car.PERMISSION_CONTROL_CAR_CLIMATE, 172 Car.PERMISSION_CONTROL_CAR_CLIMATE)); 173 mProps.put(VehicleProperty.HVAC_AC_ON, new Pair<>( 174 Car.PERMISSION_CONTROL_CAR_CLIMATE, 175 Car.PERMISSION_CONTROL_CAR_CLIMATE)); 176 mProps.put(VehicleProperty.HVAC_MAX_AC_ON, new Pair<>( 177 Car.PERMISSION_CONTROL_CAR_CLIMATE, 178 Car.PERMISSION_CONTROL_CAR_CLIMATE)); 179 mProps.put(VehicleProperty.HVAC_MAX_DEFROST_ON, new Pair<>( 180 Car.PERMISSION_CONTROL_CAR_CLIMATE, 181 Car.PERMISSION_CONTROL_CAR_CLIMATE)); 182 mProps.put(VehicleProperty.HVAC_RECIRC_ON, new Pair<>( 183 Car.PERMISSION_CONTROL_CAR_CLIMATE, 184 Car.PERMISSION_CONTROL_CAR_CLIMATE)); 185 mProps.put(VehicleProperty.HVAC_DUAL_ON, new Pair<>( 186 Car.PERMISSION_CONTROL_CAR_CLIMATE, 187 Car.PERMISSION_CONTROL_CAR_CLIMATE)); 188 mProps.put(VehicleProperty.HVAC_AUTO_ON, new Pair<>( 189 Car.PERMISSION_CONTROL_CAR_CLIMATE, 190 Car.PERMISSION_CONTROL_CAR_CLIMATE)); 191 mProps.put(VehicleProperty.HVAC_SEAT_TEMPERATURE, new Pair<>( 192 Car.PERMISSION_CONTROL_CAR_CLIMATE, 193 Car.PERMISSION_CONTROL_CAR_CLIMATE)); 194 mProps.put(VehicleProperty.HVAC_SIDE_MIRROR_HEAT, new Pair<>( 195 Car.PERMISSION_CONTROL_CAR_CLIMATE, 196 Car.PERMISSION_CONTROL_CAR_CLIMATE)); 197 mProps.put(VehicleProperty.HVAC_STEERING_WHEEL_HEAT, new Pair<>( 198 Car.PERMISSION_CONTROL_CAR_CLIMATE, 199 Car.PERMISSION_CONTROL_CAR_CLIMATE)); 200 mProps.put(VehicleProperty.HVAC_TEMPERATURE_DISPLAY_UNITS, new Pair<>( 201 Car.PERMISSION_CONTROL_CAR_CLIMATE, 202 Car.PERMISSION_CONTROL_CAR_CLIMATE)); 203 mProps.put(VehicleProperty.HVAC_ACTUAL_FAN_SPEED_RPM, new Pair<>( 204 Car.PERMISSION_CONTROL_CAR_CLIMATE, 205 Car.PERMISSION_CONTROL_CAR_CLIMATE)); 206 mProps.put(VehicleProperty.HVAC_POWER_ON, new Pair<>( 207 Car.PERMISSION_CONTROL_CAR_CLIMATE, 208 Car.PERMISSION_CONTROL_CAR_CLIMATE)); 209 mProps.put(VehicleProperty.HVAC_FAN_DIRECTION_AVAILABLE, new Pair<>( 210 Car.PERMISSION_CONTROL_CAR_CLIMATE, 211 Car.PERMISSION_CONTROL_CAR_CLIMATE)); 212 mProps.put(VehicleProperty.HVAC_AUTO_RECIRC_ON, new Pair<>( 213 Car.PERMISSION_CONTROL_CAR_CLIMATE, 214 Car.PERMISSION_CONTROL_CAR_CLIMATE)); 215 mProps.put(VehicleProperty.HVAC_SEAT_VENTILATION, new Pair<>( 216 Car.PERMISSION_CONTROL_CAR_CLIMATE, 217 Car.PERMISSION_CONTROL_CAR_CLIMATE)); 218 mProps.put(VehicleProperty.ENV_OUTSIDE_TEMPERATURE, new Pair<>( 219 Car.PERMISSION_CONTROL_CAR_CLIMATE, 220 Car.PERMISSION_CONTROL_CAR_CLIMATE)); 221 222 // Info properties 223 mProps.put(VehicleProperty.INFO_VIN, new Pair<>( 224 Car.PERMISSION_IDENTIFICATION, 225 Car.PERMISSION_IDENTIFICATION)); 226 mProps.put(VehicleProperty.INFO_MAKE, new Pair<>( 227 Car.PERMISSION_CAR_INFO, 228 Car.PERMISSION_CAR_INFO)); 229 mProps.put(VehicleProperty.INFO_MODEL, new Pair<>( 230 Car.PERMISSION_CAR_INFO, 231 Car.PERMISSION_CAR_INFO)); 232 mProps.put(VehicleProperty.INFO_MODEL_YEAR, new Pair<>( 233 Car.PERMISSION_CAR_INFO, 234 Car.PERMISSION_CAR_INFO)); 235 mProps.put(VehicleProperty.INFO_FUEL_CAPACITY, new Pair<>( 236 Car.PERMISSION_CAR_INFO, 237 Car.PERMISSION_CAR_INFO)); 238 mProps.put(VehicleProperty.INFO_FUEL_TYPE, new Pair<>( 239 Car.PERMISSION_CAR_INFO, 240 Car.PERMISSION_CAR_INFO)); 241 mProps.put(VehicleProperty.INFO_EV_BATTERY_CAPACITY, new Pair<>( 242 Car.PERMISSION_CAR_INFO, 243 Car.PERMISSION_CAR_INFO)); 244 mProps.put(VehicleProperty.INFO_EV_CONNECTOR_TYPE, new Pair<>( 245 Car.PERMISSION_CAR_INFO, 246 Car.PERMISSION_CAR_INFO)); 247 mProps.put(VehicleProperty.INFO_FUEL_DOOR_LOCATION, new Pair<>( 248 Car.PERMISSION_CAR_INFO, 249 Car.PERMISSION_CAR_INFO)); 250 mProps.put(VehicleProperty.INFO_EV_PORT_LOCATION, new Pair<>( 251 Car.PERMISSION_CAR_INFO, 252 Car.PERMISSION_CAR_INFO)); 253 mProps.put(VehicleProperty.INFO_DRIVER_SEAT, new Pair<>( 254 Car.PERMISSION_CAR_INFO, 255 Car.PERMISSION_CAR_INFO)); 256 257 // Sensor properties 258 mProps.put(VehicleProperty.PERF_ODOMETER, new Pair<>( 259 Car.PERMISSION_MILEAGE, 260 Car.PERMISSION_MILEAGE)); 261 mProps.put(VehicleProperty.PERF_VEHICLE_SPEED, new Pair<>( 262 Car.PERMISSION_SPEED, 263 Car.PERMISSION_SPEED)); 264 mProps.put(VehicleProperty.ENGINE_COOLANT_TEMP, new Pair<>( 265 Car.PERMISSION_CAR_ENGINE_DETAILED, 266 Car.PERMISSION_CAR_ENGINE_DETAILED)); 267 mProps.put(VehicleProperty.ENGINE_OIL_LEVEL, new Pair<>( 268 Car.PERMISSION_CAR_ENGINE_DETAILED, 269 Car.PERMISSION_CAR_ENGINE_DETAILED)); 270 mProps.put(VehicleProperty.ENGINE_OIL_TEMP, new Pair<>( 271 Car.PERMISSION_CAR_ENGINE_DETAILED, 272 Car.PERMISSION_CAR_ENGINE_DETAILED)); 273 mProps.put(VehicleProperty.ENGINE_RPM, new Pair<>( 274 Car.PERMISSION_CAR_ENGINE_DETAILED, 275 Car.PERMISSION_CAR_ENGINE_DETAILED)); 276 mProps.put(VehicleProperty.WHEEL_TICK, new Pair<>( 277 Car.PERMISSION_SPEED, 278 Car.PERMISSION_SPEED)); 279 mProps.put(VehicleProperty.FUEL_LEVEL, new Pair<>( 280 Car.PERMISSION_ENERGY, 281 Car.PERMISSION_ENERGY)); 282 mProps.put(VehicleProperty.FUEL_DOOR_OPEN, new Pair<>( 283 Car.PERMISSION_ENERGY_PORTS, 284 Car.PERMISSION_ENERGY_PORTS)); 285 mProps.put(VehicleProperty.EV_BATTERY_LEVEL, new Pair<>( 286 Car.PERMISSION_ENERGY, 287 Car.PERMISSION_ENERGY)); 288 mProps.put(VehicleProperty.EV_CHARGE_PORT_OPEN, new Pair<>( 289 Car.PERMISSION_ENERGY_PORTS, 290 Car.PERMISSION_ENERGY_PORTS)); 291 mProps.put(VehicleProperty.EV_CHARGE_PORT_CONNECTED, new Pair<>( 292 Car.PERMISSION_ENERGY_PORTS, 293 Car.PERMISSION_ENERGY_PORTS)); 294 mProps.put(VehicleProperty.EV_BATTERY_INSTANTANEOUS_CHARGE_RATE, new Pair<>( 295 Car.PERMISSION_ENERGY, 296 Car.PERMISSION_ENERGY)); 297 mProps.put(VehicleProperty.RANGE_REMAINING, new Pair<>( 298 Car.PERMISSION_ENERGY, 299 Car.PERMISSION_ENERGY)); 300 mProps.put(VehicleProperty.TIRE_PRESSURE, new Pair<>( 301 Car.PERMISSION_TIRES, 302 Car.PERMISSION_TIRES)); 303 mProps.put(VehicleProperty.GEAR_SELECTION, new Pair<>( 304 Car.PERMISSION_POWERTRAIN, 305 Car.PERMISSION_POWERTRAIN)); 306 mProps.put(VehicleProperty.CURRENT_GEAR, new Pair<>( 307 Car.PERMISSION_POWERTRAIN, 308 Car.PERMISSION_POWERTRAIN)); 309 mProps.put(VehicleProperty.PARKING_BRAKE_ON, new Pair<>( 310 Car.PERMISSION_POWERTRAIN, 311 Car.PERMISSION_POWERTRAIN)); 312 mProps.put(VehicleProperty.PARKING_BRAKE_AUTO_APPLY, new Pair<>( 313 Car.PERMISSION_POWERTRAIN, 314 Car.PERMISSION_POWERTRAIN)); 315 mProps.put(VehicleProperty.FUEL_LEVEL_LOW, new Pair<>( 316 Car.PERMISSION_ENERGY, 317 Car.PERMISSION_ENERGY)); 318 mProps.put(VehicleProperty.NIGHT_MODE, new Pair<>( 319 Car.PERMISSION_EXTERIOR_ENVIRONMENT, 320 Car.PERMISSION_EXTERIOR_ENVIRONMENT)); 321 mProps.put(VehicleProperty.TURN_SIGNAL_STATE, new Pair<>( 322 Car.PERMISSION_EXTERIOR_LIGHTS, 323 Car.PERMISSION_EXTERIOR_LIGHTS)); 324 mProps.put(VehicleProperty.IGNITION_STATE, new Pair<>( 325 Car.PERMISSION_CAR_POWER, 326 Car.PERMISSION_CAR_POWER)); 327 mProps.put(VehicleProperty.ABS_ACTIVE, new Pair<>( 328 Car.PERMISSION_CAR_DYNAMICS_STATE, 329 Car.PERMISSION_CAR_DYNAMICS_STATE)); 330 mProps.put(VehicleProperty.TRACTION_CONTROL_ACTIVE, new Pair<>( 331 Car.PERMISSION_CAR_DYNAMICS_STATE, 332 Car.PERMISSION_CAR_DYNAMICS_STATE)); 333 mProps.put(VehicleProperty.ENV_OUTSIDE_TEMPERATURE, new Pair<>( 334 Car.PERMISSION_EXTERIOR_ENVIRONMENT, 335 Car.PERMISSION_EXTERIOR_ENVIRONMENT)); 336 mProps.put(VehicleProperty.HEADLIGHTS_STATE, new Pair<>( 337 Car.PERMISSION_EXTERIOR_LIGHTS, 338 Car.PERMISSION_EXTERIOR_LIGHTS)); 339 mProps.put(VehicleProperty.HIGH_BEAM_LIGHTS_STATE, new Pair<>( 340 Car.PERMISSION_EXTERIOR_LIGHTS, 341 Car.PERMISSION_EXTERIOR_LIGHTS)); 342 mProps.put(VehicleProperty.FOG_LIGHTS_STATE, new Pair<>( 343 Car.PERMISSION_EXTERIOR_LIGHTS, 344 Car.PERMISSION_EXTERIOR_LIGHTS)); 345 mProps.put(VehicleProperty.HAZARD_LIGHTS_STATE, new Pair<>( 346 Car.PERMISSION_EXTERIOR_LIGHTS, 347 Car.PERMISSION_EXTERIOR_LIGHTS)); 348 mProps.put(VehicleProperty.HEADLIGHTS_SWITCH, new Pair<>( 349 Car.PERMISSION_EXTERIOR_LIGHTS, 350 Car.PERMISSION_CONTROL_EXTERIOR_LIGHTS)); 351 mProps.put(VehicleProperty.HIGH_BEAM_LIGHTS_SWITCH, new Pair<>( 352 Car.PERMISSION_EXTERIOR_LIGHTS, 353 Car.PERMISSION_CONTROL_EXTERIOR_LIGHTS)); 354 mProps.put(VehicleProperty.FOG_LIGHTS_SWITCH, new Pair<>( 355 Car.PERMISSION_EXTERIOR_LIGHTS, 356 Car.PERMISSION_CONTROL_EXTERIOR_LIGHTS)); 357 mProps.put(VehicleProperty.HAZARD_LIGHTS_SWITCH, new Pair<>( 358 Car.PERMISSION_EXTERIOR_LIGHTS, 359 Car.PERMISSION_CONTROL_EXTERIOR_LIGHTS)); 360 } 361 362 /** 363 * Returns read permission string for given property ID. 364 */ 365 @Nullable 366 public String getReadPermission(int propId) { 367 Pair<String, String> p = mProps.get(propId); 368 if (p != null) { 369 // Property ID exists. Return read permission. 370 return p.first; 371 } else { 372 return null; 373 } 374 } 375 376 /** 377 * Returns write permission string for given property ID. 378 */ 379 @Nullable 380 public String getWritePermission(int propId) { 381 Pair<String, String> p = mProps.get(propId); 382 if (p != null) { 383 // Property ID exists. Return write permission. 384 return p.second; 385 } else { 386 return null; 387 } 388 } 389 390 /** 391 * Return true if property is a vendor property and was added 392 */ 393 public boolean insertVendorProperty(int propId) { 394 if ((propId & VehiclePropertyGroup.MASK) == VehiclePropertyGroup.VENDOR) { 395 mProps.put(propId, new Pair<>( 396 Car.PERMISSION_VENDOR_EXTENSION, Car.PERMISSION_VENDOR_EXTENSION)); 397 return true; 398 } else { 399 // This is not a vendor extension property, it is not added 400 return false; 401 } 402 } 403 404 /** 405 * Check if property ID is in the list of known IDs that PropertyHalService is interested it. 406 */ 407 public boolean isSupportedProperty(int propId) { 408 if (mProps.get(propId) != null) { 409 // Property is in the list of supported properties 410 return true; 411 } else { 412 // If it's a vendor property, insert it into the propId list and handle it 413 return insertVendorProperty(propId); 414 } 415 } 416} 417