1

I am coding an application for Android Automotive OS. It is a simple Hello World for now, but that is not the problem of the app so far.

To run the app in the in-built automotive emulator of Android Studio (I use the Canary version of Android Studio Electric Eel | 2022.1.1 Canary 10) I had to download an app called Google Automotive App Host, gonna refer to them as GAAH from now on, to be able to run my own created app. So far so good.

Now I came across a "problem" in my AndroidManifest.xml which says: Implement permissions on this exported component. in the <service> section:

<application
        android:allowBackup="true"
        android:icon="@mipmap/example_icon"
        android:label="@string/app_name"
        android:roundIcon="@mipmap/example_icon_round"
        android:supportsRtl="true"
        android:theme="@style/Theme.Example">

        <meta-data
            android:name="androidx.car.app.minCarApiLevel"
            android:value="1" />

        <service
            android:name="com.example.launcher.services.LauncherService"
            android:exported="true">
            <intent-filter>
                <action android:name="androidx.car.app.CarAppService" />
            </intent-filter>
        </service>

        <activity
            android:name="androidx.car.app.activity.CarAppActivity"
            android:exported="true"
            android:launchMode="singleTask"
            android:theme="@android:style/Theme.DeviceDefault.NoActionBar">

            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
            <meta-data
                android:name="distractionOptimized"
                android:value="true" />
        </activity>

    </application>

Most of the answers stated, that android:exported should be set to false, which makes sense, so other apps don't have access to my own app.

The problem is, it also includes the aforementioned GAAH, which I need to be able to run it at all. It is not something game-breaking, it is just an inconvenience to deal with.

My question is: Are there ways to fix this issue and retain the ability for GAAH to run my app in AAOS?

Thanks in advance! Grey

Edit: Expanded the XML section from <service> to <application>

Grey
  • 116
  • 6

1 Answers1

1

The Google Automotive App Host holds the android.car.permission.TEMPLATE_RENDERER permission, so you should be able to use that as follows:

<service
   android:name=(hidden)
   android:exported="true"
   android:permission="android.car.permission.TEMPLATE_RENDERER">
   <intent-filter>
      <action android:name="androidx.car.app.CarAppService" />
   </intent-filter>
</service>

Additionally, you can further refine which hosts you trust by overriding the CarAppService::createHostValidator method.

Ben Sagmoe
  • 440
  • 2
  • 9
  • Sadly, as expected, `java.lang.SecurityException: Not allowed to bind to service Intent` is thrown. Did I forgot something? I would be glad to know. – Grey Sep 21 '22 at 09:26
  • Hmm, do you have a longer log? Using `android:permission="android.car.permission.TEMPLATE_RENDERER"` works for me (and changing it to `android:permission="android.car.permission.FOO"` breaks, so the value is definitely being used). – Ben Sagmoe Sep 21 '22 at 15:11
  • I think this is all I get. The logs are in the [album](https://imgur.com/a/H16cInY). My service class is the same as Google's example [here](https://developer.android.com/reference/androidx/car/app/CarAppService#createHostValidator()) – Grey Sep 22 '22 at 07:56