You can implement a service in a VM, and let client in the Android can use it as if it's in the Android. To do so, use libbinder's IAccessor.
IAccessor allows AIDL service in a VM to be accessed via servicemanager. To do so, VM owners should also provide IAccessor through libbinder's service manager APIs. servicemanager will connect to the IAccessor and get the binder of the service in a VM with it.
com.android.virt.accessor_demo apex contains the minimum setup for IAccessor as follows:
You need to do envsetup.sh
m com.android.virt.accessor_demo
For very first install,
adb remount -R || adb wait-for-device # Remount to push apex to /system_ext adb root && adb remount # Ensure it's rebooted. adb push $ANDROID_PRODUCT_OUT/system_ext/apex/com.android.virt.accessor_demo.apex /system_ext/apex adb reboot && adb wait-for-device # Ensure that newly pushed apex at /system_ext is installed
Once it's installed, you can simply use adb install
for update.
adb install $ANDROID_PRODUCT_OUT/system_ext/com.android.virt.accessor_demo.apex adb reboot