您现在的位置是:首页 >技术交流 >Android 12系统源码_CarService(一)CarService的基本架构网站首页技术交流

Android 12系统源码_CarService(一)CarService的基本架构

AFinalStone 2023-06-16 12:00:02
简介Android 12系统源码_CarService(一)CarService的基本架构

前言

1、Google官网上是这样介绍汽车架构的。

在这里插入图片描述

  • Car App:包括OEM和第三方开发的App
  • Car API:内有包含 CarSensorManager 在内的 API。位于 /platform/packages/services/Car/car-lib。
  • CarService:系统中与车相关的服务,位于 /platform/packages/services/Car/目录。
  • 车载 HAL:用于定义 OEM 可以实现的车辆属性的接口。包含属性元数据(例如,车辆属性是否为 int 以及允许使用哪些更改模式)。位于 hardware/libhardware/include/hardware/vehicle.h。如需了解基本参考实现,请参阅 hardware/libhardware/modules/vehicle/。

2、 Framework CarService

1、Android O/P为Automotive场景提供了一系列的服务,这些服务统被称为CarService。它们与HAL层的VehicleHAL通信,进而通过车载总线(例如CAN总线)与车身进行通讯,同时它们还为应用层的APP提供接口,从而让APP能够实现对车身的控制与状态的显示。
在这里插入图片描述

  • Car***Manage位于packages/services/Car/car-lib/src/android/car/hardware目录,
  • Car***Service位于packages/services/Car/service/src/com/android/car目录。

一、目录结构

1、CarService主要位于packages/services/Car/目录。

├── Android.mk
├── apicheck.mk
├── apicheck_msg_current.txt
├── apicheck_msg_last.txt
├── car-cluster-logging-renderer    //LoggingClusterRenderingService继承InstrumentClusterRenderingService
├── car-default-input-service   //按键消息处理
├── car-lib         //提供给汽车App特有的接口,许多定制的模块都在这里实现,包括Sensor,HVAC,Cabin,ActiveParkingAssiance,Diagnostic,Vendor等
├── car-maps-placeholder    //地图软件相关
├── car_product         //系统编译相关
├── car-support-lib     //android.support.car
├── car-systemtest-lib  //系统测试相关
├── car-usb-handler     //开机自启,用于管理车机USB
├── CleanSpec.mk
├── evs  
├── obd2-lib
├── PREUPLOAD.cfg
├── procfs-inspector
├── service    //com.android.car是一个后台运行的组件,可以长时间运行并且不需要和用户去交互的,这里即使应用被销毁,它也可以正常工作
├── tests
├── tools   //是一系列的工具,要提到的是里面的emulator,测试需要用到的。python写的,通过adb可以连接vehicleHal的工具,用于模拟测试
├── TrustAgent
└── vehicle-hal-support-lib

2、Car APP

1、Car APP的相关源码位于packages/apps/Car/目录,其中packages/services/Car/car_product/build/car.mk里面决定了需要编译哪些相关apk(system/priv-app)。

packages/services/Car/car_product/build/car.mk

# Common make file for all car builds

PRODUCT_PUBLIC_SEPOLICY_DIRS += packages/services/Car/car_product/sepolicy/public
PRODUCT_PRIVATE_SEPOLICY_DIRS += packages/services/Car/car_product/sepolicy/private

PRODUCT_PACKAGES += 
    Bluetooth 
    CarActivityResolver 
    CarDeveloperOptions 
    CarSettingsIntelligence 
    CarManagedProvisioning 
    OneTimeInitializer 
    CarProvision 
    StatementService 
    SystemUpdater


PRODUCT_PACKAGES += 
    clatd 
    pppd 
    screenrecord

# This is for testing
ifneq (,$(filter userdebug eng, $(TARGET_BUILD_VARIANT)))
PRODUCT_PACKAGES += 
    DefaultStorageMonitoringCompanionApp 
    EmbeddedKitchenSinkApp 
    GarageModeTestApp 
    ExperimentalCarService 
    BugReportApp 
    NetworkPreferenceApp 
    SampleCustomInputService 
    AdasLocationTestApp 
    curl 

# SEPolicy for test apps / services
BOARD_SEPOLICY_DIRS += packages/services/Car/car_product/sepolicy/test
endif

# ClusterOsDouble is the testing app to test Cluster2 framework and it can handle Cluster VHAL
# and do some Cluster OS role.
ifeq ($(ENABLE_CLUSTER_OS_DOUBLE), true)
PRODUCT_PACKAGES += ClusterHomeSample ClusterOsDouble
else
# DirectRenderingCluster is the sample app for the old Cluster framework.
PRODUCT_PACKAGES += DirectRenderingCluster
endif  # ENABLE_CLUSTER_OS_DOUBLE

PRODUCT_COPY_FILES += 
    frameworks/av/media/libeffects/data/audio_effects.conf:system/etc/audio_effects.conf

PRODUCT_PROPERTY_OVERRIDES += 
    persist.bluetooth.enablenewavrcp=false 
    ro.carrier=unknown

PRODUCT_SYSTEM_DEFAULT_PROPERTIES += 
    config.disable_systemtextclassifier=true

###
### Suggested values for multi-user properties - can be overridden
###

# Enable headless system user mode
PRODUCT_SYSTEM_DEFAULT_PROPERTIES += 
    ro.fw.mu.headless_system_user?=true

# Enable user pre-creation
PRODUCT_SYSTEM_DEFAULT_PROPERTIES += 
    android.car.number_pre_created_users?=1 
    android.car.number_pre_created_guests?=1

# Enable User HAL integration
# NOTE: when set to true, VHAL must also implement the user-related properties,
# otherwise CarService will ignore it
PRODUCT_SYSTEM_DEFAULT_PROPERTIES += 
    android.car.user_hal_enabled?=true

### end of multi-user properties ###

# Overlay for Google network and fused location providers
$(call inherit-product, device/sample/products/location_overlay.mk)
$(call inherit-product-if-exists, frameworks/webview/chromium/chromium.mk)
$(call inherit-product, packages/services/Car/car_product/build/car_base.mk)

# Overrides
PRODUCT_BRAND := generic
PRODUCT_DEVICE := generic
PRODUCT_NAME := generic_car_no_telephony

PRODUCT_IS_AUTOMOTIVE := true

PRODUCT_PROPERTY_OVERRIDES := 
    ro.config.ringtone=Girtab.ogg 
    ro.config.notification_sound=Tethys.ogg 
    ro.config.alarm_alert=Oxygen.ogg 
    $(PRODUCT_PROPERTY_OVERRIDES) 

PRODUCT_PROPERTY_OVERRIDES += 
    keyguard.no_require_sim=true

# TODO(b/205189147): Remove the following change after the proper fix is landed.
# Uses the local KeyGuard animation to resolve TaskView misalignment issue after display-on.
PRODUCT_SYSTEM_PROPERTIES += 
    persist.wm.enable_remote_keyguard_animation=0

# Automotive specific packages
PRODUCT_PACKAGES += 
    CarFrameworkPackageStubs 
    CarService 
    CarShell 
    CarDialerApp 
    CarRadioApp 
    OverviewApp 
    CarSystemUI 
    LocalMediaPlayer 
    CarMediaApp 
    CarMessengerApp 
    CarHTMLViewer 
    CarMapsPlaceholder 
    CarLatinIME 
    CarSettings 
    CarUsbHandler 
    android.car 
    car-frameworks-service 
    com.android.car.procfsinspector 
    libcar-framework-service-jni 
    ScriptExecutor 

# RROs
PRODUCT_PACKAGES += 
    CarPermissionControllerRRO 

# System Server components
# Order is important: if X depends on Y, then Y should precede X on the list.
PRODUCT_SYSTEM_SERVER_JARS += car-frameworks-service
# TODO: make the order optimal by appending 'car-frameworks-service' at the end
# after its dependency 'services'. Currently the order is violated because this
# makefile is included before AOSP makefile.
PRODUCT_BROKEN_SUBOPTIMAL_ORDER_OF_SYSTEM_SERVER_JARS := true

# Boot animation
PRODUCT_COPY_FILES += 
    packages/services/Car/car_product/bootanimations/bootanimation-832.zip:system/media/bootanimation.zip

PRODUCT_LOCALES := 
    en_US 
    af_ZA 
    am_ET 
    ar_EG ar_XB 
    as_IN 
    az_AZ 
    be_BY 
    bg_BG 
    bn_BD 
    bs_BA 
    ca_ES 
    cs_CZ 
    da_DK 
    de_DE 
    el_GR 
    en_AU en_CA en_GB en_IN en_XA 
    es_ES es_US 
    et_EE 
    eu_ES 
    fa_IR 
    fi_FI 
    fil_PH 
    fr_CA fr_FR 
    gl_ES 
    gu_IN 
    hi_IN 
    hr_HR 
    hu_HU 
    hy_AM 
    id_ID 
    is_IS 
    it_IT 
    iw_IL 
    ja_JP 
    ka_GE 
    kk_KZ 
    km_KH km_MH 
    kn_IN 
    ko_KR 
    ky_KG 
    lo_LA 
    lv_LV 
    lt_LT 
    mk_MK 
    ml_IN 
    mn_MN 
    mr_IN 
    ms_MY 
    my_MM 
    ne_NP 
    nl_NL 
    no_NO 
    or_IN 
    pa_IN 
    pl_PL 
    pt_BR pt_PT 
    ro_RO 
    ru_RU 
    si_LK 
    sk_SK 
    sl_SI 
    sq_AL 
    sr_RS 
    sv_SE 
    sw_TZ 
    ta_IN 
    te_IN 
    th_TH 
    tr_TR 
    uk_UA 
    ur_PK 
    uz_UZ 
    vi_VN 
    zh_CN zh_HK zh_TW 
    zu_ZA

PRODUCT_BOOT_JARS += 
    android.car

PRODUCT_HIDDENAPI_STUBS := 
    android.car-stubs-dex

PRODUCT_HIDDENAPI_STUBS_SYSTEM := 
    android.car-system-stubs-dex

PRODUCT_HIDDENAPI_STUBS_TEST := 
    android.car-test-stubs-dex

# Disable Prime Shader Cache in SurfaceFlinger to make it available faster
PRODUCT_PROPERTY_OVERRIDES += 
    service.sf.prime_shader_cache=0

风语者!平时喜欢研究各种技术,目前在从事后端开发工作,热爱生活、热爱工作。