A partire dal 27 marzo 2025, ti consigliamo di utilizzare android-latest-release anziché aosp-main per compilare e contribuire ad AOSP. Per ulteriori informazioni, vedi Modifiche ad AOSP.
Mantieni tutto organizzato con le raccolte
Salva e classifica i contenuti in base alle tue preferenze.
Per eseguire la migrazione di un'implementazione VHAL HIDL esistente a un'implementazione VHAL AIDL,
utilizza la struttura dell'implementazione di riferimento AIDL per implementare l'interfaccia IVehicleHardware.
Se l'implementazione HIDL esistente segue anche
l'implementazione di riferimento HIDL,
il fornitore ha implementato la classe VehicleHal. IVehicleHardware è molto simile a VehicleHal.
HIDL VHAL
AIDL VHAL
getAllPropertyConfigs()
Uguale a VehicleHal.listProperties()
getValues(callback, requests)
Può chiamare VehicleHal.get() per ogni richiesta e può chiamare i callback.
dump()
Uguale a VehicleHal.dump()
checkHealth()
Può restituire VehicleHal.get()
registerPropertyChangeCallback()
Simile all'impostazione VehicleHal.mOnHalEvent
Differenze tra i tipi in AIDL
Quando esegui la migrazione da HIDL VHAL ad AIDL VHAL, tieni conto di queste differenze.
HIDL genera un file di intestazione (types.h) per tutti i tipi generati da
types.hal. AIDL genera un file di intestazione per ogni tipo. Ad esempio,
VehiclePropValue.h da VehiclePropValue.aidl.
Di conseguenza, devi includere tutti i file di intestazione per i tipi di cui hai bisogno. Un file di supporto,
VehicleHalTypes.h nella libreria VehicleHalUtils, contiene la maggior parte
dei tipi comuni.
Invece di…
Usa
hidl_vec
std::vector
hidl_string
std::string
android::sp
std::shared_ptr
android::wp
std::weak_ptr
Tutti i tipi definiti in types.hal sono gli stessi in AIDL tranne:
SubscribeFlags viene rimosso perché non viene utilizzato poiché
onPropertySet viene rimosso
UserFlags ora è definito in UserInfo.aidl e deve essere definito
come flag anziché come enum. Un campo di indicatori utente è un numero intero con più
UserInfo.USER_FLAG_XXX OR di bit insieme.
RawValue in VehiclePropValue viene rinominato in
RawPropValue
bytes in RawValue viene rinominato byteValues
I campioni di contenuti e codice in questa pagina sono soggetti alle licenze descritte nella Licenza per i contenuti. Java e OpenJDK sono marchi o marchi registrati di Oracle e/o delle sue società consociate.
Ultimo aggiornamento 2025-07-27 UTC.
[[["Facile da capire","easyToUnderstand","thumb-up"],["Il problema è stato risolto","solvedMyProblem","thumb-up"],["Altra","otherUp","thumb-up"]],[["Mancano le informazioni di cui ho bisogno","missingTheInformationINeed","thumb-down"],["Troppo complicato/troppi passaggi","tooComplicatedTooManySteps","thumb-down"],["Obsoleti","outOfDate","thumb-down"],["Problema di traduzione","translationIssue","thumb-down"],["Problema relativo a esempi/codice","samplesCodeIssue","thumb-down"],["Altra","otherDown","thumb-down"]],["Ultimo aggiornamento 2025-07-27 UTC."],[],[],null,["# HIDL VHAL migration guide\n\nTo migrate an existing **HIDL** VHAL implementation to an **AIDL** VHAL,\nuse the\n[AIDL reference implementation](/docs/automotive/vhal/reference-implementation)\nstructure to implement the `IVehicleHardware` interface.\n\nIf the existing HIDL implementation also follows\n[HIDL reference implementation](https://android.googlesource.com/platform/hardware/interfaces/+/refs/heads/android16-release/automotive/vehicle/2.0/default/impl/vhal_v2_0),\nthe vendor has implemented the `VehicleHal` class. `IVehicleHardware` is\nvery similar to `VehicleHal`.\n| **Note:** AIDL uses different types than HIDL. Some types used in the HIDL implementation must be migrated. For detail, see [Type differences in AIDL](#aidl-diffs) below.\n\n| HIDL VHAL | AIDL VHAL |\n|------------------------------------|----------------------------------------------------------------------|\n| `getAllPropertyConfigs()` | Same as `VehicleHal.listProperties()` |\n| `getValues(callback, requests)` | Can call `VehicleHal.get()` for each request and can call callbacks. |\n| `dump()` | Same as `VehicleHal.dump()` |\n| `checkHealth()` | Can return `VehicleHal.get()` |\n| `registerPropertyChangeCallback()` | Similar to setting `VehicleHal.mOnHalEvent` |\n\nType differences in AIDL\n------------------------\n\nWhen migrating from the HIDL VHAL to the AIDL VHAL, consider these differences.\n\n1. HIDL generates one header file (`types.h`) for all types generated from `types.hal`. AIDL generates one header file for each type. For example, `VehiclePropValue.h` from `VehiclePropValue.aidl`.\n\n As a result, you must include all header files for the types you need. A helper file,\n `VehicleHalTypes.h` in the `VehicleHalUtils` library contains most of\n the common types.\n\n| Instead of ... | Use |\n|----------------|-------------------|\n| `hidl_vec` | `std::vector` |\n| `hidl_string` | `std::string` |\n| `android::sp` | `std::shared_ptr` |\n| `android::wp` | `std::weak_ptr` |\n\n2. All types defined in `types.hal` are the same in AIDL **except** for:\n - `SubscribeFlags` is removed as it's not used because `onPropertySet` is removed\n - `UserFlags` is now defined in `UserInfo.aidl` and should be defined as a flag instead of an enum. A user flag field is an integer that has multiple `UserInfo.USER_FLAG_XXX` bit-or together.\n - `RawValue` in `VehiclePropValue` is renamed as `RawPropValue`\n - `bytes` in `RawValue` is renamed as `byteValues`"]]