IVIVehicleService启动
Posted xhBruce
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了IVIVehicleService启动相关的知识,希望对你有一定的参考价值。
【IVI】VehicleService启动
android12-release
Android Automotive OS知识体系
1、rc文件android.hardware.automotive.vehicle@2.0-service.rc
VehicleService进程名:vendor.vehicle-hal-2.0
bin文件:/vendor/bin/hw/android.hardware.automotive.vehicle@2.0-service
对应启动入口:hardware/interfaces/automotive/vehicle/2.0/default/VehicleService.cpp
hardware/interfaces/automotive/vehicle/2.0/default/android.hardware.automotive.vehicle@2.0-service.rc
service vendor.vehicle-hal-2.0 /vendor/bin/hw/android.hardware.automotive.vehicle@2.0-service
class hal
user vehicle_network
group system inet
hardware/interfaces/automotive/vehicle/2.0/default/android.hardware.automotive.vehicle@2.0-service.xml
<manifest version="1.0" type="device">
<hal format="hidl">
<name>android.hardware.automotive.vehicle</name>
<transport>hwbinder</transport>
<version>2.0</version>
<interface>
<name>IVehicle</name>
<instance>default</instance>
</interface>
</hal>
</manifest>
2、VehicleService.cpp#main()启动
- EmulatedVehicleConnector继承VehicleHalClient、VehicleHalServer(即是
IVehicleServer、IVehicleClient
) hal = std::make_unique<impl::EmulatedVehicleHal>(store.get(), connector.get(), userHal)
与VehicleHal通行,EmulatedVehicleHal最终继承VehicleHalconfigureRpcThreadpool、joinRpcThreadpool
组队出现的东西,libhidl
库,用于自动生成HIDL语言,并辅助服务添加到hwbinder域
VehicleHalManager
继承IVehicle
,再查看service->registerAsService()
注册到/dev/hwbinder
并添加到defaultServiceManager()
int main(int /* argc */, char* /* argv */ [])
auto store = std::make_unique<VehiclePropertyStore>();
auto connector = std::make_unique<impl::EmulatedVehicleConnector>();
auto userHal = connector->getEmulatedUserHal();
auto hal = std::make_unique<impl::EmulatedVehicleHal>(store.get(), connector.get(), userHal);
auto emulator = std::make_unique<impl::VehicleEmulator>(hal.get());
auto service = std::make_unique<VehicleHalManager>(hal.get());
connector->setValuePool(hal->getValuePool());
configureRpcThreadpool(4, true /* callerWillJoin */);
ALOGI("Registering as service...");
status_t status = service->registerAsService();
if (status != OK)
ALOGE("Unable to register vehicle service (%d)", status);
return 1;
ALOGI("Ready");
joinRpcThreadpool();
return 1;
2.1 libhidl、libhwbinder路径
Binder 域
system/libhidl/transport/HidlTransportSupport.cpp
system/libhidl/transport/include/hidl/HidlTransportSupport.h
system/libhidl/transport/ServiceManagement.cpp
system/libhidl/transport/include/hidl/ServiceManagement.h
system/libhwbinder/ProcessState.cpp
system/libhwbinder/IPCThreadState.cpp
2.2 hidl-gen自动生成代码文件Bp、Bn端:types.hal、IVehicle.hal、IVehicleCallback.hal
// This file is autogenerated by hidl-gen -Landroidbp.
package
// See: http://go/android-license-faq
// A large-scale-change added 'default_applicable_licenses' to import
// all of the 'license_kinds' from "hardware_interfaces_license"
// to get the below license kinds:
// SPDX-license-identifier-Apache-2.0
default_applicable_licenses: ["hardware_interfaces_license"],
hidl_interface
name: "android.hardware.automotive.vehicle@2.0",
root: "android.hardware",
srcs: [
"types.hal",
"IVehicle.hal",
"IVehicleCallback.hal",
],
interfaces: [
"android.hidl.base@1.0",
],
gen_java: true,
3、时序图
4. 上层调用
packages/services/Car/service/src/com/android/car/CarService.java
private static IVehicle getVehicle()
final String instanceName = SystemProperties.get("ro.vehicle.hal", "default");
try
return android.hardware.automotive.vehicle.V2_0.IVehicle.getService(instanceName);
catch (RemoteException e)
Slog.e(CarLog.TAG_SERVICE, "Failed to get IVehicle/" + instanceName + " service", e);
catch (NoSuchElementException e)
Slog.e(CarLog.TAG_SERVICE, "IVehicle/" + instanceName + " service not registered yet");
return null;
以上是关于IVIVehicleService启动的主要内容,如果未能解决你的问题,请参考以下文章
VirtualBox启动模式分析(正常启动/无界面启动/分离式启动)