上篇说到AAOS14 (Android Automotive OS 14)环境搭建完毕,今天记录一下操作模拟器多屏的过程。
从Android Automotive OS 14 Releases看,第一项更新重点介绍了Car Framework Display and Window Manager
,比如在multi-user方面的更新:
从目前的新能源车型看,越来越多的车型,配置了丰富的车内屏幕,比如仪表屏,中控屏,副驾屏,后排屏,车顶折叠屏,空调控制屏,扶手屏等等;
应该说是车的屏幕越来越多了,至于他们使用的多屏方案是否是基于AAOS,就不得而知了。
Google应该也意识到,车企对多屏功能的要求正在不断提高,所以AAOS方案也在逐步完善这方面的功能;
AAOS从最早的multi-display
,multi-zone
,再到最新multi-user
的CarSystemUI
,IME
,Lock Screen
等场景的,一直在迭代升级,里面很多的代码需要学习。
从上篇下载的模拟器运行情况看,默认sdk_car_x86_64-userdebug
工程并没有展示多屏幕,只是一个单屏幕。
经过源码阅读发现,Google 在2022年已经有一笔提交了,Add a sdk_car_md_x86_64 configuration.
,是关于建立multi-display的,不过一直没有注意;
说明AAOS14模拟器对于Car已经支持multi-display
看到这里了,主要阅读一下,和sdk_car_x86_64
区别
代码路径:Z:\aosp\device\generic\car
$(call inherit-product, device/generic/car/common/car_md.mk)
$(call inherit-product, device/generic/car/sdk_car_x86_64.mk)
...
PRODUCT_NAME := sdk_car_md_x86_64
PRODUCT_DEVICE := emulator_car64_x86_64
PRODUCT_BRAND := Android
PRODUCT_MODEL := Car multi-display on x86_64 emulator
...
Makefile中引入了一个新的文件:car_md.mk
,主要关注内容:
# this overwrites Android Emulator's default input devices for virtual displays in device/generic/goldfish/input/
PRODUCT_COPY_FILES += \
device/generic/car/emulator/multi-display/input/virtio_input_multi_touch_7.idc:$(TARGET_COPY_OUT_VENDOR)/usr/idc/virtio_input_multi_touch_7.idc \
device/generic/car/emulator/multi-display/input/virtio_input_multi_touch_8.idc:$(TARGET_COPY_OUT_VENDOR)/usr/idc/virtio_input_multi_touch_8.idc \
device/generic/car/emulator/multi-display/input/virtio_input_multi_touch_9.idc:$(TARGET_COPY_OUT_VENDOR)/usr/idc/virtio_input_multi_touch_9.idc
# Overrides Goldfish's default display settings
PRODUCT_COPY_FILES += \
device/generic/car/emulator/multi-display/display_layout_configuration.xml:$(TARGET_COPY_OUT_VENDOR)/etc/displayconfig/display_layout_configuration.xml \
device/generic/car/emulator/multi-display/display_settings.xml:$(TARGET_COPY_OUT_VENDOR)/etc/display_settings.xml
可以根据屏幕id配置是否显示IME,是否显示SystemDecors,具体参考文档:display_settings.xml
PRODUCT_COPY_FILES += \
frameworks/native/data/etc/android.software.managed_users.xml:$(TARGET_COPY_OUT_VENDOR)/etc/permissions/android.software.managed_users.xml
PRODUCT_PACKAGE_OVERLAYS += \
device/generic/car/emulator/multi-display/overlay
PRODUCT_PACKAGES += \
MultiDisplaySecondaryHomeTestLauncher \
MultiDisplayTest
config配置:
......
<bool name="config_perDisplayFocusEnabled">truebool>
<bool name="config_supportsSystemDecorsOnSecondaryDisplays">truebool>
<string name="config_secondaryHomePackage" translatable="false">com.android.car.multidisplaystring>
<bool name="config_multiuserVisibleBackgroundUsers">truebool>
......
PRODUCT_COPY_FILES += \
device/generic/car/emulator/multi-display/car_audio_configuration.xml:$(TARGET_COPY_OUT_VENDOR)/etc/car_audio_configuration.xml
PRODUCT_SYSTEM_DEFAULT_PROPERTIES += \
ro.vendor.simulateMultiZoneAudio=true \
persist.sys.max_profiles=5 \
com.android.car.internal.debug.num_auto_populated_users=1
具体命令:
cd aosp
source build/envsetup.sh
lunch sdk_car_md_x86_64-userdebug
make
运行模拟:
# 冷启动模拟器
emulator -no-snapshot
# 帮助文档
emulator -help
其他调试命令:
# 获取当前屏幕activity focus焦点信息
dumpsys activity activities |grep mFoc
# 启动app到指定屏幕
am start -n com.android.car.settings/.Settings_Launcher_Homepage --display 2
am start -n com.android.documentsui/.files.FilesActivity --display 3
am start -n com.android.contacts/.activities.PeopleActivity --display 4
# Display dump信息
dumpsys display
# display id信息
dumpsys SurfaceFlinger --display-id
# 截图四个屏
screencap -d 4619827259835644672 -p ./0.png
screencap -d 4619827551948147201 -p ./1.png
screencap -d 4619827124781842690 -p ./2.png
screencap -d 4619827540095559171 -p ./3.png
# 参考wm信息
wm size -d 0
wm density -d 0
阅读完相关文件,尝试了一些调试命令, 模拟器主要建立了四个屏幕:
除了内置cluster仪表屏幕,目前主流都是2K~4K屏,下面将分辨率改成1920x1080 220dpi ;
user@ubuntu:~/code/aosp/device/generic/car$ git diff
diff --git a/common/car_md.mk b/common/car_md.mk
old mode 100644
new mode 100755
index 4b5ed2b..8e108e3
--- a/common/car_md.mk
+++ b/common/car_md.mk
@@ -38,7 +38,7 @@ PRODUCT_COPY_FILES += \
EMULATOR_DYNAMIC_MULTIDISPLAY_CONFIG := false
BUILD_EMULATOR_CLUSTER_DISPLAY := true
# Set up additional displays
-EMULATOR_MULTIDISPLAY_HW_CONFIG := 1,968,792,160,0,2,1408,792,160,0,3,1408,792,160,0
+EMULATOR_MULTIDISPLAY_HW_CONFIG := 1,1320,1080,220,0,2,1920,1080,220,0,3,1920,1080,220,0
EMULATOR_MULTIDISPLAY_BOOTANIM_CONFIG := 4619827551948147201,4619827124781842690,4619827540095559171
ENABLE_CLUSTER_OS_DOUBLE:=true
diff --git a/common/config.ini.car_md b/common/config.ini.car_md
old mode 100644
new mode 100755
index 74e6abe..bb11221
--- a/common/config.ini.car_md
+++ b/common/config.ini.car_md
@@ -1,5 +1,5 @@
hw.audioInput=yes
-hw.lcd.density=160
+hw.lcd.density=220
hw.cpu.ncore=6
hw.gpu.enabled=yes
hw.camera.back=none
@@ -8,8 +8,8 @@ hw.mainKeys=no
hw.ramSize=6144
hw.keyboard=yes
skin.dynamic=yes
-skin.name=1848x792
-skin.path=1848x792
+skin.name=1920x1080
+skin.path=1920x1080
disk.dataPartition.size=6G
hw.accelerometer=yes
hw.accelerometer_uncalibrated=yes
diff --git a/emulator/multi-display/display_settings.xml b/emulator/multi-display/display_settings.xml
old mode 100644
new mode 100755
index 8f63b42..3373fe1
--- a/emulator/multi-display/display_settings.xml
+++ b/emulator/multi-display/display_settings.xml
@@ -5,19 +5,19 @@
+ forcedDensity="220" />
+ forcedDensity="220" />
综上所述,梳理完成了multi-display配置,修改完多屏分辨率,为后续系统应用开发做好准备。
欢迎关注我的微信公众号阿坤iKun
,我是练习时长两年半的阿坤iKun
,下期再见!