Android for cars parked apps

From huytran1120/vie-agentic-skills · View interactive version

Android for cars parked apps is an AI agent skill from the GitHub repository huytran1120/vie-agentic-skills. Adapt existing Android video streaming apps, games, and web browsers to run as parked apps on Android Auto and Android Automotive OS. Covers manifest configuration, Google Play hardware feature declarations, compatibility mode, back navigation affordances, orientation and display continuity, control

How to use this skill

Skill file

Adapt existing Android video apps, games, and web browsers to run as parked

apps on Android Auto and Android Automotive OS. Follow these steps to meet the

car app quality guidelines for Google Play distribution.

Prerequisites

Glossary

Codebase exploration

Search the codebase for AndroidManifest.xml (or create

Assets/Plugins/Android/AndroidManifest.xml in Unity projects),

res/xml/automotive_app_desc.xml, build.gradle, build.gradle.kts,

or gradle/libs.versions.toml files. Locate existing video players,

MediaSession classes, requestedOrientation calls, and WindowInsets

handlers. Unless instructed otherwise by the user, ask permission before adding

dependencies.

Step 1: Configure the app manifest

Declare the app category, target platforms, hardware feature requirements, and

activity configuration in AndroidManifest.xml.

1.1: Identify the app category

android:name="android.intent.category.APP_BROWSER"/> in the MAIN <intent-filter> of an exported <activity> (android:exported="true"`).

1.2: Identify target platforms and hardware features

android:required="false"/> ("false" for mobile or multi-form-factor tracks; "true" only if the app will be published on the dedicated Automotive OS track) in the AndroidManifest.xml` file. NEVER add this feature tag if the app is solely targeting Android Auto.

android:value="true"/> is added to <application>. When an app declares android.software.car.display_compatibility in AndroidManifest.xml, the app **MUST** check PackageManager.hasSystemFeature("android.software.car.display_compatibility") at runtime and hide duplicate in-app back or close affordances when it returns true. Parked apps **MUST NOT** include <meta-data android:name="distractionOptimized" android:value="true"/> on any <activity> (DD-2, DD-3`).

Step 2: Provide back navigation and orientation support

2.1: Add in-app back and close affordances

Android Automotive OS vehicles aren't required to have a hardware or software

back button or gesture navigation (AN-1). Provide explicit UI back and close

controls on every non-root screen, including detail screens and full-screen

players:

android.software.car.display_compatibility**: Display explicit in-app back and close controls unconditionally.

android.software.car.display_compatibility with android:value="true"** : Show in-app back and close controls only when PackageManager.hasSystemFeature("android.software.car.display_compatibility") returns false.

2.2: Guard runtime orientation requests

Vehicle displays have fixed orientations. Requesting landscape on a

fixed-portrait car display causes letterboxing or flickering loops (DO-1).

Remove hardcoded android:screenOrientation manifest attributes and check

PackageManager.FEATURE_SCREEN_LANDSCAPE and

PackageManager.FEATURE_SCREEN_PORTRAIT before setting requestedOrientation.

Step 3: Adapt to system bars and irregular display cutouts

3.1: Track controllable system bar insets

On Android Automotive OS, OEMs are permitted to lock system bars visible so

climate and vehicle controls remain accessible (AR-1). Track controllable

insets with OnControllableInsetsChangedListener, hide only controllable bars,

and apply windowInsetsPadding for uncontrollable statusBars,

navigationBars, and displayCutout insets.

3.2: Render into irregular display cutouts safely

To meet Tier 1 criterion AR-2 on curved or non-rectangular car displays,

NEVER use LAYOUT_IN_DISPLAY_CUTOUT_MODE_DEFAULT (0) or

LAYOUT_IN_DISPLAY_CUTOUT_MODE_SHORT_EDGES (1). Configure

LAYOUT_IN_DISPLAY_CUTOUT_MODE_ALWAYS (3) or

LAYOUT_IN_DISPLAY_CUTOUT_MODE_NEVER (2) using the car resource qualifier

in res/values-car-v30/integers.xml:

<integer name="windowLayoutInDisplayCutoutMode">3</integer>

<br />

Protect interactive UI, app bars, and scrollable lists with

WindowInsets.safeDrawing.

Step 4: Meet driver distraction and media playback requirements

4.1: Pause playback on lifecycle transitions and block driving resumption

When a vehicle begins moving, the OS covers parked activities with a blocking

overlay and triggers onPause (and onStop on compatibility mode vehicles). To

satisfy DD-2, DD-3, and MC-1:

  1. Pause playback on ON_PAUSE or ON_STOP using LifecycleEventEffect from androidx.lifecycle:lifecycle-runtime-compose.
  2. Expose a MediaSession (androidx.media3:media3-session) with play, pause, or stop commands and item metadata (MC-1), and release it in onCleared.
  3. Add useLibrary("android.car") in build.gradle.kts, wrap ExoPlayer in ForwardingSimpleBasePlayer, listen to CarUxRestrictionsManager, pause playback when isRequiresDistractionOptimization becomes true, and remove COMMAND_PLAY_PAUSE in getState so external MediaSession controls can't resume playback while driving:
@UnstableApi
class CarAwarePlayer(context: Context) :
    ForwardingSimpleBasePlayer(ExoPlayer.Builder(context).build()) {
    private var shouldPreventPlay = false
    private var pausedByUxRestrictions = false
    private lateinit var carUxRestrictionsManager: CarUxRestrictionsManager

    init {
        if (context.packageManager.hasSystemFeature(PackageManager.FEATURE_AUTOMOTIVE)) {
            val car = Car.createCar(context)
            carUxRestrictionsManager =
                car.getCarManager(Car.CAR_UX_RESTRICTION_SERVICE) as CarUxRestrictionsManager
            shouldPreventPlay =
                carUxRestrictionsManager.currentCarUxRestrictions.isRequiresDistractionOptimization
            invalidateState()

            carUxRestrictionsManager.registerListener { restrictions: CarUxRestrictions ->
                shouldPreventPlay = restrictions.isRequiresDistractionOptimization
                if (!shouldPreventPlay && pausedByUxRestrictions) {
                    handleSetPlayWhenReady(true)
                    invalidateState()
                } else if (shouldPreventPlay && isPlaying) {
                    pausedByUxRestrictions = true
                    handleSetPlayWhenReady(false)
                    invalidateState()
                }
            }
        }
    }

    override fun getState(): State {
        val state = super.getState()
        return state.buildUpon()
            .setAvailableCommands(
                state.availableCommands.buildUpon()
                    .removeIf(COMMAND_PLAY_PAUSE, shouldPreventPlay)
                    .build()
            )
            .build()
    }

    override fun handleRelease(): ListenableFuture<*> {
        if (::carUxRestrictionsManager.isInitialized) {
            carUxRestrictionsManager.unregisterListener()
        }
        return super.handleRelease()
    }
}

<br />

4.2: Support background audio while driving (optional beta feature)

Because this is an optional beta feature, NEVER implement this feature

unless the user requests it. To implement the feature:

  1. Declare `<uses-feature

android:name="com.android.car.background_audio_while_driving"

android:required="false" /> in AndroidManifest.xml, along with FOREGROUND_SERVICE and FOREGROUND_SERVICE_MEDIA_PLAYBACK` permissions.

  1. Check runtime vehicle support with `CarFeatures.isFeatureEnabled(context,

CarFeatures.FEATURE_BACKGROUND_AUDIO_WHILE_DRIVING) from androidx.car.app:app. Only set shouldPreventPlay when !isBackgroundAudioWhileDrivingSupported &&

restrictions.isRequiresDistractionOptimization`.

  1. Host the MediaSession and player inside an exported MediaSessionService with android:foregroundServiceType="mediaPlayback", and connect from the UI using MediaController.Builder and buildAsync.

Step 5: Protect sensitive data in browser apps

Because vehicles are shared devices, browsers MUST block access to

saved passwords and payment methods unless protected by a profile lock (SD-1).

Before syncing passwords or payment data to the vehicle, browsers MUST

prompt the user to authenticate and display a notice on the car screen stating

that their data will be synchronized to the car (SD-2).

Check whether a PIN, pattern, or password is set using KeyguardManager, open

Settings.ACTION_SECURITY_SETTINGS if unset, and authenticate with

BiometricPrompt using BiometricManager.Authenticators.DEVICE_CREDENTIAL

only (vehicles don't have biometric hardware):

val keyguardManager = context.getSystemService<KeyguardManager>()
val isDeviceSecure = keyguardManager?.isDeviceSecure == true
lateinit var biometricPrompt: BiometricPrompt

if (!isDeviceSecure) {
    context.startActivity(
        Intent(Settings.ACTION_SECURITY_SETTINGS).addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
    )
} else {
    val promptInfo = BiometricPrompt.PromptInfo.Builder()
        .setTitle(context.getString(R.string.auth_title))
        .setSubtitle(context.getString(R.string.sync_data_to_car_notice))
        .setAllowedAuthenticators(BiometricManager.Authenticators.DEVICE_CREDENTIAL)
        .build()
    biometricPrompt.authenticate(promptInfo)
}

<br />

Step 6: Verify implementation

Build the app using ./gradlew assembleDebug. Find and fix any build errors.

Post-implementation guidance

Provide this guidance to the user after implementation:

Antipatterns

android:value="true"/> on any <activity> in a parked app, or include res/xml/automotive_app_desc.xml with uses name="video"` in a video app.

Best practices

VAS installation notes

Distributed from android/skills at

6daa53ef27fa2aa87827d183a85c06cedceca833 under Apache-2.0, by Google LLC and

the Android Open Source Project. Original copyright headers are retained and

the complete upstream LICENSE.txt is included with every standalone skill.

Only the frontmatter description/license formatting and these VAS notes differ;

the original workflow and all supporting files are preserved.

Use the VAS website's Copy Agent Prompt or ./vas install <skill-id> --target <agent>

with VAS's existing agent-folder mapping. Installing this skill only copies or

links its files and writes the CLI-compatible receipt. It does not install or

update Android CLI, SDK, Gradle, JDK, Python packages, plugins, MCP servers,

models or native binaries, connect to devices/services, run bundled helpers,

collect traces or send app source, credentials or application data.

Before using a workflow, check the project's compatible SDK/JDK/Gradle/library

versions and any required device, emulator, preview access or account. External

documentation, libraries, model weights and services are not bundled snapshots

and may have separate terms. Obtain explicit permission before downloads,

installer execution, package installation, telemetry, network requests, device

changes, sensitive-data processing or paid operations. Review downloaded code

and its provenance before execution; never pipe a network installer into a shell.

Surface missing prerequisites and command failures rather than inventing results.

The r8-analyzer protobuf converter needs a compatible google.protobuf runtime

(the bundled generated module declares version 6.33.4); this dependency is not

installed automatically. Its keep_radius_pb2.py helper is bundled locally.

play-policy-insights includes its scanner, scraper and template_engine helpers;

scraping Play Store pages requires network access and consent, and its report

is assistance, not a guarantee of Google Play approval or legal compliance.

android-profiler includes the upstream Perfetto Python launcher, not native

Perfetto binaries: running it can download/cache and execute a platform binary.

Review its pinned URL/hash and cache destination before approving execution.

Keep upstream executable permissions; the launcher is non-executable upstream

and can be invoked with python3 only after approval. No helpers were run and

no runtime packages or external binaries were installed during this import.

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.