AOSP Framework & Internals
2 min read

Migration Process

Learn about Migration Process.

Introduction

Migrating a hardware implementation from HIDL to AIDL is a multi-step process that involves changing the interface definition, updating the build system, rewriting the implementation daemon, and updating device manifests.

Converting .hal files to .aidl files

The first step is translating the interface syntax. HIDL .hal files use a syntax somewhat similar to C++, while .aidl uses a syntax similar to Java.

HIDL (android.hardware.light@2.0/ILight.hal):

package android.hardware.light@2.0;

interface ILight {
    setLight(Type type, LightState state) generates (Status status);
};

AIDL (android.hardware.light/ILight.aidl):

package android.hardware.light;

@VintfStability
interface ILight {
    void setLight(in LightType type, in LightState state);
}

Note that AIDL relies heavily on in/out directional tags and requires @VintfStability to cross the vendor boundary. Status returns are mapped natively to Binder android::binder::Status in C++.

Updating Android.bp

You must replace the hidl_interface module with an aidl_interface module in the build file.

aidl_interface {
    name: "android.hardware.light",
    vendor_available: true,
    srcs: ["android/hardware/light/*.aidl"],
    stability: "vintf",
    backend: {
        cpp: { enabled: false }, // Typically favor NDK backend for AIDL HALs
        ndk: { enabled: true },
        java: { sdk_version: "module_current" },
    },
}

Modern AIDL HALs heavily favor the ndk backend (libbinder_ndk) over the cpp backend for C++ implementations, as it provides a much more stable ABI.

Updating VINTF Manifest

Because the HAL is now using standard Binder instead of HwBinder, the device's VINTF manifest (manifest.xml) must be updated to reflect the new transport layer.

Old HIDL Manifest:

<hal format="hidl">
    <name>android.hardware.light</name>
    <transport>hwbinder</transport>
    <version>2.0</version>
</hal>

New AIDL Manifest:

<hal format="aidl">
    <name>android.hardware.light</name>
    <version>1</version>
    <interface>
        <name>ILight</name>
        <instance>default</instance>
    </interface>
</hal>

Testing after migration

Once migrated, the implementation code must switch from linking against libhwbinder and registering via hwservicemanager to linking against libbinder_ndk and registering via AServiceManager_addService.

Testing is enforced via VTS (Vendor Test Suite). You must run the newly compiled VtsHalLightTargetTest to ensure the AIDL implementation perfectly matches the expected system behaviors.