Android CarService调试操作

dump CarService信息

car service信息包括如下内容

  • 使能的features
  • 当前电源策略及已注册的电源策略列表
  • 电源策略中各组件的电源状态
  • 静音模式状态
  • 车库模式状态
  • I/O统计
  • 可用车辆属性列表

获取可用的服务列表

$adb shell dumpsys car_service --list

获取指定服务的信息

$adb shell dumpsys car_service --services [service name]

获取所有服务信息

$adb shell dumpsys car_service

见:Android Automotive Service dump(上),(中上),(中下),(下)

CarService控制

car service支持如下命令:

  • 注入vhal事件
  • 开启/关闭车库模式
  • 暂停/休眠/恢复的切换
  • 注入input事件
  • 用户管理/切换
  • 电源策略控制/操作

查看CarService控制命令使用说明

$adb shell cmd car_service -h

复制代码
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 name in SCREAMING_SNAKE_CASE or ID in Hex or Decimal> [area ID] 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_ID in Hex or Decimal> zone <errorCode>
	  Inject an error event from VHAL for testing.
	inject-continuous-events <PROPERTY_ID in Hex or Decimal> data(can be comma separated list) [-z zone]  [-s SampleRate in Hz] [-d time duration in seconds]
	  Inject continuous vehicle events for testing.
	  If not specified, CarService will inject fake events with areaId:0 at sample rate 10 for 60 seconds.	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 [property name in SCREAMING_SNAKE_CASE or ID in Hex or Decimal]
	  Get a specific CarPropertyConfig or list all CarPropertyConfigs
	get-property-value [property name in SCREAMING_SNAKE_CASE or ID in Hex or Decimal] [areaId]
	  Get a vehicle property value by property id and areaId
	  or list all property values for all areaId
	set-property-value <property name in SCREAMING_SNAKE_CASE or ID in Hex or Decimal> <areaId> <data (can be comma-separated)>
	suspend [--auto|--simulate|--real] [--skip-garagemode] [--wakeup-after RESUME_DELAY | --cancel-after CANCEL_DELAY][--free-memory]
	  Suspend the system to RAM.
	  --real forces the device to perform suspend-to-RAM.
	  --simulate simulates suspend-to-RAM instead of putting the device into deep sleep.
	  --auto depending on the device capability, real or simulated suspend-to-RAM is performed.
	  --skip-garagemode skips Garage Mode before going into sleep.
	  --wakeup-after [RESUME_DELAY] wakes up the device RESUME_DELAY seconds after suspend.
	  --cancel-after [RESUME_DELAY] cancels the wake up after RESUME_DELAY seconds, if this flag is set, device will not go into suspend mode and wait in shutdown prepare for RESUME_DELAY seconds.
	hibernate [--auto|--simulate|--real] [--skip-garagemode] [--wakeup-after RESUME_DELAY | --cancel-after CANCEL_DELAY][--free-memory]
	  Suspend the system to disk.
	  --real forces the device to perform suspend-to-disk.
	  --simulate simulates suspend-to-disk instead of putting the device into hibernation.
	  --auto depending on the device capability, real or simulated suspend-to-disk is performed.
	  --skip-garagemode skips Garage Mode before going into hibernation.
	  --free-memory frees cached apps memory before simulating hibernation.
	resume
	  Wake the system up after a simulated suspension/hibernation.
	set-display-state [displayId] [true|false]
	  Turn on or off the individual display.
	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.
	reset-selected-volume-context
	  Resets the last selected volume context for volume changes.
	set-mute-car-volume-group [zoneId] [groupId] [mute\unmute]
	  mute\unmute groupId in zoneId
	set-group-volume [zoneId] [groupId] [volume]
	  sets the group volume for [groupId] in [zoneId] to %volume,
	  [volume] must be an integer between 0 to 100
	set-audio-mirror [zoneId1] [zoneId2]
	  sets audio mirror for zones [zoneId1] and [zoneId2],
	  [zoneId#] must be a valid zone id 
	unset-audio-mirror [value] [--requestId]
	  unsets audio mirror for zone [value],
	  [value] must be a valid zone id
	  use --requestId to disable a request id instead
	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] [-s seat] [-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.
	  seat: int seat value defined in VeihicleAreaSeat. 0 for unknown,
	      0x0001 for row1 left, 0x0002 for row1 center, 0x0004 for row1 right,
	      0x0010 for row2 left, 0x0020 for row2 center, 0x0040 for row2 right,
	      0x0100 for row3 left, 0x0200 for row3 center, 0x0400 for row3 right.
	      If not specified, it will be driver seat.
	  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-motion [-d display] [-s seat] [--source source] [-t down_delay_ms] [-a action] [-c count] [-p pointer_id0 pointer_id1...] x0 y0 x1 y1 ...
	  inject motion down or up or move or cancel event to car service
	  display: 0 for main, 1 for cluster. If not specified, it will be 0.
	  seat: int seat value defined in VeihicleAreaSeat. 0 for unknown,
	      0x0001 for row1 left, 0x0002 for row1 center, 0x0004 for row1 right,
	      0x0010 for row2 left, 0x0020 for row2 center, 0x0040 for row2 right,
	      0x0100 for row3 left, 0x0200 for row3 center, 0x0400 for row3 right.
	      If not specified, it will be driver seat.
	  source: string source value for motion event.
	          If not specified, it will be touchscreen
	          The sources are:
	              touchnavigation
	              touchscreen
	              joystick
	              stylus
	              touchpad
	              gamepad
	              dpad
	              mouse
	              keyboard
	              trackball
	  down_delay_ms: delay from down to up motion event. If not specified,
	      it will be 0
	  action: the MotionEvent.ACTION_* for the event. If not specified,
	      both down and up will be injected.
	      This can be a string value that is down|up|move|cancel
	      or an integer value that must equal to MotionEvent.ACTION_*.
	  count: the count of pointers. If not specified, it will be 1.
	      If this value is greater than 1, there must be as many pointer_id,
	      x, y as this value.
	  pointer_id: pointer ids of following coordinates, If not specified,
	      they are automatically set in order from 0.
	  x: int x coordinate in android MotionEvent
	  y: int y coordinate in android MotionEvent
	  Must provide the 'count' number of x, y pairs.
	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.
	inject-custom-input [-d display] [-r repeatCounter] EVENT
	  display: 0 for main, 1 for cluster. If not specified, it will be 0.
	  repeatCounter: number of times the button was hit (default value is 1)
	  EVENT: mandatory last argument. Possible values for for this flag are 
	         F1, F2, up to F10 (functions to defined by OEM partners)
	get-initial-user-info <REQ_TYPE> [--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] [--ignore-uxr] [--timeout TIMEOUT_MS]
	  Switches to user USER_ID using the HAL integration.
	  The --hal-only option only calls HAL, without switching the user,
	  The --ignore-uxr option ignores any Ux restriction regarding user switch,
	  while the --timeout defines how long to wait for the response.
	logout-user [--timeout TIMEOUT_MS]
	  Logout the current user (if the user was switched toby a device admin).
	  The --timeout option defines how long to wait for the UserHal 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] [--guest] [--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 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 default 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 default 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.
	set-start-bg-users-on-garage-mode [true|false]
	  Controls backgroud user start and stop during garage mode.
	  If false, garage mode operations (background users start at garage mode entry and background users stop at garage mode exit) will be skipped.
	  silent-mode [forced-silent|forced-non-silent|non-forced-silent-mode|query]
	  Forces silent mode silent or non-silent. With query (or no command) displays the silent state
	  and shows how many listeners are monitoring the state.
	emulate-driving-state [drive|park|reverse|neutral]
	  Emulates the giving driving state.
	define-power-policy <POLICY_ID> [--enable COMP1,COMP2,...] [--disable COMP1,COMP2,...]
	  Defines a power policy. Components not specified in --enable or --disable
	  are unchanged when the policy is applied.
	  Components should be comma-separated without space.
	apply-power-policy <POLICY_ID>
	  Applies power policy which is defined in /vendor/etc/automotive/power_policy.xml or
	  by define-power-policy command
	define-power-policy-group <POLICY_GROUP_ID> [WaitForVHAL:<POLICY_ID>] [On:<POLICY_ID>]
	  Defines a power policy group. The policy ID must be defined in advance.
	set-power-policy-group <POLICY_GROUP_ID>
	  Sets power policy group which is defined in /vendor/etc/automotive/power_policy.xml 
	  or by define-power-policy-group command
	apply-cts-verifier-power-off-policy
	  Define and apply the cts_verifier_off power policy with --disable WIFI,LOCATION,BLUETOOTH
	apply-cts-verifier-power-on-policy
	  Define and apply the cts_verifier_on power policy with --enable WIFI,LOCATION,BLUETOOTH
	get-current-power-policy
	  Gets the current power policy.
	power-off [--skip-garagemode] [--reboot]
	  Powers off the car.
	set-rearview-camera-id <REARVIEW_CAMERA_ID>
	  Configures a target camera device CarEvsService to use.
	  If CAMEAR_ID is "default", this command will configure CarEvsService 
	  to use its default camera device.
	get-rearview-camera-id
	  Gets the name of the camera device CarEvsService is using for the rearview.
	set-camera-id <SERVICE_TYPE> <CAMERA_ID>
	 Configures a target camera device CarEvsService will use for a specified 
	 service type.
	 Possible SERVICE_TYPEs are REARVIEW, FRONTVIEW, LEFTVIEW, RIGHTVIEW, 
	 DRIVERVIEW, FRONT_PASSENGERSVIEW, REAR_PASSENGERSVIEW, or USER_DEFINED
	 (* of CarEvsManager.SERVICE_TYPE_* to specify a service type).
	get-camera-id <SERVICE_TYPE>
	 Gets the name of the camera device that is assigned to a specified 
	 service type.
	 Possible SERVICE_TYPEs are REARVIEW, FRONTVIEW, LEFTVIEW, RIGHTVIEW, 
	 DRIVERVIEW, FRONT_PASSENGERSVIEW, REAR_PASSENGERSVIEW, or USER_DEFINED
	 (* of CarEvsManager.SERVICE_TYPE_* to specify a service type).
	enable-camera-service-type <SERVICE_TYPE> <CAMERA_ID>
	 Enables a specified service type with a camera associated with a given 
	 camera id.
	 Use * of CarEvsManager.SERVICE_TYPE_* to specify a service type.
	check-camera-service-type-enabled <SERVICE_TYPE>
	 Checks whether or not a given service type is enabled.
	 Use * of CarEvsManager.SERVICE_TYPE_* to specify a service type.
	watchdog-control-package-killable-state true|false <PACKAGE_NAME>
	  Marks PACKAGE_NAME as killable or not killable on resource overuse 
	watchdog-io-set-3p-foreground-bytes <FOREGROUND_MODE_BYTES>
	  Sets third-party apps foreground I/O overuse threshold
	watchdog-io-get-3p-foreground-bytes
	  Gets third-party apps foreground I/O overuse threshold
	watchdog-control-health-check enable|disable
	  Enables/disables car watchdog process health check.
	watchdog-resource-overuse-kill <PACKAGE_NAME> [--user USER_ID]
	  Kills PACKAGE_NAME due to resource overuse.
	set-drivingsafety-region [REGION_STRING]	  Set driving safety region.
	  Skipping REGION_STRING leads into resetting to all regions
	telemetry <subcommand>	  Telemetry commands.
	  Provide -h to see the list of sub-commands.
	control-component-enabled-state get|default|enable|disable_until_used <PACKAGE_NAME>
	  Gets the current EnabledState, or changes the Application EnabledState to DEFAULT, ENABLED or DISABLED_UNTIL_USED.
	check-lock-is-secure [user]
	  check if the current or given user has a lock to secure
	list-vhal-props	  list all supported property IDS by vehicle HAL
	get-vhal-backend	  list whether we are connected to AIDL or HIDL vehicle HAL backend
	test-echo-reverse-bytes <PROP_ID> <REQUEST_SIZE>	  test the ECHO_REVERSE_BYTES property. PROP_ID is the ID (int) for ECHO_REVERSE_BYTES, REQUEST_SIZE is how many byteValues in the request. This command can be used for testing LargeParcelable by passing large request.
	get-target-car-version [--user USER] <APP1> [APPN]	  Gets the target API version (major and minor) defined by the given apps for the given user (or current user when --user is not set).
	set-process-group <PID> <CPU_GROUP_ID>	 Change CPU group of a process. Check android.os.Process.setProcessGroup for details on the parameters.
	get-process-group <PID>	 Get the CPU group of a process. Check android.os.Process.getProcessGroup for details on the parameters.
	set-process-profile <PID> <UID> <CPU_PROFILE>	 Change CPU profile (=CPUSet) of a process. Check android.os.Process.setProcessProfile for details on the parameters.
	get-display-by-user <USER>	 Gets the display associated to the given user
	get-user-by-display <DISPLAY>	 Gets the user associated with the given display
	assign-extra-display <USER_ID> <DISPLAY_ID>	 Assigns the user to the extra display.
	unassign-extra-display <USER_ID> <DISPLAY_ID>	 Unassigns the user from the extra display.
	get-current-ux-restrictions <DISPLAY>	 Gets the current UX restriction on given display. If no display is provided, return current UX restrictions on default display.
	set-current-uxr-mode <mode>	 Sets current mode for UX restrictions.
	get-current-uxr-mode	 Gets current mode for UX restrictions.
	get-supported-uxr-modes	 Gets all supported UX restrictions modes.
	get-uxr-config	 Gets UX restrictions configuration.
	get-input-and-display-info	 Gets input devices & their descriptor; and gets display devices & their uniqueId
	add-input-descriptor-association-to-display-unique-id <input descriptor> <display unique id>	 Add association of the input device to the particular display by using input descriptor.
	remove-input-descriptor-association <input descriptor>	 Remove association of the input device descriptor to any display.

注入vhal事件

注入input事件

开/关车库模式

暂停/休眠/恢复切换

管理/切换用户

操作电源策略

库模式相关操作

查询车库模式状态

$adb shell cmd car_service garage-mode query

强制进入车库模式

$adb shell cmd car_service garage-mode on

强制退出车库模式

$adb shell cmd car_service garage-mode off

使用"重启"功能

进入"车库模式",完成时进行重启

$adb shell cmd car_service garage-mode reboot

相关推荐
千里马-horse4 小时前
在android中 spdlog库的log如何在控制台上输出
android·c++·spdlog
Zender Han4 小时前
《从零搭建现代 Android 模块化架构项目(2025 最新实践)》
android·架构
Digitally4 小时前
如何从电脑上卸载安卓应用程序
android·电脑
Mr YiRan5 小时前
多线程性能优化基础
android·java·开发语言·性能优化
liyi_hz20085 小时前
O2OA (翱途)开发平台新版本发布预告:架构升级、性能跃迁、功能全面进化
android·java·javascript·开源软件
Huangyi5 小时前
第一节:Flow的基础知识
android·前端·kotlin
hweiyu005 小时前
Android基础入门教程(视频教程)
android
冻咸鱼9 小时前
MySQL中表操作
android·sql·mysql·oracle
技术小黑屋_9 小时前
从零搭建 Android ADB MCP Server:让 AI 助手直接操控你的 Android 设备
android·adb