auto: fix all lint findings
- Commit
890db636e91b0d262b26c51f464664767f2bf804- Author
- Vayun Mathur <[email protected]>
- When
- 2026-11-17 06:56 UTC (19 days ago)
- Parents
a5d0d91
Brings :auto:lintDev to zero app-owned errors and warnings (168 findings). PackageStructure: the car-route helpers move out of Route.kt into platform/CarRouteSync.kt. UnsafeOptInUsageError: @ExperimentalCarApi is applied along the car-discovery chain (the MESSAGING/CALLING category constants are the experimental declarations) up to framework entry points. MissingPermission: explicit RECORD_AUDIO, ACCESS_FINE_LOCATION and BLUETOOTH_CONNECT checks now gate the AudioRecord build, location updates and discovery cancel. BatteryLife: the CONNECTIVITY_CHANGE receiver is registered dynamically by ProjectionService for the session (a manifest entry never fires on API 24+) and the manifest entry is removed. InlinedApi: ContextCompat.registerReceiver and an API-33-gated permission array. PermissionImpliesUnsupportedChromeOsHardware: telephony/bluetooth/wifi uses-feature tags declared not required. StaticFieldLeak: the view model no longer stores a Context field. LocalContextGetResourceValueCall: composables read strings via stringResource/pluralStringResource. PluralsCandidate (3 strings become plurals, callers and tests updated), UseKtx (SharedPreferences.edit), ObsoleteSdkInt, ClickableViewAccessibility (CarTextureView overrides performClick), UnusedResources (39 car strings, no references anywhere) and CommentedOutCode are fixed in code. Suppressions (false positives, noted per instructions): one @SuppressLint(RestrictedApi) on HostSession - this module IS the car host and implements/calls the androidx.car.app AIDL surface (ICarApp/ISurfaceCallback/IOnDoneCallback) for which there is no public host-side API; ProtectedPermissions tools:ignore on the privileged permission block (MAOS priv-app car host, all uses runtime-checked); ExportedService/ExportedReceiver tools:ignore on the head-unit bind targets and startup receiver, which must be exported for the head unit to bind and whose binds are rejected unless valid. Verified: ./gradlew :auto:lintDev reports 0 errors and 0 app-owned warnings, and :auto:testDevUnitTest passes (374 tests). Remaining report warnings are sourced from shared library modules only.
Diff
auto/src/main/AndroidManifest.xml
diff --git a/auto/src/main/AndroidManifest.xml b/auto/src/main/AndroidManifest.xmlindex e4f76b2ce0..0f8c429177 100644--- a/auto/src/main/AndroidManifest.xml+++ b/auto/src/main/AndroidManifest.xml@@ -1,11 +1,20 @@ <?xml version="1.0" encoding="utf-8"?>-<manifest xmlns:android="http://schemas.android.com/apk/res/android">+<manifest xmlns:android="http://schemas.android.com/apk/res/android"+ xmlns:tools="http://schemas.android.com/tools"> <!-- The projection session outlives any activity: it is bound to the cable or the wireless link, not to a screen the user is looking at. -->+ <uses-feature android:name="android.hardware.telephony" android:required="false" />+ <uses-feature android:name="android.hardware.bluetooth" android:required="false" />+ <uses-feature android:name="android.hardware.wifi" android:required="false" />+ <uses-feature android:name="android.hardware.wifi.direct" android:required="false" />+ <!-- MAOS: opt out of the GrapheneOS Sensors permission (OTHER_SENSORS). --> <!-- This app uses no motion/environment sensors; MAOS withholds the --> <!-- Sensors permission at install instead of auto-granting it. -->+ <!-- ProtectedPermissions: this app is the MAOS system car host (priv-app); the+ signature|privileged permissions below are granted by the OS image and every+ use is additionally runtime-checked, so the lint warning is a false positive. --> <uses-permission android:name="com.vayunmathur.permission.SENSORS_OPTOUT" /> <uses-permission android:name="android.permission.FOREGROUND_SERVICE" />@@ -58,8 +67,8 @@ <uses-permission android:name="android.permission.BLUETOOTH_ADMIN" /> <uses-permission android:name="android.permission.BLUETOOTH_SCAN" /> <uses-permission android:name="android.permission.BLUETOOTH_CONNECT" />- <uses-permission android:name="android.permission.BLUETOOTH_PRIVILEGED" />- <uses-permission android:name="android.permission.LOCAL_MAC_ADDRESS" />+ <uses-permission android:name="android.permission.BLUETOOTH_PRIVILEGED" tools:ignore="ProtectedPermissions" />+ <uses-permission android:name="android.permission.LOCAL_MAC_ADDRESS" tools:ignore="ProtectedPermissions" /> <!-- Projected calls + message/call templates: the InCall pair (CarProjection/non-car) and reading the threads the mirror posts. Without these the call UI stays on the phone and restricted message@@ -71,52 +80,52 @@ <uses-permission android:name="android.permission.RECEIVE_SMS" /> <uses-permission android:name="android.permission.SEND_SMS" /> <uses-permission android:name="android.permission.READ_CALENDAR" />- <uses-permission android:name="android.permission.RECEIVE_SENSITIVE_NOTIFICATIONS" />- <uses-permission android:name="android.permission.GET_INTENT_SENDER_INTENT" />+ <uses-permission android:name="android.permission.RECEIVE_SENSITIVE_NOTIFICATIONS" tools:ignore="ProtectedPermissions" />+ <uses-permission android:name="android.permission.GET_INTENT_SENDER_INTENT" tools:ignore="ProtectedPermissions" /> <!-- Wired auto-launch/role-switch/reset: the USB receivers and the reset chain. Privapp-gated (see the allowlist note below): without the allowlist entry this is inert and USB falls back to the plain attach/permission/open path, which needs no privileged grant. -->- <uses-permission android:name="android.permission.MANAGE_USB" />+ <uses-permission android:name="android.permission.MANAGE_USB" tools:ignore="ProtectedPermissions" /> <!-- Audio routing + telephony/in-call control + background launch: the sinks route to the car speakers (not the phone), the InCall pair controls the call, and background starts fire the startup chain. Privapp-gated like MANAGE_USB (see below). -->- <uses-permission android:name="android.permission.MODIFY_AUDIO_ROUTING" />- <uses-permission android:name="android.permission.TETHER_PRIVILEGED" />- <uses-permission android:name="android.permission.POWER_SAVER" />- <uses-permission android:name="android.permission.MANAGE_USERS" />- <uses-permission android:name="android.permission.READ_PRIVILEGED_PHONE_STATE" />- <uses-permission android:name="android.permission.CHANGE_COMPONENT_ENABLED_STATE" />- <uses-permission android:name="android.permission.MODIFY_PHONE_STATE" />- <uses-permission android:name="android.permission.CONTROL_INCALL_EXPERIENCE" />- <uses-permission android:name="android.permission.CALL_PRIVILEGED" />+ <uses-permission android:name="android.permission.MODIFY_AUDIO_ROUTING" tools:ignore="ProtectedPermissions" />+ <uses-permission android:name="android.permission.TETHER_PRIVILEGED" tools:ignore="ProtectedPermissions" />+ <uses-permission android:name="android.permission.POWER_SAVER" tools:ignore="ProtectedPermissions" />+ <uses-permission android:name="android.permission.MANAGE_USERS" tools:ignore="ProtectedPermissions" />+ <uses-permission android:name="android.permission.READ_PRIVILEGED_PHONE_STATE" tools:ignore="ProtectedPermissions" />+ <uses-permission android:name="android.permission.CHANGE_COMPONENT_ENABLED_STATE" tools:ignore="ProtectedPermissions" />+ <uses-permission android:name="android.permission.MODIFY_PHONE_STATE" tools:ignore="ProtectedPermissions" />+ <uses-permission android:name="android.permission.CONTROL_INCALL_EXPERIENCE" tools:ignore="ProtectedPermissions" />+ <uses-permission android:name="android.permission.CALL_PRIVILEGED" tools:ignore="ProtectedPermissions" /> <!-- Trusted display + projection control + secure capture: the virtual display route (TRUSTED vs PRIVATE), the projection toggle, and secure surfaces. Without these the display stays private-only and secure content renders black on the head unit. -->- <uses-permission android:name="android.permission.ADD_TRUSTED_DISPLAY" />- <uses-permission android:name="android.permission.ADD_ALWAYS_UNLOCKED_DISPLAY" />+ <uses-permission android:name="android.permission.ADD_TRUSTED_DISPLAY" tools:ignore="ProtectedPermissions" />+ <uses-permission android:name="android.permission.ADD_ALWAYS_UNLOCKED_DISPLAY" tools:ignore="ProtectedPermissions" /> <uses-permission android:name="android.permission.CREATE_VIRTUAL_DEVICE" />- <uses-permission android:name="android.permission.TOGGLE_AUTOMOTIVE_PROJECTION" />- <uses-permission android:name="android.permission.CAPTURE_SECURE_VIDEO_OUTPUT" />+ <uses-permission android:name="android.permission.TOGGLE_AUTOMOTIVE_PROJECTION" tools:ignore="ProtectedPermissions" />+ <uses-permission android:name="android.permission.CAPTURE_SECURE_VIDEO_OUTPUT" tools:ignore="ProtectedPermissions" /> <!-- Companion-device trigger for wireless: the CDM service (CarCompanionDeviceService) associates with the automotive-projection profile and fires the BT_START chain. Without these the association never forms and wireless stays on the pairing-screen stand-in. --> <uses-permission android:name="android.permission.ASSOCIATE_COMPANION_DEVICES" /> <uses-permission android:name="android.permission.REQUEST_COMPANION_PROFILE_AUTOMOTIVE_PROJECTION" />- <uses-permission android:name="android.permission.REQUEST_COMPANION_SELF_MANAGED" />- <uses-permission android:name="android.permission.COMPANION_APPROVE_WIFI_CONNECTIONS" />+ <uses-permission android:name="android.permission.REQUEST_COMPANION_SELF_MANAGED" tools:ignore="ProtectedPermissions" />+ <uses-permission android:name="android.permission.COMPANION_APPROVE_WIFI_CONNECTIONS" tools:ignore="ProtectedPermissions" /> <uses-permission android:name="android.permission.REQUEST_OBSERVE_COMPANION_DEVICE_PRESENCE" /> <!-- Background/trusted launch: the startup chain (BT_START, START_USB_PROJECTION, deep links) and car-mode entry fire without a visible activity. Without these the chain can only start while the app is foreground. -->- <uses-permission android:name="android.permission.START_ACTIVITIES_FROM_BACKGROUND" />- <uses-permission android:name="android.permission.ENTER_CAR_MODE_PRIORITIZED" />+ <uses-permission android:name="android.permission.START_ACTIVITIES_FROM_BACKGROUND" tools:ignore="ProtectedPermissions" />+ <uses-permission android:name="android.permission.ENTER_CAR_MODE_PRIORITIZED" tools:ignore="ProtectedPermissions" /> <uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW" />- <uses-permission android:name="android.permission.INTERACT_ACROSS_PROFILES" />+ <uses-permission android:name="android.permission.INTERACT_ACROSS_PROFILES" tools:ignore="ProtectedPermissions" /> <!-- Do-not-disturb state for the rail status cluster (DND icon): reading the interruption filter needs the policy grant; without it the icon stays gone (fail-closed), like every other absent source. -->@@ -265,16 +274,6 @@ </intent-filter> </receiver> - <!-- Link changes under a wireless session (see- ConnectivityEventReceiver). -->- <receiver- android:name=".platform.ConnectivityEventReceiver"- android:exported="false">- <intent-filter>- <action android:name="android.net.conn.CONNECTIVITY_CHANGE" />- </intent-filter>- </receiver>- <!-- Re-starts the projection listener after a reboot or an app update. Runs in :car like gearhead's init receiver; both the boot and the replaced actions restart plus republish the role. -->@@ -359,10 +358,12 @@ into ch2 video rather than hosting HU-composited windows. --> <service android:name=".platform.CarSystemUiControllerService"- android:exported="true" />+ android:exported="true"+ tools:ignore="ExportedService" /> <service android:name=".platform.AppDecorService"- android:exported="true" />+ android:exported="true"+ tools:ignore="ExportedService" /> <!-- Chimera entry point (GMS-compat car.service.START): funnels into the projection service. Same single type as ProjectionService@@ -371,6 +372,7 @@ <service android:name=".platform.CarChimeraService" android:exported="true"+ tools:ignore="ExportedService" android:foregroundServiceType="connectedDevice"> <intent-filter> <action android:name="car.service.START" />@@ -381,7 +383,8 @@ pairing screen owns setup). --> <service android:name=".platform.CarSetupService"- android:exported="true">+ android:exported="true"+ tools:ignore="ExportedService"> <intent-filter> <action android:name="com.vayunmathur.auto.CAR_SETUP_SERVICE" /> </intent-filter>@@ -392,7 +395,8 @@ open. --> <service android:name=".platform.CarStartupService"- android:exported="true">+ android:exported="true"+ tools:ignore="ExportedService"> <intent-filter> <action android:name="com.vayunmathur.auto.BT_START" /> <action android:name="com.vayunmathur.auto.START_USB_PROJECTION" />@@ -408,7 +412,8 @@ android:exported="false" /> <service android:name=".platform.WirelessSetupCarService"- android:exported="true" />+ android:exported="true"+ tools:ignore="ExportedService" /> <!-- BT/WiFi state during wireless setup (ACL + adapter state). --> <receiver@@ -424,7 +429,8 @@ <!-- Wireless head-unit announcement: enters the BT_START chain. --> <receiver android:name=".platform.WirelessStartupReceiver"- android:exported="true">+ android:exported="true"+ tools:ignore="ExportedReceiver"> <intent-filter> <action android:name="com.vayunmathur.auto.WIRELESS_STARTUP" /> </intent-filter>
auto/src/main/java/com/vayunmathur/auto/MainActivity.kt
diff --git a/auto/src/main/java/com/vayunmathur/auto/MainActivity.kt b/auto/src/main/java/com/vayunmathur/auto/MainActivity.ktindex 2f569a6ccf..38dad33f30 100644--- a/auto/src/main/java/com/vayunmathur/auto/MainActivity.kt+++ b/auto/src/main/java/com/vayunmathur/auto/MainActivity.kt@@ -11,6 +11,7 @@ import com.vayunmathur.auto.platform.TransportState import com.vayunmathur.auto.service.ProjectionService import com.vayunmathur.library.ui.MaActivity [email protected] class MainActivity : MaActivity() { private val viewModel: AutoViewModel by viewModels() private val pairingViewModel: PairingViewModel by viewModels()
auto/src/main/java/com/vayunmathur/auto/Navigation.kt
diff --git a/auto/src/main/java/com/vayunmathur/auto/Navigation.kt b/auto/src/main/java/com/vayunmathur/auto/Navigation.ktindex d82af7f86e..fb6f54e16e 100644--- a/auto/src/main/java/com/vayunmathur/auto/Navigation.kt+++ b/auto/src/main/java/com/vayunmathur/auto/Navigation.kt@@ -10,6 +10,7 @@ import com.vayunmathur.library.util.MainNavigation import com.vayunmathur.library.util.rememberNavBackStack @Composable[email protected] fun Navigation(viewModel: AutoViewModel, pairingViewModel: PairingViewModel) { val backStack = rememberNavBackStack<Route>(Route.Home) MainNavigation(backStack) {
auto/src/main/java/com/vayunmathur/auto/Route.kt
diff --git a/auto/src/main/java/com/vayunmathur/auto/Route.kt b/auto/src/main/java/com/vayunmathur/auto/Route.ktindex 4f3657c4d3..e93384fc2a 100644--- a/auto/src/main/java/com/vayunmathur/auto/Route.kt+++ b/auto/src/main/java/com/vayunmathur/auto/Route.kt@@ -39,27 +39,3 @@ sealed interface Route : NavKey { data class App(val appId: String) : Route } -/** The car destination a selected app id names; null is the home grid. */-fun carRouteFor(selectedAppId: String?): Route =- selectedAppId?.let { Route.App(it) } ?: Route.LauncherHome--/**- * Projects a selected app id onto the car-side stack, kept free of- * composition so unit tests can drive it with a plain [NavBackStack].- *- * The stack is [Route.LauncherHome] plus at most one [Route.App]:- * selecting an app pushes it (or replaces the open one — switching apps- * is a swap, not a descent), and clearing the selection pops back home.- * Idempotent while the selection is unchanged.- */-fun syncCarRoute(backStack: NavBackStack<Route>, selectedAppId: String?) {- val target = carRouteFor(selectedAppId)- val top = backStack.backStack.lastOrNull()- if (top == target) return- when {- target is Route.LauncherHome -> backStack.reset(Route.LauncherHome)- top is Route.LauncherHome -> backStack.add(target)- top is Route.App -> backStack.setLast(target)- else -> backStack.reset(Route.LauncherHome, target)- }-}
auto/src/main/java/com/vayunmathur/auto/domain/PinnedAppsViewModel.kt
diff --git a/auto/src/main/java/com/vayunmathur/auto/domain/PinnedAppsViewModel.kt b/auto/src/main/java/com/vayunmathur/auto/domain/PinnedAppsViewModel.ktindex ef79c264ed..2ceddf185e 100644--- a/auto/src/main/java/com/vayunmathur/auto/domain/PinnedAppsViewModel.kt+++ b/auto/src/main/java/com/vayunmathur/auto/domain/PinnedAppsViewModel.kt@@ -25,8 +25,9 @@ data class PinnedAppRow( * Toggle pins/unpins (guarding the max-5 cap, reporting rejection so the UI * can snackbar); move reorders. All writes go through [PinnedAppsPrefs]. */[email protected] class PinnedAppsViewModel(application: Application) : AndroidViewModel(application) {- private val context = application.applicationContext+ private val context: android.content.Context get() = getApplication<android.app.Application>().applicationContext private val _allApps = MutableStateFlow<List<DiscoveredApp>>(emptyList()) @@ -56,6 +57,7 @@ class PinnedAppsViewModel(application: Application) : AndroidViewModel(applicati } /** Re-runs discovery (package changes while the picker is open). */+ @androidx.car.app.annotations.ExperimentalCarApi fun refresh() { viewModelScope.launch { _allApps.value = runCatching { CarAppDiscovery.queryAll(context) }.getOrDefault(emptyList())
auto/src/main/java/com/vayunmathur/auto/network/WifiDirectConnector.kt
diff --git a/auto/src/main/java/com/vayunmathur/auto/network/WifiDirectConnector.kt b/auto/src/main/java/com/vayunmathur/auto/network/WifiDirectConnector.ktindex 3e21ef06ba..d55f22a5e4 100644--- a/auto/src/main/java/com/vayunmathur/auto/network/WifiDirectConnector.kt+++ b/auto/src/main/java/com/vayunmathur/auto/network/WifiDirectConnector.kt@@ -389,7 +389,12 @@ object WifiDirectConnector { } // Discovery slows (and often breaks) an outgoing ACL connect; stop it // first like every BT connect path must.- runCatching { adapter.cancelDiscovery() }+ if (androidx.core.content.ContextCompat.checkSelfPermission(+ appContext!!, android.Manifest.permission.BLUETOOTH_CONNECT,+ ) == android.content.pm.PackageManager.PERMISSION_GRANTED+ ) {+ runCatching { adapter.cancelDiscovery() }+ } val device: BluetoothDevice = runCatching { adapter.getRemoteDevice(address) }.getOrNull() ?: run { Log.status(TAG, "RFCOMM fallback: unparsable BT peer $address")
auto/src/main/java/com/vayunmathur/auto/platform/CarAppDiscovery.kt
diff --git a/auto/src/main/java/com/vayunmathur/auto/platform/CarAppDiscovery.kt b/auto/src/main/java/com/vayunmathur/auto/platform/CarAppDiscovery.ktindex e35d31020b..df0acb3ab5 100644--- a/auto/src/main/java/com/vayunmathur/auto/platform/CarAppDiscovery.kt+++ b/auto/src/main/java/com/vayunmathur/auto/platform/CarAppDiscovery.kt@@ -34,7 +34,9 @@ data class DiscoveredApp( * constant — so [queryAll] merges explicit components ahead of category * results, with real app icons resolved through `PackageManager`. */+@OptIn(androidx.car.app.annotations.ExperimentalCarApi::class) object CarAppDiscovery {+ @androidx.car.app.annotations.ExperimentalCarApi fun query(context: Context): List<DiscoveredApp> { val pm = context.packageManager val merged = linkedMapOf<ComponentName, MutableSet<String>>()@@ -73,6 +75,7 @@ object CarAppDiscovery { } /** Categories the launcher hosts templates for. */+ @androidx.car.app.annotations.ExperimentalCarApi val HOSTED_CATEGORIES: List<String> = listOf( CarAppService.CATEGORY_NAVIGATION_APP, CarAppService.CATEGORY_POI_APP,@@ -88,6 +91,7 @@ object CarAppDiscovery { * dock, the pin picker, and the host session all list. First-party * entries win on id collisions so their explicit category survives. */+ @androidx.car.app.annotations.ExperimentalCarApi fun queryAll(context: Context): List<DiscoveredApp> { val byId = query(context).associateBy { it.id }.toMutableMap() for (party in firstParty(context)) {@@ -101,6 +105,7 @@ object CarAppDiscovery { * resolved from the installed packages (missing packages resolve to * null and are skipped, so uninstalls never show dead tiles). */+ @androidx.car.app.annotations.ExperimentalCarApi fun firstParty(context: Context): List<DiscoveredApp> { val pm = context.packageManager return FIRST_PARTY_COMPONENTS.mapNotNull { (packageName, className, label, categories) ->@@ -126,6 +131,7 @@ object CarAppDiscovery { val categories: Set<String>, ) + @androidx.car.app.annotations.ExperimentalCarApi private val FIRST_PARTY_COMPONENTS: List<FirstPartyComponent> = listOf( FirstPartyComponent( packageName = "com.vayunmathur.music",
auto/src/main/java/com/vayunmathur/auto/platform/CarApps.kt
diff --git a/auto/src/main/java/com/vayunmathur/auto/platform/CarApps.kt b/auto/src/main/java/com/vayunmathur/auto/platform/CarApps.ktindex ea9e891d57..47bd2f5078 100644--- a/auto/src/main/java/com/vayunmathur/auto/platform/CarApps.kt+++ b/auto/src/main/java/com/vayunmathur/auto/platform/CarApps.kt@@ -31,6 +31,7 @@ object CarApps { * in dock order; entries that no longer resolve are filtered as stale. * Unpinned apps follow in label order, then the legacy phone slots. */+ @androidx.car.app.annotations.ExperimentalCarApi fun query(context: Context, pinnedOrder: List<String> = emptyList()): List<CarApp> { val discovered = runCatching { CarAppDiscovery.query(context) }.getOrElse { Log.status(TAG, "car discovery failed; legacy slots only", it)
auto/src/main/java/com/vayunmathur/auto/platform/CarRouteSync.kt
diff --git a/auto/src/main/java/com/vayunmathur/auto/platform/CarRouteSync.kt b/auto/src/main/java/com/vayunmathur/auto/platform/CarRouteSync.ktnew file mode 100644index 0000000000..f88bdaee8a--- /dev/null+++ b/auto/src/main/java/com/vayunmathur/auto/platform/CarRouteSync.kt@@ -0,0 +1,29 @@+package com.vayunmathur.auto.platform++import com.vayunmathur.auto.Route+import com.vayunmathur.library.util.NavBackStack++/** The car destination a selected app id names; null is the home grid. */+fun carRouteFor(selectedAppId: String?): Route =+ selectedAppId?.let { Route.App(it) } ?: Route.LauncherHome++/**+ * Projects a selected app id onto the car-side stack, kept free of+ * composition so unit tests can drive it with a plain [NavBackStack].+ *+ * The stack is [Route.LauncherHome] plus at most one [Route.App]:+ * selecting an app pushes it (or replaces the open one — switching apps+ * is a swap, not a descent), and clearing the selection pops back home.+ * Idempotent while the selection is unchanged.+ */+fun syncCarRoute(backStack: NavBackStack<Route>, selectedAppId: String?) {+ val target = carRouteFor(selectedAppId)+ val top = backStack.backStack.lastOrNull()+ if (top == target) return+ when {+ target is Route.LauncherHome -> backStack.reset(Route.LauncherHome)+ top is Route.LauncherHome -> backStack.add(target)+ top is Route.App -> backStack.setLast(target)+ else -> backStack.reset(Route.LauncherHome, target)+ }+}
auto/src/main/java/com/vayunmathur/auto/platform/HostSession.kt
diff --git a/auto/src/main/java/com/vayunmathur/auto/platform/HostSession.kt b/auto/src/main/java/com/vayunmathur/auto/platform/HostSession.ktindex 142dbcbab0..2fd8cdab7a 100644--- a/auto/src/main/java/com/vayunmathur/auto/platform/HostSession.kt+++ b/auto/src/main/java/com/vayunmathur/auto/platform/HostSession.kt@@ -1,4 +1,5 @@ package com.vayunmathur.auto.platform+import android.annotation.SuppressLint import android.content.ComponentName import android.content.Context@@ -53,6 +54,11 @@ import kotlin.concurrent.thread * block); `clearSurface` stays synchronous so the service can release the * surface on return. Template callbacks post to main. */+// This class IS the car host: it implements and calls the androidx.car.app+// AIDL surface (ICarApp/ISurfaceCallback/IOnDoneCallback) that the library+// restricts to itself, because hosting car apps is this module's purpose and+// there is no public host-side API. RestrictedApi is a false positive here.+@SuppressLint("RestrictedApi") class HostSession( context: Context, private val component: ComponentName,
auto/src/main/java/com/vayunmathur/auto/platform/MessagingPrefs.kt
diff --git a/auto/src/main/java/com/vayunmathur/auto/platform/MessagingPrefs.kt b/auto/src/main/java/com/vayunmathur/auto/platform/MessagingPrefs.ktindex 1c414bd65b..36e7972f52 100644--- a/auto/src/main/java/com/vayunmathur/auto/platform/MessagingPrefs.kt+++ b/auto/src/main/java/com/vayunmathur/auto/platform/MessagingPrefs.kt@@ -1,4 +1,5 @@ package com.vayunmathur.auto.platform+import androidx.core.content.edit import android.content.Context @@ -15,7 +16,7 @@ object MessagingPrefs { prefs(context).getBoolean(KEY_CONSENT, false) fun setMirroringConsented(context: Context, consented: Boolean) {- prefs(context).edit().putBoolean(KEY_CONSENT, consented).apply()+ prefs(context).edit { putBoolean(KEY_CONSENT, consented) } } private fun prefs(context: Context) =
auto/src/main/java/com/vayunmathur/auto/platform/MusicCapture.kt
diff --git a/auto/src/main/java/com/vayunmathur/auto/platform/MusicCapture.kt b/auto/src/main/java/com/vayunmathur/auto/platform/MusicCapture.ktindex e49f0d165d..caab54cec0 100644--- a/auto/src/main/java/com/vayunmathur/auto/platform/MusicCapture.kt+++ b/auto/src/main/java/com/vayunmathur/auto/platform/MusicCapture.kt@@ -173,6 +173,13 @@ class MusicCapture( Log.status(TAG, "music capture has no viable buffer ($minBytes)") return null }+ if (androidx.core.content.ContextCompat.checkSelfPermission(+ appContext, android.Manifest.permission.RECORD_AUDIO,+ ) != android.content.pm.PackageManager.PERMISSION_GRANTED+ ) {+ Log.status(TAG, "music capture needs the microphone permission")+ return null+ } return runCatching { AudioRecord.Builder() .setAudioPlaybackCaptureConfig(config)
auto/src/main/java/com/vayunmathur/auto/platform/MusicCapturePrefs.kt
diff --git a/auto/src/main/java/com/vayunmathur/auto/platform/MusicCapturePrefs.kt b/auto/src/main/java/com/vayunmathur/auto/platform/MusicCapturePrefs.ktindex 333317fb38..dae5fc9eac 100644--- a/auto/src/main/java/com/vayunmathur/auto/platform/MusicCapturePrefs.kt+++ b/auto/src/main/java/com/vayunmathur/auto/platform/MusicCapturePrefs.kt@@ -1,4 +1,5 @@ package com.vayunmathur.auto.platform+import androidx.core.content.edit import android.content.Context @@ -15,7 +16,7 @@ object MusicCapturePrefs { prefs(context).getBoolean(KEY_CONSENT, false) fun setMusicCaptureConsented(context: Context, consented: Boolean) {- prefs(context).edit().putBoolean(KEY_CONSENT, consented).apply()+ prefs(context).edit { putBoolean(KEY_CONSENT, consented) } } private fun prefs(context: Context) =
auto/src/main/java/com/vayunmathur/auto/platform/NavGuidanceMonitor.kt
diff --git a/auto/src/main/java/com/vayunmathur/auto/platform/NavGuidanceMonitor.kt b/auto/src/main/java/com/vayunmathur/auto/platform/NavGuidanceMonitor.ktindex 1fb08cb6ee..71ed946400 100644--- a/auto/src/main/java/com/vayunmathur/auto/platform/NavGuidanceMonitor.kt+++ b/auto/src/main/java/com/vayunmathur/auto/platform/NavGuidanceMonitor.kt@@ -108,6 +108,13 @@ class NavGuidanceMonitor( override fun onStatusChanged(provider: String?, status: Int, extras: Bundle?) {} } listener = active+ if (androidx.core.content.ContextCompat.checkSelfPermission(+ context, android.Manifest.permission.ACCESS_FINE_LOCATION,+ ) != android.content.pm.PackageManager.PERMISSION_GRANTED+ ) {+ Log.status(TAG, "no location permission; guidance holds last-known")+ return@post+ } runCatching { if (manager.isProviderEnabled(LocationManager.GPS_PROVIDER)) { manager.requestLocationUpdates(LocationManager.GPS_PROVIDER, FIX_MIN_MS, 0f, active)
auto/src/main/java/com/vayunmathur/auto/platform/PhoneStatusMonitor.kt
diff --git a/auto/src/main/java/com/vayunmathur/auto/platform/PhoneStatusMonitor.kt b/auto/src/main/java/com/vayunmathur/auto/platform/PhoneStatusMonitor.ktindex c5112d0366..5560532d37 100644--- a/auto/src/main/java/com/vayunmathur/auto/platform/PhoneStatusMonitor.kt+++ b/auto/src/main/java/com/vayunmathur/auto/platform/PhoneStatusMonitor.kt@@ -76,10 +76,11 @@ class PhoneStatusMonitor(private val context: Context) { } } batteryReceiver = receiver- context.registerReceiver(+ androidx.core.content.ContextCompat.registerReceiver(+ context, receiver, IntentFilter(Intent.ACTION_BATTERY_CHANGED),- Context.RECEIVER_NOT_EXPORTED,+ androidx.core.content.ContextCompat.RECEIVER_NOT_EXPORTED, ) }.onFailure { Log.status(TAG, "battery receiver unavailable", it) } refreshDndAndBadge()
auto/src/main/java/com/vayunmathur/auto/platform/RefusedCarApps.kt
diff --git a/auto/src/main/java/com/vayunmathur/auto/platform/RefusedCarApps.kt b/auto/src/main/java/com/vayunmathur/auto/platform/RefusedCarApps.ktindex f0b09fa59b..6019be3229 100644--- a/auto/src/main/java/com/vayunmathur/auto/platform/RefusedCarApps.kt+++ b/auto/src/main/java/com/vayunmathur/auto/platform/RefusedCarApps.kt@@ -1,4 +1,5 @@ package com.vayunmathur.auto.platform+import androidx.core.content.edit import android.content.ComponentName import android.content.Context@@ -18,7 +19,7 @@ object RefusedCarApps { fun markRefused(context: Context, component: ComponentName) { val version = versionCode(context, component.packageName) ?: return- prefs(context).edit().putLong(component.flattenToString(), version).apply()+ prefs(context).edit { putLong(component.flattenToString(), version) } } private fun versionCode(context: Context, packageName: String): Long? = runCatching {
auto/src/main/java/com/vayunmathur/auto/service/CarAppHostSession.kt
diff --git a/auto/src/main/java/com/vayunmathur/auto/service/CarAppHostSession.kt b/auto/src/main/java/com/vayunmathur/auto/service/CarAppHostSession.ktindex 6b17ab3b4c..3175847e4f 100644--- a/auto/src/main/java/com/vayunmathur/auto/service/CarAppHostSession.kt+++ b/auto/src/main/java/com/vayunmathur/auto/service/CarAppHostSession.kt@@ -32,6 +32,7 @@ class CarAppHostSession( * Binds every car-app service; template states push into the car card * through the legacy path until Phase C replaces the nav renderer. */+ @androidx.car.app.annotations.ExperimentalCarApi fun start() { if (manager != null) return val host = HostManager(context)@@ -102,6 +103,7 @@ class CarAppHostSession( HostTemplateBus.toLegacy(template)?.let { video()?.wiring?.setHostNavState(it) } } + @androidx.car.app.annotations.ExperimentalCarApi private fun discover(): List<DiscoveredApp> { val merged = runCatching { CarAppDiscovery.queryAll(context) }.getOrDefault(emptyList()) if (merged.isNotEmpty()) return merged
auto/src/main/java/com/vayunmathur/auto/service/MusicCaptureService.kt
diff --git a/auto/src/main/java/com/vayunmathur/auto/service/MusicCaptureService.kt b/auto/src/main/java/com/vayunmathur/auto/service/MusicCaptureService.ktindex dff3d6f967..28397acc43 100644--- a/auto/src/main/java/com/vayunmathur/auto/service/MusicCaptureService.kt+++ b/auto/src/main/java/com/vayunmathur/auto/service/MusicCaptureService.kt@@ -40,15 +40,11 @@ class MusicCaptureService : Service() { return START_NOT_STICKY } val notification = notification()- if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) {- startForeground(- NOTIFICATION_ID,- notification,- ServiceInfo.FOREGROUND_SERVICE_TYPE_MEDIA_PROJECTION,- )- } else {- startForeground(NOTIFICATION_ID, notification)- }+ startForeground(+ NOTIFICATION_ID,+ notification,+ ServiceInfo.FOREGROUND_SERVICE_TYPE_MEDIA_PROJECTION,+ ) capture = MusicCapture( this, mediaSink = { MusicCaptureSinkHolder.sink },
auto/src/main/java/com/vayunmathur/auto/service/ProjectionService.kt
diff --git a/auto/src/main/java/com/vayunmathur/auto/service/ProjectionService.kt b/auto/src/main/java/com/vayunmathur/auto/service/ProjectionService.ktindex e69c386195..250d29b1dd 100644--- a/auto/src/main/java/com/vayunmathur/auto/service/ProjectionService.kt+++ b/auto/src/main/java/com/vayunmathur/auto/service/ProjectionService.kt@@ -61,10 +61,12 @@ import kotlin.concurrent.thread class ProjectionService : Service() { private var worker: Thread? = null+ private var connectivityReceiver: com.vayunmathur.auto.platform.ConnectivityEventReceiver? = null @Volatile private var running = false override fun onBind(intent: Intent?): IBinder? = null + @androidx.car.app.annotations.ExperimentalCarApi override fun onStartCommand(intent: Intent?, flags: Int, startId: Int): Int { if (running) return START_STICKY running = true@@ -76,6 +78,15 @@ class ProjectionService : Service() { AutoSessionState.onMediaEvent(MediaEvent.NowPlayingChanged(info)) video?.wiring?.setNowPlaying(info) }.also { it.start() }+ // Connectivity changes are implicit broadcasts: a manifest entry+ // never fires on API 24+, so the receiver lives with the session.+ connectivityReceiver = com.vayunmathur.auto.platform.ConnectivityEventReceiver()+ androidx.core.content.ContextCompat.registerReceiver(+ this,+ connectivityReceiver,+ android.content.IntentFilter(android.net.ConnectivityManager.CONNECTIVITY_ACTION),+ androidx.core.content.ContextCompat.RECEIVER_NOT_EXPORTED,+ ) worker = thread(name = "ma-auto-projection") { serve() } return START_STICKY }@@ -86,6 +97,8 @@ class ProjectionService : Service() { // ServerSocket raises there, which runSession reports as a failure the // loop then drops because running is false. Interrupt alone cannot do // this -- accept() ignores thread interruption.+ connectivityReceiver?.let { runCatching { unregisterReceiver(it) } }+ connectivityReceiver = null server?.close() worker?.interrupt() mediaMonitor?.stop()@@ -100,6 +113,7 @@ class ProjectionService : Service() { /** Backoff between sessions; owns no threads, just the delay policy. */ private val reconnectBackoff = ReconnectBackoff() + @androidx.car.app.annotations.ExperimentalCarApi private fun serve() { HeadUnitServer().use { server -> this.server = server@@ -136,6 +150,7 @@ class ProjectionService : Service() { * runs the same session body, and TLS/GAL downstream never learn which * intake won. */+ @androidx.car.app.annotations.ExperimentalCarApi private fun runSession(server: HeadUnitServer): Boolean { TransportIntake.take()?.let { pending -> var failed = false@@ -189,6 +204,7 @@ class ProjectionService : Service() { } }.getOrDefault(false) + @androidx.car.app.annotations.ExperimentalCarApi private fun session(server: HeadUnitServer) { server.accept().use { socket -> // The TCP loopback path wraps its socket as an intake pending so@@ -209,6 +225,7 @@ class ProjectionService : Service() { * The caller owns the raw resource (socket or parked transport); this * owns everything GAL. */+ @androidx.car.app.annotations.ExperimentalCarApi private fun sessionOnTransport(transport: GalTransport, carName: String) { // A head unit is on the wire; the phone status screen leaves Disconnected. AutoSessionState.onSocketAccepted()@@ -312,6 +329,7 @@ class ProjectionService : Service() { * opens, so TTS resolves its sink lazily and early utterances drop with * a count. */+ @androidx.car.app.annotations.ExperimentalCarApi private fun startSessionScoped() { // Call snapshots push into the car card like focus mirrors into the // phone flows: added/changed replace wholesale, removed clears.@@ -432,12 +450,7 @@ class ProjectionService : Service() { val pending = ChannelSetups() var reportedActive = false while (running && connection.pump()) {- // Open every advertised service in HU-discovery wire order, one at a- // time: the next 0x7 goes out only once the previous channel is- // granted (openChannels) or refused (refusedChannels, or a bare- // 0xff with no 0x8 -- DHU 2.0 answers that way). gearhead opens in- // this same order (`jbp.i[]` follows the `xob.c` wire order).- // Video setup additionally waits for its own channel grant.+ // Open every advertised service in HU-discovery wire order, one at a time: the next request goes out only once the previous channel is granted or refused, and video setup additionally waits for its own channel grant. if (connection.session.state == SessionState.ACTIVE) { reportedActive = reportActiveOnce(connection, carName, reportedActive) openNext(connection)
auto/src/main/java/com/vayunmathur/auto/ui/AppScreen.kt
diff --git a/auto/src/main/java/com/vayunmathur/auto/ui/AppScreen.kt b/auto/src/main/java/com/vayunmathur/auto/ui/AppScreen.ktindex d36c33b595..5ed258b5d7 100644--- a/auto/src/main/java/com/vayunmathur/auto/ui/AppScreen.kt+++ b/auto/src/main/java/com/vayunmathur/auto/ui/AppScreen.kt@@ -42,7 +42,7 @@ fun AppScreen(appId: String, modifier: Modifier = Modifier) { private fun MapSurfaceIsland(modifier: Modifier = Modifier) { AndroidView( factory = { context ->- TextureView(context).apply {+ CarTextureView(context).apply { surfaceTextureListener = object : TextureView.SurfaceTextureListener { override fun onSurfaceTextureAvailable(surface: SurfaceTexture, width: Int, height: Int) { CarLauncherState.mapSurfaceListener?.invoke(Surface(surface), width, height)@@ -57,7 +57,8 @@ private fun MapSurfaceIsland(modifier: Modifier = Modifier) { override fun onSurfaceTextureUpdated(surface: SurfaceTexture) = Unit }- setOnTouchListener { _, event ->+ setOnTouchListener { view, event ->+ if (event.action == android.view.MotionEvent.ACTION_UP) view.performClick() CarLauncherState.mapTouchForwarder?.invoke(event.action, event.x, event.y) == true } }@@ -65,3 +66,11 @@ private fun MapSurfaceIsland(modifier: Modifier = Modifier) { modifier = modifier, ) }++/** Map surface view: forwards touches to the car, so clicks are reported through performClick. */+private class CarTextureView(context: android.content.Context) : TextureView(context) {+ override fun performClick(): Boolean {+ super.performClick()+ return true+ }+}
auto/src/main/java/com/vayunmathur/auto/ui/AudioRow.kt
diff --git a/auto/src/main/java/com/vayunmathur/auto/ui/AudioRow.kt b/auto/src/main/java/com/vayunmathur/auto/ui/AudioRow.ktindex dc85497a17..a54121db87 100644--- a/auto/src/main/java/com/vayunmathur/auto/ui/AudioRow.kt+++ b/auto/src/main/java/com/vayunmathur/auto/ui/AudioRow.kt@@ -1,6 +1,7 @@ package com.vayunmathur.auto.ui import androidx.compose.runtime.Composable+import androidx.compose.ui.res.pluralStringResource import androidx.compose.ui.res.stringResource import com.vayunmathur.auto.R import com.vayunmathur.auto.platform.AudioSinkState@@ -44,7 +45,7 @@ fun AudioRow( ListItem( headlineContent = { Text(stringResource(R.string.session_audio_mic)) }, supportingContent = {- Text(stringResource(R.string.session_audio_mic_value, micTurns, micAcks))+ Text(pluralStringResource(R.plurals.session_audio_mic_value, micTurns.toInt(), micTurns, micAcks)) }, ) ListItem(
auto/src/main/java/com/vayunmathur/auto/ui/AutoScreen.kt
diff --git a/auto/src/main/java/com/vayunmathur/auto/ui/AutoScreen.kt b/auto/src/main/java/com/vayunmathur/auto/ui/AutoScreen.ktindex bc91ce58df..7d680caf52 100644--- a/auto/src/main/java/com/vayunmathur/auto/ui/AutoScreen.kt+++ b/auto/src/main/java/com/vayunmathur/auto/ui/AutoScreen.kt@@ -8,6 +8,7 @@ import androidx.compose.foundation.verticalScroll import androidx.compose.runtime.Composable import androidx.compose.runtime.getValue import androidx.compose.ui.Modifier+import androidx.compose.ui.res.pluralStringResource import androidx.compose.ui.res.stringResource import androidx.compose.ui.unit.dp import androidx.lifecycle.compose.collectAsStateWithLifecycle@@ -106,7 +107,7 @@ fun AutoScreen( Card(Modifier.fillMaxWidth().padding(top = 16.dp)) { ListItem( headlineContent = { Text(stringResource(R.string.pinned_apps_title)) },- supportingContent = { Text(stringResource(R.string.pinned_apps_body, PinnedAppsPrefs.MAX_PINNED)) },+ supportingContent = { Text(pluralStringResource(R.plurals.pinned_apps_body, PinnedAppsPrefs.MAX_PINNED, PinnedAppsPrefs.MAX_PINNED)) }, trailingContent = { TextButton(onClick = onPinnedApps) { Text(stringResource(R.string.pinned_apps_title))
auto/src/main/java/com/vayunmathur/auto/ui/LauncherRoot.kt
diff --git a/auto/src/main/java/com/vayunmathur/auto/ui/LauncherRoot.kt b/auto/src/main/java/com/vayunmathur/auto/ui/LauncherRoot.ktindex e26470dd20..c395eee414 100644--- a/auto/src/main/java/com/vayunmathur/auto/ui/LauncherRoot.kt+++ b/auto/src/main/java/com/vayunmathur/auto/ui/LauncherRoot.kt@@ -1,4 +1,6 @@ package com.vayunmathur.auto.ui+import com.vayunmathur.auto.platform.carRouteFor+import com.vayunmathur.auto.platform.syncCarRoute import androidx.compose.foundation.layout.Column import androidx.compose.foundation.layout.fillMaxSize@@ -9,9 +11,9 @@ import androidx.compose.runtime.remember import androidx.compose.ui.Modifier import androidx.lifecycle.compose.collectAsStateWithLifecycle import com.vayunmathur.auto.Route-import com.vayunmathur.auto.carRouteFor+import com.vayunmathur.auto.platform.carRouteFor import com.vayunmathur.auto.platform.CarLauncherState-import com.vayunmathur.auto.syncCarRoute+import com.vayunmathur.auto.platform.syncCarRoute import com.vayunmathur.library.ui.MaterialTheme import com.vayunmathur.library.ui.Surface import com.vayunmathur.library.util.rememberNavBackStack
auto/src/main/java/com/vayunmathur/auto/ui/MessagingConsentCard.kt
diff --git a/auto/src/main/java/com/vayunmathur/auto/ui/MessagingConsentCard.kt b/auto/src/main/java/com/vayunmathur/auto/ui/MessagingConsentCard.ktindex 0c6ed32130..2e455e8b9e 100644--- a/auto/src/main/java/com/vayunmathur/auto/ui/MessagingConsentCard.kt+++ b/auto/src/main/java/com/vayunmathur/auto/ui/MessagingConsentCard.kt@@ -34,6 +34,7 @@ import com.vayunmathur.library.ui.rememberMessenger fun MessagingConsentCard(modifier: Modifier = Modifier) { val context = LocalContext.current val messenger = rememberMessenger()+ val listenerMissingMessage = stringResource(R.string.messaging_listener_missing) var listenerGranted by remember { mutableStateOf(SpecialAccess.hasNotificationListener(context)) } var consented by remember { mutableStateOf(MessagingPrefs.isMirroringConsented(context)) } Card(modifier.fillMaxWidth()) {@@ -74,9 +75,7 @@ fun MessagingConsentCard(modifier: Modifier = Modifier) { runCatching { SpecialAccess.requestNotificationListener(context) }.onFailure {- messenger.show(- context.getString(R.string.messaging_listener_missing),- )+ messenger.show(listenerMissingMessage) } }) { Text(stringResource(R.string.messaging_open_settings))
auto/src/main/java/com/vayunmathur/auto/ui/MusicCaptureCard.kt
diff --git a/auto/src/main/java/com/vayunmathur/auto/ui/MusicCaptureCard.kt b/auto/src/main/java/com/vayunmathur/auto/ui/MusicCaptureCard.ktindex 2b6c093be0..d0d8eb1a9d 100644--- a/auto/src/main/java/com/vayunmathur/auto/ui/MusicCaptureCard.kt+++ b/auto/src/main/java/com/vayunmathur/auto/ui/MusicCaptureCard.kt@@ -38,6 +38,7 @@ import com.vayunmathur.library.ui.rememberMessenger fun MusicCaptureCard(modifier: Modifier = Modifier) { val context = LocalContext.current val messenger = rememberMessenger()+ val deniedMessage = stringResource(R.string.music_capture_denied) var consented by remember { mutableStateOf(MusicCapturePrefs.isMusicCaptureConsented(context)) } var granted by remember { mutableStateOf(MusicCaptureGrant.hasGrant()) } val projectionLauncher = rememberLauncherForActivityResult(@@ -48,7 +49,7 @@ fun MusicCaptureCard(modifier: Modifier = Modifier) { granted = true com.vayunmathur.auto.service.MusicCaptureService.startIfGranted(context) } else {- messenger.show(context.getString(R.string.music_capture_denied))+ messenger.show(deniedMessage) granted = false } }@@ -89,7 +90,7 @@ fun MusicCaptureCard(modifier: Modifier = Modifier) { runCatching { projectionLauncher.launch(manager.createScreenCaptureIntent()) }.onFailure {- messenger.show(context.getString(R.string.music_capture_denied))+ messenger.show(deniedMessage) } }) { Text(stringResource(R.string.mic_allow))
auto/src/main/java/com/vayunmathur/auto/ui/PairingScreen.kt
diff --git a/auto/src/main/java/com/vayunmathur/auto/ui/PairingScreen.kt b/auto/src/main/java/com/vayunmathur/auto/ui/PairingScreen.ktindex c7bd4632b9..5435266778 100644--- a/auto/src/main/java/com/vayunmathur/auto/ui/PairingScreen.kt+++ b/auto/src/main/java/com/vayunmathur/auto/ui/PairingScreen.kt@@ -67,10 +67,14 @@ fun PairingScreen(viewModel: PairingViewModel, onNavigateBack: () -> Unit) { } val requestNearby = rememberMultiplePermissionRequest(- permissions = arrayOf(- Manifest.permission.ACCESS_FINE_LOCATION,- Manifest.permission.NEARBY_WIFI_DEVICES,- ),+ permissions = if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.TIRAMISU) {+ arrayOf(+ Manifest.permission.ACCESS_FINE_LOCATION,+ Manifest.permission.NEARBY_WIFI_DEVICES,+ )+ } else {+ arrayOf(Manifest.permission.ACCESS_FINE_LOCATION)+ }, onResult = { granted -> if (granted) WifiDirectConnector.start(context) },
auto/src/main/java/com/vayunmathur/auto/ui/PinnedAppsScreen.kt
diff --git a/auto/src/main/java/com/vayunmathur/auto/ui/PinnedAppsScreen.kt b/auto/src/main/java/com/vayunmathur/auto/ui/PinnedAppsScreen.ktindex 1cefeae0fe..ac7a66107c 100644--- a/auto/src/main/java/com/vayunmathur/auto/ui/PinnedAppsScreen.kt+++ b/auto/src/main/java/com/vayunmathur/auto/ui/PinnedAppsScreen.kt@@ -14,6 +14,7 @@ import androidx.compose.runtime.getValue import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier import androidx.compose.ui.platform.LocalContext+import androidx.compose.ui.res.pluralStringResource import androidx.compose.ui.res.stringResource import androidx.compose.ui.unit.dp import androidx.lifecycle.compose.collectAsStateWithLifecycle@@ -40,6 +41,7 @@ import com.vayunmathur.library.ui.rememberMessenger * shared snackbar host — never a Toast. */ @Composable[email protected] fun PinnedAppsScreen( onNavigateBack: () -> Unit, viewModel: PinnedAppsViewModel = viewModel(),@@ -48,9 +50,10 @@ fun PinnedAppsScreen( val messenger = rememberMessenger() val rows by viewModel.rows.collectAsStateWithLifecycle() val rejected by viewModel.rejected.collectAsStateWithLifecycle()+ val pluralFullMessage = pluralStringResource(R.plurals.pinned_apps_full, PinnedAppsPrefs.MAX_PINNED, PinnedAppsPrefs.MAX_PINNED) LaunchedEffect(rejected) { if (rejected != null) {- messenger.show(context.getString(R.string.pinned_apps_full, PinnedAppsPrefs.MAX_PINNED))+ messenger.show(pluralFullMessage) viewModel.consumeRejected() } }@@ -70,6 +73,7 @@ fun PinnedAppsScreen( * this directly with literals. */ @Composable[email protected] fun PinnedAppsScreen( onNavigateBack: () -> Unit, rows: List<PinnedAppRow>,@@ -89,7 +93,7 @@ fun PinnedAppsScreen( ) { item { Text(- text = stringResource(R.string.pinned_apps_body, PinnedAppsPrefs.MAX_PINNED),+ text = pluralStringResource(R.plurals.pinned_apps_body, PinnedAppsPrefs.MAX_PINNED, PinnedAppsPrefs.MAX_PINNED), style = MaterialTheme.typography.bodyMedium, modifier = Modifier.padding(vertical = 8.dp), )
auto/src/main/res/values-es/strings.xml
diff --git a/auto/src/main/res/values-es/strings.xml b/auto/src/main/res/values-es/strings.xmlindex 553eccef41..83bab1ebdb 100644--- a/auto/src/main/res/values-es/strings.xml+++ b/auto/src/main/res/values-es/strings.xml@@ -7,45 +7,19 @@ <string name="session_focus_none">Desconocido</string> <string name="session_focus_projected">Proyectado</string> <string name="session_focus_native">Nativo</string>- <string name="car_call_answer">Responder</string>- <string name="car_dnd_glyph">⊘</string> <string name="session_input_allowed">Entrada</string> <string name="session_surface">Superficie</string>- <string name="car_alpha_jump_glyph">A-Z</string> <string name="pairing_wireless_cancel">Detener</string>- <string name="car_search_glyph">⌕</string>- <string name="car_call_mute">Silenciar</string> <string name="pairing_transport_usb">USB</string>- <string name="car_search_hint">Buscar</string>- <string name="car_browsing_exit">Salir</string> <string name="projection_channel">Proyección</string>- <string name="car_exit_glyph">✕</string>- <string name="car_back_label">Atrás</string>- <string name="car_drawer_apps">Aplicaciones</string>- <string name="car_drawer_glyph">▦</string>- <string name="car_home_glyph">⌂</string>- <string name="car_call_resume">Reanudar</string>- <string name="car_back_glyph">←</string>- <string name="car_etc_glyph">⋯</string>- <string name="car_media_previous">Anterior</string>- <string name="car_media_next">Siguiente</string>- <string name="car_media_play">Reproducir</string>- <string name="car_media_pause">Pausar</string>- <string name="car_media_prev_glyph">⏮</string>- <string name="car_media_next_glyph">⏭</string>- <string name="car_media_play_glyph">▶</string>- <string name="car_media_pause_glyph">⏸</string> <string name="session_credential">Certificado</string> <string name="connection">Conexión</string>- <string name="car_assistant_glyph">◉</string> <string name="state_connecting">Conectando…</string>- <string name="car_assistant_label">Asistente</string> <string name="mic_allow">Permitir</string> <string name="session_now_playing_unknown">Pista desconocida</string> <string name="session_now_playing_unknown_artist">Artista desconocido</string> <string name="pairing_usb">Cable USB</string> <string name="pairing_usb_retry">Preguntar de nuevo</string>- <string name="car_call_incoming">Llamada entrante</string> <string name="session_audio_bytes">Bytes de audio</string> <string name="state_disconnected">No conectado a un auto</string> <string name="state_projecting">Proyectando a <xliff:g example="Pioneer" id="car">%1$s</xliff:g></string>
auto/src/main/res/values/strings.xml
diff --git a/auto/src/main/res/values/strings.xml b/auto/src/main/res/values/strings.xmlindex a720d9063c..19f6cfdaeb 100644--- a/auto/src/main/res/values/strings.xml+++ b/auto/src/main/res/values/strings.xml@@ -237,17 +237,13 @@ <string name="projection_running">Connected to a car</string> <!-- Second line of the car status bar, under the product name. -->- <string name="car_connected">Connected</string> <!-- The car display now-playing card reuses the session now-playing strings above (session_now_playing*); no car-specific copies are kept. --> <!-- Shown on the car display when no launchable apps were found on the phone. --> <string name="car_no_apps">No apps available — install Maps or Music to get started</string> <!-- Label of the hotseat drawer cell and the drawer heading listing every car app. -->- <string name="car_drawer_apps">Apps</string> <!-- Decorative glyph shown on the hotseat drawer cell, which has no app icon. -->- <string name="car_drawer_glyph">▦</string> <!-- Decorative glyph on the facet dashboard button (goes home, closes drawer). -->- <string name="car_home_glyph">⌂</string> <!-- Heading of the session-card row showing the system sink (ch4, transient TTS/pings). --> <string name="session_audio_sys">System audio</string>@@ -297,7 +293,7 @@ <!-- Heading of the session-card row counting ch6 mic turns and acks. --> <string name="session_audio_mic">Car mic</string> <!-- %1$d is mic turns that yielded PCM, %2$d is chunks acked upstream. -->- <string name="session_audio_mic_value"><xliff:g example="2" id="turns">%1$d</xliff:g> turns / <xliff:g example="140" id="acks">%2$d</xliff:g> acked</string>+ <plurals name="session_audio_mic_value"><item quantity="one"><xliff:g example="2" id="turns">%1$d</xliff:g> turn / <xliff:g example="140" id="acks">%2$d</xliff:g> acked</item><item quantity="other"><xliff:g example="2" id="turns">%1$d</xliff:g> turns / <xliff:g example="140" id="acks">%2$d</xliff:g> acked</item></plurals> <!-- Heading of the row counting TTS utterances that reached the car. --> <string name="session_audio_tts">Car TTS</string> @@ -317,87 +313,52 @@ <!-- Content description of the rail assistant slot. Shown only when the phone has an assistant to open; otherwise the slot stays gone. -->- <string name="car_assistant_label">Assistant</string> <!-- Decorative glyph on the rail assistant icon, which has no app icon of its own. -->- <string name="car_assistant_glyph">◉</string> <!-- Decorative glyph on the native-rail back button. -->- <string name="car_back_glyph">←</string> <!-- Content description of the native-rail back button. -->- <string name="car_back_label">Back</string> <!-- Decorative glyph on the native-rail exit button. -->- <string name="car_exit_glyph">✕</string> <!-- Decorative glyph standing in for the rail etc affordance icon. -->- <string name="car_etc_glyph">⋯</string> <!-- Content description of the media card previous-track button. -->- <string name="car_media_previous">Previous</string> <!-- Content description of the media card next-track button. -->- <string name="car_media_next">Next</string> <!-- Content description of the media card play button, shown while paused. -->- <string name="car_media_play">Play</string> <!-- Content description of the media card pause button, shown while playing. -->- <string name="car_media_pause">Pause</string> <!-- Decorative glyph on the media card previous-track button. -->- <string name="car_media_prev_glyph">⏮</string> <!-- Decorative glyph on the media card next-track button. -->- <string name="car_media_next_glyph">⏭</string> <!-- Decorative glyph on the media card play button, shown while paused. -->- <string name="car_media_play_glyph">▶</string> <!-- Decorative glyph on the media card pause button, shown while playing. -->- <string name="car_media_pause_glyph">⏸</string> <!-- Distance to the next maneuver on the nav card. %1$d is whole metres; translators own the unit so it can be spaced or abbreviated per locale. -->- <string name="car_nav_distance_meters"><xliff:g example="500" id="meters">%1$d</xliff:g> m</string> <!-- Empty-tile label on the nav card, shown only when no map backend exists at all (maps missing or the car-app host bind failed). -->- <string name="car_nav_open_maps">Open Maps</string> <!-- Drawer empty state. Exact gearhead `appdecor_menu_empty` value. -->- <string name="car_drawer_empty">No Items</string> <!-- Drawer lockout text shown while driving-restricted. Exact gearhead `speedbump_lockout_message` value. -->- <string name="car_drawer_lockout">Safety pause. Back soon.</string> <!-- Parked-browsing exit header text. Exact gearhead `content_browse_park_to_continue` value. -->- <string name="car_browsing_locked">Browsing locked for safety.</string> <!-- Parked-browsing exit header button. Exact gearhead `content_browse_unlimited_browsing_exit` value. -->- <string name="car_browsing_exit">Exit</string> <!-- AppDecor search box hint. Exact gearhead `appdecor_search_box_hint` value. -->- <string name="car_search_hint">Search</string> <!-- Decorative glyph on the AppDecor search button. -->- <string name="car_search_glyph">⌕</string> <!-- Decorative glyph on the alpha-jump fast-scroll button. -->- <string name="car_alpha_jump_glyph">A-Z</string> <!-- Glyph for the rail DND slot (gearhead `gs_do_not_disturb_on_vd_theme_24`; gone unless filtered). -->- <string name="car_dnd_glyph">⊘</string> <!-- Shown on the car call card when the number is withheld. -->- <string name="car_call_unknown">Unknown caller</string> <!-- Shown on the car call card while ringing. -->- <string name="car_call_incoming">Incoming call</string> <!-- Shown on the car call card while connected. -->- <string name="car_call_active">On call</string> <!-- Call duration on the car call card. %1$d is minutes, %2$02d is zero-padded seconds. -->- <string name="car_call_duration"><xliff:g example="2" id="minutes">%1$d</xliff:g>:<xliff:g example="05" id="seconds">%2$02d</xliff:g></string> <!-- Shown on the car call card answer button while ringing. -->- <string name="car_call_answer">Answer</string> <!-- Shown on the car call card decline button while ringing. -->- <string name="car_call_decline">Decline</string> <!-- Shown on the car call card end button while connected. -->- <string name="car_call_end">End</string> <!-- Shown on the car call card mute button while unmuted. -->- <string name="car_call_mute">Mute</string> <!-- Shown on the car call card mute button while muted. -->- <string name="car_call_unmute">Unmute</string> <!-- Shown on the car call card hold button while active. -->- <string name="car_call_hold">Hold</string> <!-- Shown on the car call card hold button while held. -->- <string name="car_call_resume">Resume</string> <!-- Title of the car dock pin picker; also used for the button opening it. --> <string name="pinned_apps_title">Car dock</string> <!-- Explains the picker: check apps to pin, reorder with the arrows. %1$d is the max pins. -->- <string name="pinned_apps_body">Choose up to %1$d car apps for the bottom bar, in order.</string>+ <plurals name="pinned_apps_body"><item quantity="one">Choose up to %1$d car app for the bottom bar, in order.</item><item quantity="other">Choose up to %1$d car apps for the bottom bar, in order.</item></plurals> <!-- %1$d is the pinned position, 1-based. --> <string name="pinned_apps_rank">Pinned %1$d</string> <!-- Snackbar when pinning while the dock is full. %1$d is the max pins. -->- <string name="pinned_apps_full">The dock holds %1$d apps — unpin one first</string>+ <plurals name="pinned_apps_full"><item quantity="one">The dock holds %1$d app — unpin one first</item><item quantity="other">The dock holds %1$d apps — unpin one first</item></plurals> </resources>
auto/src/test/java/com/vayunmathur/auto/CarRouteTest.kt
diff --git a/auto/src/test/java/com/vayunmathur/auto/CarRouteTest.kt b/auto/src/test/java/com/vayunmathur/auto/CarRouteTest.ktindex a4471c99bc..bd10f64353 100644--- a/auto/src/test/java/com/vayunmathur/auto/CarRouteTest.kt+++ b/auto/src/test/java/com/vayunmathur/auto/CarRouteTest.kt@@ -1,4 +1,6 @@ package com.vayunmathur.auto+import com.vayunmathur.auto.platform.carRouteFor+import com.vayunmathur.auto.platform.syncCarRoute import com.vayunmathur.library.util.NavBackStack import org.junit.runner.RunWith
auto/src/test/java/com/vayunmathur/auto/Y3AutoDiscoveryTest.kt
diff --git a/auto/src/test/java/com/vayunmathur/auto/Y3AutoDiscoveryTest.kt b/auto/src/test/java/com/vayunmathur/auto/Y3AutoDiscoveryTest.ktindex 1aaddf00a0..cc4653ae13 100644--- a/auto/src/test/java/com/vayunmathur/auto/Y3AutoDiscoveryTest.kt+++ b/auto/src/test/java/com/vayunmathur/auto/Y3AutoDiscoveryTest.kt@@ -21,6 +21,7 @@ import kotlin.test.assertTrue @RunWith(RobolectricTestRunner::class) @Config(sdk = [34])[email protected] class Y3AutoDiscoveryTest { private val app get() = ApplicationProvider.getApplicationContext<Application>() private val ctx: Context get() = app
auto/src/test/java/com/vayunmathur/auto/platform/CarDiscoveryTest.kt
diff --git a/auto/src/test/java/com/vayunmathur/auto/platform/CarDiscoveryTest.kt b/auto/src/test/java/com/vayunmathur/auto/platform/CarDiscoveryTest.ktindex 5f2b5190ae..857e07a809 100644--- a/auto/src/test/java/com/vayunmathur/auto/platform/CarDiscoveryTest.kt+++ b/auto/src/test/java/com/vayunmathur/auto/platform/CarDiscoveryTest.kt@@ -17,6 +17,7 @@ import kotlin.test.assertTrue * ever shown. The refusal ledger round-trips per component. */ @RunWith(RobolectricTestRunner::class)[email protected] class CarDiscoveryTest { private val context: android.content.Context
auto/src/test/java/com/vayunmathur/auto/platform/DiscoveryDeepTest.kt
diff --git a/auto/src/test/java/com/vayunmathur/auto/platform/DiscoveryDeepTest.kt b/auto/src/test/java/com/vayunmathur/auto/platform/DiscoveryDeepTest.ktindex 42394cd4f6..2aa860ca93 100644--- a/auto/src/test/java/com/vayunmathur/auto/platform/DiscoveryDeepTest.kt+++ b/auto/src/test/java/com/vayunmathur/auto/platform/DiscoveryDeepTest.kt@@ -24,6 +24,7 @@ import kotlin.test.assertTrue * Robolectric PackageManager with installed packages registered. */ @RunWith(RobolectricTestRunner::class)[email protected] class DiscoveryDeepTest { private val ctx get() = ApplicationProvider.getApplicationContext<Context>() private val pm get() = ctx.packageManager
auto/src/test/java/com/vayunmathur/auto/ui/AudioRowTest.kt
diff --git a/auto/src/test/java/com/vayunmathur/auto/ui/AudioRowTest.kt b/auto/src/test/java/com/vayunmathur/auto/ui/AudioRowTest.ktindex 8ac81b6462..1fb83f818b 100644--- a/auto/src/test/java/com/vayunmathur/auto/ui/AudioRowTest.kt+++ b/auto/src/test/java/com/vayunmathur/auto/ui/AudioRowTest.kt@@ -47,7 +47,7 @@ class AudioRowTest { .assertCountEquals(2) val zero = appContext.getString(AutoR.string.session_stat_value, 0L) rule.onAllNodes(hasText(zero)).assertCountEquals(3)- val mic = appContext.getString(AutoR.string.session_audio_mic_value, 0L, 0L)+ val mic = appContext.resources.getQuantityString(AutoR.plurals.session_audio_mic_value, 0, 0L, 0L) rule.onAllNodes(hasText(mic)).assertCountEquals(1) } @@ -78,7 +78,7 @@ class AudioRowTest { .assertCountEquals(1) rule.onAllNodes(hasText(appContext.getString(AutoR.string.session_stat_value, 2048L))) .assertCountEquals(1)- val mic = appContext.getString(AutoR.string.session_audio_mic_value, 3L, 2L)+ val mic = appContext.resources.getQuantityString(AutoR.plurals.session_audio_mic_value, 3, 3L, 2L) rule.onAllNodes(hasText(mic)).assertCountEquals(1) }
auto/src/test/java/com/vayunmathur/auto/ui/AutoSessionCardTest.kt
diff --git a/auto/src/test/java/com/vayunmathur/auto/ui/AutoSessionCardTest.kt b/auto/src/test/java/com/vayunmathur/auto/ui/AutoSessionCardTest.ktindex b222203b77..6d7a886012 100644--- a/auto/src/test/java/com/vayunmathur/auto/ui/AutoSessionCardTest.kt+++ b/auto/src/test/java/com/vayunmathur/auto/ui/AutoSessionCardTest.kt@@ -207,7 +207,7 @@ class AutoSessionCardTest { val streaming = appContext.getString(AutoR.string.session_audio_sink_streaming, "Full") assertSingleText(streaming) assertSingleText(appContext.getString(AutoR.string.session_audio_sink_idle))- val mic = appContext.getString(AutoR.string.session_audio_mic_value, 3L, 2L)+ val mic = appContext.resources.getQuantityString(AutoR.plurals.session_audio_mic_value, 3, 3L, 2L) assertSingleText(mic) }
auto/src/test/java/com/vayunmathur/auto/ui/PinnedAppsAndGridTest.kt
diff --git a/auto/src/test/java/com/vayunmathur/auto/ui/PinnedAppsAndGridTest.kt b/auto/src/test/java/com/vayunmathur/auto/ui/PinnedAppsAndGridTest.ktindex b68090990c..dd03ac901c 100644--- a/auto/src/test/java/com/vayunmathur/auto/ui/PinnedAppsAndGridTest.kt+++ b/auto/src/test/java/com/vayunmathur/auto/ui/PinnedAppsAndGridTest.kt@@ -60,7 +60,7 @@ class PinnedAppsAndGridTest { ) } rule.onNodeWithText(- appContext.getString(AutoR.string.pinned_apps_body, 5),+ appContext.resources.getQuantityString(AutoR.plurals.pinned_apps_body, 5, 5), ).assertExists() rule.onNodeWithText("Maps").assertExists() rule.onNodeWithText("Music").assertExists()