The Android Open Source Project (AOSP) Automotive App Host is a part of the Car App Library used by third party (3P) developers to enable apps for Android Automotive. The App Host is a system app that allows 3P car apps to render OEM-styled user interface (UI) components on its behalf.
To run 3P apps, both the 3P app and the AOSP Automotive App Host must be installed:
- Automotive App Host provides 3P apps with a a set of UI templates and components optimized for vehicles, including capabilities like usability and safety.
- OEMs can style these UI templates and components.
- The result? 3P apps are visually well-integrated into the infotainment system of the OEM.
This page explains how to generate the AOSP Automotive App Host from the Gradle project in the
ub-automotive branch and then how to integrate the AOSP Automotive App Host into car
Check out the code
To check out the unbundled code:
- Run the following command:
repo init -u https://android.googlesource.com/platform/manifest -b ub-automotive-main repo sync -j4
To learn more about working with AOSP source code, see Initializing a Repo client.
- Install Android Studio.
Create the AOSP host APK
- Check out
ub-automotiveand then open the Gradle project under
- To configure the project with the Android SDK, configure your project's
local.propertiesfile. You can find the path under Android SDK Settings in Android Studio.
- Create the host APK as a typical Gradle project. For example, run the
The APK file is located in:
Embed the AOSP host
- Create a new
Android.mkfile to include the following content:
LOCAL_PATH := $(my-dir) ################## Start of AOSPHost target ################## include $(CLEAR_VARS) LOCAL_MODULE := CarAOSPHost LOCAL_LICENSE_KINDS := legacy_notice LOCAL_LICENSE_CONDITIONS := notice LOCAL_MODULE_OWNER := google LOCAL_SRC_FILES := AOSPHost.apk LOCAL_MODULE_CLASS := APPS LOCAL_MODULE_TAGS := optional LOCAL_MODULE_SUFFIX := $(COMMON_ANDROID_PACKAGE_SUFFIX) LOCAL_BUILT_MODULE_STEM := package.apk LOCAL_CERTIFICATE := PRESIGNED LOCAL_PRIVILEGED_MODULE := true LOCAL_PRODUCT_MODULE := true LOCAL_DEX_PREOPT := false include $(BUILD_PREBUILT)
- Rename the
AOSPHost.apkand put the APK in the same folder as
- Add the
CarAOSPHostmodule to your targets as
PRODUCT_PACKAGES += \ CarAOSPHost \
Add the permissions config
- Create a file called
com.android.car.templates.host.xmlto contain the following:
<permissions> <!-- Rename the package to com.android.car.templates.host --> <privapp-permissions package="com.android.car.templates.host"> <!-- To be able to display activities in the cluster --> <permission name="android.car.permission.CAR_DISPLAY_IN_CLUSTER" /> <!-- To be able to show navigation state (turn by turn directions) in the cluster.--> <permission name="android.car.permission.CAR_NAVIGATION_MANAGER" /> <!-- To be considered a system-approved host --> <permission name="android.car.permission.TEMPLATE_RENDERER" /> </privapp-permissions> <!-- Declare support for templated applications. --> <feature name="android.software.car.templates_host" /> </permissions>
- In your target, add the config file to your targets:
PRODUCT_COPY_FILES += \ <the file root>/com.android.car.templates.host.xml:$(TARGET_COPY_OUT_VENDOR)/etc/permissions/com.android.car.templates.host.xml
Build the target
When you build the target, the host is installed and permission is granted:
… android.car.permission.CAR_NAVIGATION_MANAGER: granted=true android.car.permission.CAR_DISPLAY_IN_CLUSTER: granted=true android.car.permission.TEMPLATE_RENDERER: granted=true …
Test the integration
To build and install the samples, see this GitHub project, car-samples/car_app_library.