android12-release
Android Automotive OS知识体系
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.vehiclename>
<transport>hwbindertransport>
<version>2.0version>
<interface>
<name>IVehiclename>
<instance>defaultinstance>
interface>
hal>
manifest>
IVehicleServer、IVehicleClient
)hal = std::make_unique(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;
}
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
参考:
// 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,
}
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;
}