【IVI】car_service 命令行工具
- 1、car_service服务执行
- 2、CarShellCommand命令执行
- 2.1 cmd car_service day-night-mode day设置白天模式
- 2.2 cmd car_service inject-vhal-event vhal信号事件
- 2.2.1 VehiclePropertyIds
- 2.2.2 模拟驾驶事件
- 2.3 cmd car_service inject-error-event 注入错误vhal信号事件
- 2.4 cmd car_service get-carpropertyconfig 获取车辆CarPropertyConfigs
- 2.5 cmd car_service get-property-value 获取车辆属性值
- 2.6 cmd car_service inject-key 注入KeyEvent事件
- 2.7 cmd car_service inject-rotary 模拟旋控器事件
Android framework服务命令行工具框架 - Android13
1、car_service服务执行
Android framework服务命令行工具框架 - Android13
【IVI】CarService启动
bindService
绑定的car_service
服务ServiceManager.addService("car_service", mICarImpl);
, 也可通过Activity获取执行服务命令adb shell dumpsys activity service com.android.car
Automotive 虚拟机(Volvo System Image)API 30如下:
C:\Users\Administrator\Desktop>adb shell cmd car_service
Car service commands:
-h
Print this help text.
day-night-mode [day|night|sensor]
Force into day/night mode or restore to auto.
inject-vhal-event property [zone] data(can be comma separated list) [-t delay_time_seconds]
Inject a vehicle property for testing.
delay_time_seconds: the event timestamp is increased by certain second.
If not specified, it will be 0.
inject-error-event property zone errorCode
Inject an error event from VHAL for testing.
enable-uxr true|false
Enable/Disable UX restrictions and App blocking.
garage-mode [on|off|query|reboot]
Force into or out of garage mode, or check status.
With 'reboot', enter garage mode, then reboot when it completes.
get-do-activities pkgname
Get Distraction Optimized activities in given package.
get-carpropertyconfig [propertyId]
Get a CarPropertyConfig by Id in Hex or list all CarPropertyConfigs
get-property-value [propertyId] [areaId]
Get a vehicle property value by property id in Hex and areaId
or list all property values for all areaId
suspend [--skip-garagemode] [--wakeup-after RESUME_DELAY]
Suspend the system to Deep Sleep.
--skip-garagemode skips Garage Mode before going into sleep.
--wakeup-after RESUME_DELAY wakes up the device RESUME_DELAY seconds after suspend.
resume
Wake the system up after a 'suspend.'
enable-trusted-device true|false
Enable/Disable Trusted device feature.
remove-trusted-devices
Remove all trusted devices for the current foreground user.
projection-tethering [true|false]
Whether tethering should be used when creating access point for wireless projection
--metrics
When used with dumpsys, only metrics will be in the dumpsys output.
set-audio-zone-for-uid [zoneid] [uid]
Maps the audio zoneid to uid.
start-fixed-activity displayId packageName activityName
Start an Activity the specified display as fixed mode
stop-fixed-mode displayId
Stop fixed Activity mode for the given display. The Activity will not be restarted upon crash.
enable-feature featureName
Enable the requested feature. Change will happen after reboot.
This requires root/su.
disable-feature featureName
Disable the requested feature. Change will happen after reboot
This requires root/su.
inject-key [-d display] [-t down_delay_ms | -a down|up] key_code
inject key down and/or up event to car service
display: 0 for main, 1 for cluster. If not specified, it will be 0.
down_delay_ms: delay from down to up key event. If not specified,
it will be 0
key_code: int key code defined in android KeyEvent
If -a isn't specified, both down and up will be injected.
inject-rotary [-d display] [-i input_type] [-c clockwise]
[-dt delta_times_ms]
inject rotary input event to car service.
display: 0 for main, 1 for cluster. If not specified, it will be 0.
input_type: 10 for navigation controller input, 11 for volume
controller input. If not specified, it will be 10.
clockwise: true if the event is clockwise, false if the event is
counter-clockwise. If not specified, it will be false.
delta_times_ms: a list of delta time (current time minus event time)
in descending order. If not specified, it will be 0.
get-initial-user-info <REQ_TYPE> [--hal-only] [--timeout TIMEOUT_MS]
Calls the Vehicle HAL to get the initial boot info, passing the given
REQ_TYPE (which could be either FIRST_BOOT, FIRST_BOOT_AFTER_OTA,
COLD_BOOT, RESUME, or any numeric value that would be passed 'as-is')
and an optional TIMEOUT_MS to wait for the HAL response (if not set,
it will use a default value).
The --hal-only option only calls HAL, without using CarUserService.
switch-user <USER_ID> [--hal-only] [--timeout TIMEOUT_MS]
Switches to user USER_ID using the HAL integration.
The --hal-only option only calls HAL, without switching the user,
while the --timeout defines how long to wait for the HAL response.
remove-user <USER_ID> [--hal-only]
Removes user with USER_ID using the HAL integration.
The --hal-only option only calls HAL, without removing the user,
create-user [--hal-only] [--timeout TIMEOUT_MS] [--type TYPE] [--flags FLAGS] [NAME]
Creates a new user using the HAL integration.
The --hal-only uses UserManager to create the user,
while the --timeout defines how long to wait for the HAL response.
get-initial-user
Gets the id of the initial user (or N/A when it's not available)
set-occupant-zone-for-user [occupantZoneId] [userId]
Maps the occupant zone id to user id.
reset-user-in-occupant-zone [occupantZoneId]
Unmaps the user assigned to occupant zone id.
get-user-auth-association [--hal-only] [--user USER_ID] TYPE1 [..TYPE_N]
Gets the N user authentication values for the N types for the given user
(or current user when not specified).
By defautt it calls CarUserManager, but using --hal-only will call just UserHalService.
set-user-auth-association [--hal-only] [--user USER_ID] TYPE1 VALUE1 [..TYPE_N VALUE_N]
Sets the N user authentication types with the N values for the given user
(or current user when not specified).
By defautt it calls CarUserManager, but using --hal-only will call just UserHalService.
Valid types are: KEY_FOB, CUSTOM_1, CUSTOM_2, CUSTOM_3, CUSTOM_4.
Valid values are: ASSOCIATE_CURRENT_USER, DISASSOCIATE_CURRENT_USER, DISASSOCIATE_ALL_USERS.
power-off [--skip-garagemode] [--shutdown]
Powers off the car.
telemetry <subcommand> Telemetry commands.
Provide -h to see the list of sub-commands.
2、CarShellCommand命令执行
packages/services/Car/car-lib/README.md
packages/services/Car/service/src/com/android/car/CarShellCommand.java
packages/services/Car/service/src/com/android/car/ICarImpl.java
adb shell cmd car_service
2.1 cmd car_service day-night-mode day设置白天模式
day-night-mode [day|night|sensor]
Force into day/night mode or restore to auto.
- 强制进入白天模式:
adb shell cmd car_service day-night-mode day
- 恢复到自动模式:
adb shell cmd car_service day-night-mode sensor
packages/services/Car/service/src/com/android/car/CarNightService.java
/**
* Sets {@link UiModeManager} to night mode according to the {@link DayNightSensorMode} passed
* as parameter.
*
* @param mode the sensor mode used to set vehicle in night mode
* @return the current night mode, or {@code -1} on error
*/
public int forceDayNightMode(@DayNightSensorMode int mode) {
synchronized (mLock) {
if (mUiModeManager == null) {
return -1;
}
int resultMode;
switch (mode) {
case FORCED_SENSOR_MODE:
resultMode = mNightSetting;
mForcedMode = FORCED_SENSOR_MODE;
break;
case FORCED_DAY_MODE:
resultMode = UiModeManager.MODE_NIGHT_NO;
mForcedMode = FORCED_DAY_MODE;
break;
case FORCED_NIGHT_MODE:
resultMode = UiModeManager.MODE_NIGHT_YES;
mForcedMode = FORCED_NIGHT_MODE;
break;
default:
Slogf.e(CarLog.TAG_SENSOR, "Unknown forced day/night mode " + mode);
return -1;
}
mUiModeManager.setNightMode(resultMode);
return mUiModeManager.getNightMode();
}
}
2.2 cmd car_service inject-vhal-event vhal信号事件
inject-vhal-event property [zone] data(can be comma separated list) [-t delay_time_seconds]
Inject a vehicle property for testing.
delay_time_seconds: the event timestamp is increased by certain second.
If not specified, it will be 0.
packages/services/Car/service/src/com/android/car/hal/VehicleHal.java
/**
* Inject a VHAL event
*
* @param property the Vehicle property Id as defined in the HAL
* @param zone the zone that this event services
* @param value the data value of the event
* @param delayTime add a certain duration to event timestamp
*/
public void injectVhalEvent(int property, int zone, String value, int delayTime)
throws NumberFormatException {
long timestamp = SystemClock.elapsedRealtimeNanos() + TimeUnit.SECONDS.toNanos(delayTime);
HalPropValue v = createPropValueForInjecting(mPropValueBuilder, property, zone,
Arrays.asList(value.split(DATA_DELIMITER)), timestamp);
if (v == null) {
return;
}
mHandler.post(() -> onPropertyEvent(Lists.newArrayList(v)));
}
2.2.1 VehiclePropertyIds
packages/services/Car/car-lib-module/api/current.txt
packages/services/Car/car-lib/src/android/car/VehiclePropertyIds.java
VehiclePropertyIds | value | 说明 |
---|---|---|
INFO_VIN | 286261504; // 0x11100100 | VIN of vehicle Requires permission: Car.PERMISSION_IDENTIFICATION. |
INFO_MAKE | 286261505; // 0x11100101 | Manufacturer of vehicle. |
… | … | … |
PERF_VEHICLE_SPEED | 291504647; // 0x11600207 | 车辆的速度(以 米/秒 为单位)。当车辆向前行驶时为正,当车辆向后行驶时为负。 |
PERF_VEHICLE_SPEED_DISPLAY | 291504648; // 0x11600208 | 用于显示的车辆速度(以 米/秒 为单位)。 |
PERF_STEERING_ANGLE | 291504649; // 0x11600209 | 车辆前轮转向角度,单位为度。左边是负数。 |
PERF_REAR_STEERING_ANGLE | 291504656; // 0x11600210 | 车辆后轮转向角度,单位为度。左边是负数。 |
… | … | … |
SENSOR_TYPE_GEAR | 289408000; // 0x11400400 | 表示变速箱档位的当前位置。 |
… | … | … |
public final class VehiclePropertyIds {
ctor @Deprecated public VehiclePropertyIds();
method public static String toString(int);
field @RequiresPermission("android.car.permission.CAR_DYNAMICS_STATE") public static final int ABS_ACTIVE = 287310858; // 0x1120040a
field @RequiresPermission("android.car.permission.CAR_POWER") public static final int AP_POWER_BOOTUP_REASON = 289409538; // 0x11400a02
field @RequiresPermission("android.car.permission.CAR_POWER") public static final int AP_POWER_STATE_REPORT = 289475073; // 0x11410a01
field @RequiresPermission("android.car.permission.CAR_POWER") public static final int AP_POWER_STATE_REQ = 289475072; // 0x11410a00
field @RequiresPermission(android.car.Car.PERMISSION_READ_INTERIOR_LIGHTS) public static final int CABIN_LIGHTS_STATE = 289410817; // 0x11400f01
field @RequiresPermission(android.car.Car.PERMISSION_CONTROL_INTERIOR_LIGHTS) public static final int CABIN_LIGHTS_SWITCH = 289410818; // 0x11400f02
field @RequiresPermission("android.car.permission.CAR_TIRES") public static final int CRITICALLY_LOW_TIRE_PRESSURE = 392168202; // 0x1760030a
field @RequiresPermission(android.car.Car.PERMISSION_POWERTRAIN) public static final int CURRENT_GEAR = 289408001; // 0x11400401
field @RequiresPermission("android.car.permission.CAR_POWER") public static final int DISPLAY_BRIGHTNESS = 289409539; // 0x11400a03
field @RequiresPermission.Read(@androidx.annotation.RequiresPermission(android.car.Car.PERMISSION_READ_DISPLAY_UNITS)) @RequiresPermission.Write(@androidx.annotation.RequiresPermission(allOf={android.car.Car.PERMISSION_CONTROL_DISPLAY_UNITS, "android.car.permission.CAR_VENDOR_EXTENSION"})) public static final int DISTANCE_DISPLAY_UNITS = 289408512; // 0x11400600
field @RequiresPermission("android.car.permission.CONTROL_CAR_DOORS") public static final int DOOR_LOCK = 371198722; // 0x16200b02
field @RequiresPermission("android.car.permission.CONTROL_CAR_DOORS") public static final int DOOR_MOVE = 373295873; // 0x16400b01
field @RequiresPermission("android.car.permission.CONTROL_CAR_DOORS") public static final int DOOR_POS = 373295872; // 0x16400b00
field @RequiresPermission(android.car.Car.PERMISSION_CAR_INFO) public static final int ELECTRONIC_TOLL_COLLECTION_CARD_STATUS = 289410874; // 0x11400f3a
field @RequiresPermission(android.car.Car.PERMISSION_CAR_INFO) public static final int ELECTRONIC_TOLL_COLLECTION_CARD_TYPE = 289410873; // 0x11400f39
field @RequiresPermission("android.car.permission.CAR_ENGINE_DETAILED") public static final int ENGINE_COOLANT_TEMP = 291504897; // 0x11600301
field @RequiresPermission("android.car.permission.CAR_ENGINE_DETAILED") public static final int ENGINE_OIL_LEVEL = 289407747; // 0x11400303
field @RequiresPermission("android.car.permission.CAR_ENGINE_DETAILED") public static final int ENGINE_OIL_TEMP = 291504900; // 0x11600304
field @RequiresPermission("android.car.permission.CAR_ENGINE_DETAILED") public static final int ENGINE_RPM = 291504901; // 0x11600305
field @RequiresPermission(android.car.Car.PERMISSION_EXTERIOR_ENVIRONMENT) public static final int ENV_OUTSIDE_TEMPERATURE = 291505923; // 0x11600703
field @RequiresPermission("android.car.permission.CAR_EPOCH_TIME") public static final int EPOCH_TIME = 290457094; // 0x11500606
field @RequiresPermission.Read(@androidx.annotation.RequiresPermission(android.car.Car.PERMISSION_READ_DISPLAY_UNITS)) @RequiresPermission.Write(@androidx.annotation.RequiresPermission(allOf={android.car.Car.PERMISSION_CONTROL_DISPLAY_UNITS, "android.car.permission.CAR_VENDOR_EXTENSION"})) public static final int EV_BATTERY_DISPLAY_UNITS = 289408515; // 0x11400603
field @RequiresPermission(android.car.Car.PERMISSION_ENERGY) public static final int EV_BATTERY_INSTANTANEOUS_CHARGE_RATE = 291504908; // 0x1160030c
field @RequiresPermission(android.car.Car.PERMISSION_ENERGY) public static final int EV_BATTERY_LEVEL = 291504905; // 0x11600309
field @RequiresPermission.Read(@androidx.annotation.RequiresPermission(android.car.Car.PERMISSION_ENERGY)) @RequiresPermission.Write(@androidx.annotation.RequiresPermission(android.car.Car.PERMISSION_CONTROL_CAR_ENERGY)) public static final int EV_CHARGE_CURRENT_DRAW_LIMIT = 291508031; // 0x11600f3f
field @RequiresPermission.Read(@androidx.annotation.RequiresPermission(android.car.Car.PERMISSION_ENERGY)) @RequiresPermission.Write(@androidx.annotation.RequiresPermission(android.car.Car.PERMISSION_CONTROL_CAR_ENERGY)) public static final int EV_CHARGE_PERCENT_LIMIT = 291508032; // 0x11600f40
field @RequiresPermission(android.car.Car.PERMISSION_ENERGY_PORTS) public static final int EV_CHARGE_PORT_CONNECTED = 287310603; // 0x1120030b
field @RequiresPermission.Read(@androidx.annotation.RequiresPermission(android.car.Car.PERMISSION_ENERGY_PORTS)) @RequiresPermission.Write(@androidx.annotation.RequiresPermission("android.car.permission.CONTROL_CAR_ENERGY_PORTS")) public static final int EV_CHARGE_PORT_OPEN = 287310602; // 0x1120030a
field @RequiresPermission.Read(@androidx.annotation.RequiresPermission(android.car.Car.PERMISSION_ENERGY)) public static final int EV_CHARGE_STATE = 289410881; // 0x11400f41
field @RequiresPermission(android.car.Car.PERMISSION_CONTROL_CAR_ENERGY) public static final int EV_CHARGE_SWITCH = 287313730; // 0x11200f42
field @RequiresPermission.Read(@androidx.annotation.RequiresPermission(android.car.Car.PERMISSION_ENERGY)) public static final int EV_CHARGE_TIME_REMAINING = 289410883; // 0x11400f43
field @RequiresPermission.Read(@androidx.annotation.RequiresPermission(android.car.Car.PERMISSION_ENERGY)) public static final int EV_REGENERATIVE_BRAKING_STATE = 289410884; // 0x11400f44
field @RequiresPermission("android.car.permission.CAR_EXTERIOR_LIGHTS") public static final int FOG_LIGHTS_STATE = 289410562; // 0x11400e02
field @RequiresPermission("android.car.permission.CONTROL_CAR_EXTERIOR_LIGHTS") public static final int FOG_LIGHTS_SWITCH = 289410578; // 0x11400e12
field @RequiresPermission("android.car.permission.CAR_EXTERIOR_LIGHTS") public static final int FRONT_FOG_LIGHTS_STATE = 289410875; // 0x11400f3b
field @RequiresPermission("android.car.permission.CONTROL_CAR_EXTERIOR_LIGHTS") public static final int FRONT_FOG_LIGHTS_SWITCH = 289410876; // 0x11400f3c
field @RequiresPermission.Read(@androidx.annotation.RequiresPermission(android.car.Car.PERMISSION_READ_DISPLAY_UNITS)) @RequiresPermission.Write(@androidx.annotation.RequiresPermission(allOf={android.car.Car.PERMISSION_CONTROL_DISPLAY_UNITS, "android.car.permission.CAR_VENDOR_EXTENSION"})) public static final int FUEL_CONSUMPTION_UNITS_DISTANCE_OVER_VOLUME = 287311364; // 0x11200604
field @RequiresPermission.Read(@androidx.annotation.RequiresPermission(android.car.Car.PERMISSION_ENERGY_PORTS)) @RequiresPermission.Write(@androidx.annotation.RequiresPermission("android.car.permission.CONTROL_CAR_ENERGY_PORTS")) public static final int FUEL_DOOR_OPEN = 287310600; // 0x11200308
field @RequiresPermission(android.car.Car.PERMISSION_ENERGY) public static final int FUEL_LEVEL = 291504903; // 0x11600307
field @RequiresPermission(android.car.Car.PERMISSION_ENERGY) public static final int FUEL_LEVEL_LOW = 287310853; // 0x11200405
field @RequiresPermission.Read(@androidx.annotation.RequiresPermission(android.car.Car.PERMISSION_READ_DISPLAY_UNITS)) @RequiresPermission.Write(@androidx.annotation.RequiresPermission(allOf={android.car.Car.PERMISSION_CONTROL_DISPLAY_UNITS, "android.car.permission.CAR_VENDOR_EXTENSION"})) public static final int FUEL_VOLUME_DISPLAY_UNITS = 289408513; // 0x11400601
field @RequiresPermission(android.car.Car.PERMISSION_POWERTRAIN) public static final int GEAR_SELECTION = 289408000; // 0x11400400
field @RequiresPermission("android.car.permission.CAR_EXTERIOR_LIGHTS") public static final int HAZARD_LIGHTS_STATE = 289410563; // 0x11400e03
field @RequiresPermission("android.car.permission.CONTROL_CAR_EXTERIOR_LIGHTS") public static final int HAZARD_LIGHTS_SWITCH = 289410579; // 0x11400e13
field @RequiresPermission("android.car.permission.CAR_EXTERIOR_LIGHTS") public static final int HEADLIGHTS_STATE = 289410560; // 0x11400e00
field @RequiresPermission("android.car.permission.CONTROL_CAR_EXTERIOR_LIGHTS") public static final int HEADLIGHTS_SWITCH = 289410576; // 0x11400e10
field @RequiresPermission("android.car.permission.CAR_EXTERIOR_LIGHTS") public static final int HIGH_BEAM_LIGHTS_STATE = 289410561; // 0x11400e01
field @RequiresPermission("android.car.permission.CONTROL_CAR_EXTERIOR_LIGHTS") public static final int HIGH_BEAM_LIGHTS_SWITCH = 289410577; // 0x11400e11
field @RequiresPermission("android.car.permission.CONTROL_CAR_CLIMATE") public static final int HVAC_ACTUAL_FAN_SPEED_RPM = 356517135; // 0x1540050f
field @RequiresPermission("android.car.permission.CONTROL_CAR_CLIMATE") public static final int HVAC_AC_ON = 354419973; // 0x15200505
field @RequiresPermission("android.car.permission.CONTROL_CAR_CLIMATE") public static final int HVAC_AUTO_ON = 354419978; // 0x1520050a
field @RequiresPermission("android.car.permission.CONTROL_CAR_CLIMATE") public static final int HVAC_AUTO_RECIRC_ON = 354419986; // 0x15200512
field @RequiresPermission("android.car.permission.CONTROL_CAR_CLIMATE") public static final int HVAC_DEFROSTER = 320865540; // 0x13200504
field @RequiresPermission("android.car.permission.CONTROL_CAR_CLIMATE") public static final int HVAC_DUAL_ON = 354419977; // 0x15200509
field @RequiresPermission("android.car.permission.CONTROL_CAR_CLIMATE") public static final int HVAC_FAN_DIRECTION = 356517121; // 0x15400501
field @RequiresPermission("android.car.permission.CONTROL_CAR_CLIMATE") public static final int HVAC_FAN_DIRECTION_AVAILABLE = 356582673; // 0x15410511
field @RequiresPermission("android.car.permission.CONTROL_CAR_CLIMATE") public static final int HVAC_FAN_SPEED = 356517120; // 0x15400500
field @RequiresPermission("android.car.permission.CONTROL_CAR_CLIMATE") public static final int HVAC_MAX_AC_ON = 354419974; // 0x15200506
field @RequiresPermission("android.car.permission.CONTROL_CAR_CLIMATE") public static final int HVAC_MAX_DEFROST_ON = 354419975; // 0x15200507
field @RequiresPermission("android.car.permission.CONTROL_CAR_CLIMATE") public static final int HVAC_POWER_ON = 354419984; // 0x15200510
field @RequiresPermission("android.car.permission.CONTROL_CAR_CLIMATE") public static final int HVAC_RECIRC_ON = 354419976; // 0x15200508
field @RequiresPermission("android.car.permission.CONTROL_CAR_CLIMATE") public static final int HVAC_SEAT_TEMPERATURE = 356517131; // 0x1540050b
field @RequiresPermission("android.car.permission.CONTROL_CAR_CLIMATE") public static final int HVAC_SEAT_VENTILATION = 356517139; // 0x15400513
field @RequiresPermission("android.car.permission.CONTROL_CAR_CLIMATE") public static final int HVAC_SIDE_MIRROR_HEAT = 339739916; // 0x1440050c
field @RequiresPermission("android.car.permission.CONTROL_CAR_CLIMATE") public static final int HVAC_STEERING_WHEEL_HEAT = 289408269; // 0x1140050d
field @RequiresPermission("android.car.permission.CONTROL_CAR_CLIMATE") public static final int HVAC_TEMPERATURE_CURRENT = 358614274; // 0x15600502
field @RequiresPermission("android.car.permission.CONTROL_CAR_CLIMATE") public static final int HVAC_TEMPERATURE_DISPLAY_UNITS = 289408270; // 0x1140050e
field @RequiresPermission("android.car.permission.CONTROL_CAR_CLIMATE") public static final int HVAC_TEMPERATURE_SET = 358614275; // 0x15600503
field @RequiresPermission("android.car.permission.CONTROL_CAR_CLIMATE") public static final int HVAC_TEMPERATURE_VALUE_SUGGESTION = 291570965; // 0x11610515
field public static final int HW_KEY_INPUT = 289475088; // 0x11410a10
field @RequiresPermission(android.car.Car.PERMISSION_POWERTRAIN) public static final int IGNITION_STATE = 289408009; // 0x11400409
field @RequiresPermission(android.car.Car.PERMISSION_CAR_INFO) public static final int INFO_DRIVER_SEAT = 356516106; // 0x1540010a
field @RequiresPermission(android.car.Car.PERMISSION_CAR_INFO) public static final int INFO_EV_BATTERY_CAPACITY = 291504390; // 0x11600106
field @RequiresPermission(android.car.Car.PERMISSION_CAR_INFO) public static final int INFO_EV_CONNECTOR_TYPE = 289472775; // 0x11410107
field @RequiresPermission(android.car.Car.PERMISSION_CAR_INFO) public static final int INFO_EV_PORT_LOCATION = 289407241; // 0x11400109
field @RequiresPermission(android.car.Car.PERMISSION_CAR_INFO) public static final int INFO_EXTERIOR_DIMENSIONS = 289472779; // 0x1141010b
field @RequiresPermission(android.car.Car.PERMISSION_CAR_INFO) public static final int INFO_FUEL_CAPACITY = 291504388; // 0x11600104
field @RequiresPermission(android.car.Car.PERMISSION_CAR_INFO) public static final int INFO_FUEL_DOOR_LOCATION = 289407240; // 0x11400108
field @RequiresPermission(android.car.Car.PERMISSION_CAR_INFO) public static final int INFO_FUEL_TYPE = 289472773; // 0x11410105
field @RequiresPermission(android.car.Car.PERMISSION_CAR_INFO) public static final int INFO_MAKE = 286261505; // 0x11100101
field @RequiresPermission(android.car.Car.PERMISSION_CAR_INFO) public static final int INFO_MODEL = 286261506; // 0x11100102
field @RequiresPermission(android.car.Car.PERMISSION_CAR_INFO) public static final int INFO_MODEL_YEAR = 289407235; // 0x11400103
field @RequiresPermission(android.car.Car.PERMISSION_CAR_INFO) public static final int INFO_MULTI_EV_PORT_LOCATIONS = 289472780; // 0x1141010c
field @RequiresPermission(android.car.Car.PERMISSION_IDENTIFICATION) public static final int INFO_VIN = 286261504; // 0x11100100
field public static final int INVALID = 0; // 0x0
field @RequiresPermission("android.car.permission.CONTROL_CAR_MIRRORS") public static final int MIRROR_FOLD = 287312709; // 0x11200b45
field @RequiresPermission("android.car.permission.CONTROL_CAR_MIRRORS") public static final int MIRROR_LOCK = 287312708; // 0x11200b44
field @RequiresPermission("android.car.permission.CONTROL_CAR_MIRRORS") public static final int MIRROR_Y_MOVE = 339741507; // 0x14400b43
field @RequiresPermission("android.car.permission.CONTROL_CAR_MIRRORS") public static final int MIRROR_Y_POS = 339741506; // 0x14400b42
field @RequiresPermission("android.car.permission.CONTROL_CAR_MIRRORS") public static final int MIRROR_Z_MOVE = 339741505; // 0x14400b41
field @RequiresPermission("android.car.permission.CONTROL_CAR_MIRRORS") public static final int MIRROR_Z_POS = 339741504; // 0x14400b40
field @RequiresPermission(android.car.Car.PERMISSION_EXTERIOR_ENVIRONMENT) public static final int NIGHT_MODE = 287310855; // 0x11200407
field @RequiresPermission("android.car.permission.CAR_DIAGNOSTICS") public static final int OBD2_FREEZE_FRAME = 299896065; // 0x11e00d01
field @RequiresPermission("android.car.permission.CLEAR_CAR_DIAGNOSTICS") public static final int OBD2_FREEZE_FRAME_CLEAR = 299896067; // 0x11e00d03
field @RequiresPermission("android.car.permission.CAR_DIAGNOSTICS") public static final int OBD2_FREEZE_FRAME_INFO = 299896066; // 0x11e00d02
field @RequiresPermission("android.car.permission.CAR_DIAGNOSTICS") public static final int OBD2_LIVE_FRAME = 299896064; // 0x11e00d00
field @RequiresPermission(android.car.Car.PERMISSION_POWERTRAIN) public static final int PARKING_BRAKE_AUTO_APPLY = 287310851; // 0x11200403
field @RequiresPermission(android.car.Car.PERMISSION_POWERTRAIN) public static final int PARKING_BRAKE_ON = 287310850; // 0x11200402
field @RequiresPermission("android.car.permission.CAR_MILEAGE") public static final int PERF_ODOMETER = 291504644; // 0x11600204
field @RequiresPermission(android.car.Car.PERMISSION_READ_STEERING_STATE) public static final int PERF_REAR_STEERING_ANGLE = 291504656; // 0x11600210
field @RequiresPermission(android.car.Car.PERMISSION_READ_STEERING_STATE) public static final int PERF_STEERING_ANGLE = 291504649; // 0x11600209
field @RequiresPermission(android.car.Car.PERMISSION_SPEED) public static final int PERF_VEHICLE_SPEED = 291504647; // 0x11600207
field @RequiresPermission(android.car.Car.PERMISSION_SPEED) public static final int PERF_VEHICLE_SPEED_DISPLAY = 291504648; // 0x11600208
field @RequiresPermission.Read(@androidx.annotation.RequiresPermission(android.car.Car.PERMISSION_ENERGY)) @RequiresPermission.Write(@androidx.annotation.RequiresPermission("android.car.permission.ADJUST_RANGE_REMAINING")) public static final int RANGE_REMAINING = 291504904; // 0x11600308
field @RequiresPermission(android.car.Car.PERMISSION_READ_INTERIOR_LIGHTS) public static final int READING_LIGHTS_STATE = 356519683; // 0x15400f03
field @RequiresPermission(android.car.Car.PERMISSION_CONTROL_INTERIOR_LIGHTS) public static final int READING_LIGHTS_SWITCH = 356519684; // 0x15400f04
field @RequiresPermission("android.car.permission.CAR_EXTERIOR_LIGHTS") public static final int REAR_FOG_LIGHTS_STATE = 289410877; // 0x11400f3d
field @RequiresPermission("android.car.permission.CONTROL_CAR_EXTERIOR_LIGHTS") public static final int REAR_FOG_LIGHTS_SWITCH = 289410878; // 0x11400f3e
field @RequiresPermission("android.car.permission.CONTROL_CAR_SEATS") public static final int SEAT_BACKREST_ANGLE_1_MOVE = 356518792; // 0x15400b88
field @RequiresPermission("android.car.permission.CONTROL_CAR_SEATS") public static final int SEAT_BACKREST_ANGLE_1_POS = 356518791; // 0x15400b87
field @RequiresPermission("android.car.permission.CONTROL_CAR_SEATS") public static final int SEAT_BACKREST_ANGLE_2_MOVE = 356518794; // 0x15400b8a
field @RequiresPermission("android.car.permission.CONTROL_CAR_SEATS") public static final int SEAT_BACKREST_ANGLE_2_POS = 356518793; // 0x15400b89
field @RequiresPermission("android.car.permission.CONTROL_CAR_SEATS") public static final int SEAT_BELT_BUCKLED = 354421634; // 0x15200b82
field @RequiresPermission("android.car.permission.CONTROL_CAR_SEATS") public static final int SEAT_BELT_HEIGHT_MOVE = 356518788; // 0x15400b84
field @RequiresPermission("android.car.permission.CONTROL_CAR_SEATS") public static final int SEAT_BELT_HEIGHT_POS = 356518787; // 0x15400b83
field @RequiresPermission("android.car.permission.CONTROL_CAR_SEATS") public static final int SEAT_DEPTH_MOVE = 356518798; // 0x15400b8e
field @RequiresPermission("android.car.permission.CONTROL_CAR_SEATS") public static final int SEAT_DEPTH_POS = 356518797; // 0x15400b8d
field @RequiresPermission("android.car.permission.CONTROL_CAR_SEATS") public static final int SEAT_FORE_AFT_MOVE = 356518790; // 0x15400b86
field @RequiresPermission("android.car.permission.CONTROL_CAR_SEATS") public static final int SEAT_FORE_AFT_POS = 356518789; // 0x15400b85
field @RequiresPermission("android.car.permission.CONTROL_CAR_SEATS") public static final int SEAT_HEADREST_ANGLE_MOVE = 356518808; // 0x15400b98
field @RequiresPermission("android.car.permission.CONTROL_CAR_SEATS") public static final int SEAT_HEADREST_ANGLE_POS = 356518807; // 0x15400b97
field @RequiresPermission("android.car.permission.CONTROL_CAR_SEATS") public static final int SEAT_HEADREST_FORE_AFT_MOVE = 356518810; // 0x15400b9a
field @RequiresPermission("android.car.permission.CONTROL_CAR_SEATS") public static final int SEAT_HEADREST_FORE_AFT_POS = 356518809; // 0x15400b99
field @RequiresPermission("android.car.permission.CONTROL_CAR_SEATS") public static final int SEAT_HEADREST_HEIGHT_MOVE = 356518806; // 0x15400b96
field @RequiresPermission("android.car.permission.CONTROL_CAR_SEATS") public static final int SEAT_HEADREST_HEIGHT_POS = 289409941; // 0x11400b95
field @RequiresPermission("android.car.permission.CONTROL_CAR_SEATS") public static final int SEAT_HEIGHT_MOVE = 356518796; // 0x15400b8c
field @RequiresPermission("android.car.permission.CONTROL_CAR_SEATS") public static final int SEAT_HEIGHT_POS = 356518795; // 0x15400b8b
field @RequiresPermission("android.car.permission.CONTROL_CAR_SEATS") public static final int SEAT_LUMBAR_FORE_AFT_MOVE = 356518802; // 0x15400b92
field @RequiresPermission("android.car.permission.CONTROL_CAR_SEATS") public static final int SEAT_LUMBAR_FORE_AFT_POS = 356518801; // 0x15400b91
field @RequiresPermission("android.car.permission.CONTROL_CAR_SEATS") public static final int SEAT_LUMBAR_SIDE_SUPPORT_MOVE = 356518804; // 0x15400b94
field @RequiresPermission("android.car.permission.CONTROL_CAR_SEATS") public static final int SEAT_LUMBAR_SIDE_SUPPORT_POS = 356518803; // 0x15400b93
field @RequiresPermission("android.car.permission.CONTROL_CAR_SEATS") public static final int SEAT_MEMORY_SELECT = 356518784; // 0x15400b80
field @RequiresPermission("android.car.permission.CONTROL_CAR_SEATS") public static final int SEAT_MEMORY_SET = 356518785; // 0x15400b81
field @RequiresPermission("android.car.permission.CONTROL_CAR_SEATS") public static final int SEAT_OCCUPANCY = 356518832; // 0x15400bb0
field @RequiresPermission("android.car.permission.CONTROL_CAR_SEATS") public static final int SEAT_TILT_MOVE = 356518800; // 0x15400b90
field @RequiresPermission("android.car.permission.CONTROL_CAR_SEATS") public static final int SEAT_TILT_POS = 356518799; // 0x15400b8f
field @RequiresPermission("android.car.permission.STORAGE_ENCRYPTION_BINDING_SEED") public static final int STORAGE_ENCRYPTION_BINDING_SEED = 292554247; // 0x11700607
field @RequiresPermission("android.car.permission.CAR_TIRES") public static final int TIRE_PRESSURE = 392168201; // 0x17600309
field @RequiresPermission.Read(@androidx.annotation.RequiresPermission(android.car.Car.PERMISSION_READ_DISPLAY_UNITS)) @RequiresPermission.Write(@androidx.annotation.RequiresPermission(allOf={android.car.Car.PERMISSION_CONTROL_DISPLAY_UNITS, "android.car.permission.CAR_VENDOR_EXTENSION"})) public static final int TIRE_PRESSURE_DISPLAY_UNITS = 289408514; // 0x11400602
field @RequiresPermission("android.car.permission.CAR_DYNAMICS_STATE") public static final int TRACTION_CONTROL_ACTIVE = 287310859; // 0x1120040b
field @RequiresPermission.Read(@androidx.annotation.RequiresPermission(android.car.Car.PERMISSION_PRIVILEGED_CAR_INFO)) public static final int TRAILER_PRESENT = 289410885; // 0x11400f45
field @RequiresPermission("android.car.permission.CAR_EXTERIOR_LIGHTS") public static final int TURN_SIGNAL_STATE = 289408008; // 0x11400408
field @RequiresPermission.Read(@androidx.annotation.RequiresPermission(android.car.Car.PERMISSION_PRIVILEGED_CAR_INFO)) public static final int VEHICLE_CURB_WEIGHT = 289410886; // 0x11400f46
field @RequiresPermission(anyOf={"android.car.permission.VMS_PUBLISHER", "android.car.permission.VMS_SUBSCRIBER"}) public static final int VEHICLE_MAP_SERVICE = 299895808; // 0x11e00c00
field @RequiresPermission.Read(@androidx.annotation.RequiresPermission(android.car.Car.PERMISSION_READ_DISPLAY_UNITS)) @RequiresPermission.Write(@androidx.annotation.RequiresPermission(allOf={android.car.Car.PERMISSION_CONTROL_DISPLAY_UNITS, "android.car.permission.CAR_VENDOR_EXTENSION"})) public static final int VEHICLE_SPEED_DISPLAY_UNITS = 289408516; // 0x11400604
field @RequiresPermission(android.car.Car.PERMISSION_SPEED) public static final int WHEEL_TICK = 290521862; // 0x11510306
field @RequiresPermission("android.car.permission.CONTROL_CAR_WINDOWS") public static final int WINDOW_LOCK = 320867268; // 0x13200bc4
field @RequiresPermission("android.car.permission.CONTROL_CAR_WINDOWS") public static final int WINDOW_MOVE = 322964417; // 0x13400bc1
field @RequiresPermission("android.car.permission.CONTROL_CAR_WINDOWS") public static final int WINDOW_POS = 322964416; // 0x13400bc0
}
2.2.2 模拟驾驶事件
如需将速度设置为 0,请运行以下命令:
adb shell cmd car_service inject-vhal-event 0x11600207 0
adb shell dumpsys activity service com.android.car inject-vhal-event 0x11600207 0
如需将档位设置为“停车”(模拟指向“PARKED”
的 CarDrivingStateEvent ),请运行以下命令:
adb shell cmd car_service inject-vhal-event 0x11400400 4
adb shell dumpsys activity service com.android.car inject-vhal-event 0x11400400 4
如需将档位设置为“行驶”,而使速度仍为 0(模拟指向“IDLING”
的 CarDrivingStateEvent ),请运行以下命令:
adb shell cmd car_service inject-vhal-event 0x11400400 8
adb shell dumpsys activity service com.android.car inject-vhal-event 0x11400400 8
如需将速度设为每秒 30 米(模拟指向“MOVING”
的 CarDrivingStateEvent ),请运行以下命令:
adb shell cmd car_service inject-vhal-event 0x11600207 30
adb shell dumpsys activity service com.android.car inject-vhal-event 0x11600207 30
2.3 cmd car_service inject-error-event 注入错误vhal信号事件
inject-error-event property zone errorCode
Inject an error event from VHAL for testing.
2.4 cmd car_service get-carpropertyconfig 获取车辆CarPropertyConfigs
get-carpropertyconfig [propertyId]
Get a CarPropertyConfig by Id in Hex or list all CarPropertyConfigs
2.5 cmd car_service get-property-value 获取车辆属性值
get-property-value [propertyId] [areaId]
Get a vehicle property value by property id in Hex and areaId
or list all property values for all areaId
2.6 cmd car_service inject-key 注入KeyEvent事件
inject-key [-d display] [-t down_delay_ms | -a down|up] key_code
inject rotary input event to car service.
display: 0 for main, 1 for cluster. If not specified, it will be 0.
down_delay_ms: delay from down to up key event. If not specified, it will be 0
key_code: int key code defined in android KeyEvent
If -a isn’t specified, both down and up will be injected.
2.7 cmd car_service inject-rotary 模拟旋控器事件
inject-rotary [-d display] [-i input_type] [-c clockwise] [-dt delta_times_ms]
inject rotary input event to car service.
display: 0 for main, 1 for cluster. If not specified, it will be 0.
input_type: 10 for navigation controller input, 11 for volume controller input. If not specified, it will be 10.
clockwise: true if the event is clockwise, false if the event is counter-clockwise. If not specified, it will be false.
delta_times_ms: a list of delta time (current time minus event time) in descending order. If not specified, it will be 0.
car_service 命令 | 旋转输入 |
---|---|
adb shell cmd car_service inject-rotary | 逆时针旋转 |
adb shell cmd car_service inject-rotary -c true | 顺时针旋转 |
adb shell cmd car_service inject-rotary -dt 100 50 | 逆时针旋转多次(100 毫秒前和 50 毫秒前) |
adb shell cmd car_service inject-key 282 | 向左微移 |
adb shell cmd car_service inject-key 283 | 向右微移 |
adb shell cmd car_service inject-key 280 | 向上微移 |
adb shell cmd car_service inject-key 281 | 向下微移 |
adb shell cmd car_service inject-key 23 | 点击居中的按钮 |
adb shell input keyevent inject-key 4 | 点击返回按钮 |