Migrate Android Auto implementation to androidx.car.app:app:1.7.0 - #2008
Migrate Android Auto implementation to androidx.car.app:app:1.7.0#2008rainman74 wants to merge 1 commit into
Conversation
Ports the missing pieces from DrKLO/Telegram#2008 into risin42/NagramX: align the Android Auto code path with the androidx.car.app:app:1.7.0 contract that the rest of the codebase already assumes. This repo already pins androidx.car.app:app:1.7.0 (and app-projected:1.7.0), so the dependency bump itself is in place. What's missing is the rest of the 1.7.x contract that the upstream PR bundled: the two transitive deps (androidx.media, androidx.lifecycle), the manifest side, the automotive_app_desc.xml template category, and the Person setKey guarantee in HomeScreen that the 1.7.x ConversationItem.validateSender() requires. The AndroidX media-compat artifact androidx.media:media:1.7.0 keeps its classes under the legacy android.support.v4.media.* package for binary compatibility reasons — the import migration to androidx.media.* is NOT applied here (it would reference non-existent classes). Only the new transitive dependency is added; existing android.support.v4.media.* imports are left as-is. Build / manifest - add androidx.media:media:1.7.0 (AndroidX media session) - add androidx.lifecycle:lifecycle-runtime:2.7.0 (DefaultLifecycleObserver) - uncomment the entire CarAppService <meta-data> + <service> block in AndroidManifest.xml; bump minCarApiLevel 5 -> 7 (required by ConversationItem @RequiresCarApi(7)) - automotive_app_desc.xml: add <uses name="media"/> for the new CarAppService messaging category, keep notification and template Code - HomeScreen: ensure Person always carries a key, which the 1.7.x ConversationItem.validateSender() requires. Applied locally to the senderBuilder.setName("") branch in buildCarMessage, matching the upstream intent without touching the surrounding code (NagramX has a richer DefaultLifecycleObserver + NotificationCenter pipeline than the upstream). NagramX-specific context - NagramX already ships androidx.car.app:app:1.7.0 and app-projected:1.7.0; the dependency swap itself is a no-op in this repo — only the two missing transitive dependencies and the manifest / xml / setKey changes are added. - Final diff against dev: 4 files, 5 insertions(+), 4 deletions(-). Refs: DrKLO/Telegram#2008
Ports DrKLO/Telegram PR #2008 (branch fix/android-auto-1.7, commit 32ca438) into NagramXF. The car-app code introduced in 12.8.0 already uses the 1.7.x API (ConversationItem, ConversationCallback, CarMessage), but build.gradle still pinned androidx.car.app:app:1.4.0, leaving the CarAppService code path in an unbuildable state. Bump the dependency and align the rest of the codebase with the 1.7.x contract. The AndroidX media-compat artifact androidx.media:media:1.7.0 keeps its classes under the legacy android.support.v4.media.* package for binary compatibility reasons — the import migration to androidx.media.* is NOT applied here (it would reference non-existent classes). Only the new transitive dependency is added; existing android.support.v4.media.* imports are left as-is. Build / manifest - androidx.car.app:app 1.4.0 -> 1.7.0 - drop androidx.car.app:app-projected (1.4-era AAR, unused in 1.7+) - add androidx.media:media:1.7.0 (AndroidX media session) - add androidx.lifecycle:lifecycle-runtime:2.7.0 (DefaultLifecycleObserver) - minCarApiLevel 5 -> 7 (required by ConversationItem @RequiresCarApi(7)) - automotive_app_desc.xml: add 'media' for the new CarAppService messaging category, keep 'template' for the new category, keep 'notification' for the regular notification path Code - HomeScreen: ensure Person always carries a key, which the 1.7.x ConversationItem.validateSender() requires. NagramXF-specific context - NagramXF already ships androidx.mediarouter:mediarouter:1.8.0 (upstream PR also bumps it to 1.7.0; 1.8.0 is the patch above and is left as-is). - The car-app metadata block in AndroidManifest.xml was entirely commented out in NagramXF; this commit uncomments it and bumps minCarApiLevel from 5 to 7 alongside the dependency bump. - Final diff against dev: 4 files, 7 insertions(+), 7 deletions(-). Refs: DrKLO/Telegram#2008
32ca438 to
43c3a52
Compare
|
Update: corrected the import migration in commit The original commit Verified by downloading the actual
So the original import migration would not have compiled. Fix: force-pushed commit Final diff vs |
…ar.app:1.7.0 Aligns the Android Auto code path with the androidx.car.app:app:1.7.0 contract that the rest of the codebase already assumes. Combines the transitive dependency and manifest pieces from DrKLO/Telegram#2008 with the MediaPlayerService/MediaSession integration that risin42 added in ec956e3 ("fix: Android Auto support", co-authored by rainman74). The AndroidX media-compat artifact androidx.media:media:1.7.0 keeps its classes under the legacy android.support.v4.media.* package for binary compatibility reasons - the import migration to androidx.media.* is NOT applied here (it would reference non-existent classes). Only the new transitive dependency is added; existing android.support.v4.media.* imports are left as-is. Build - add androidx.media:media:1.7.0 (AndroidX media session) - add androidx.lifecycle:lifecycle-runtime:2.7.0 (DefaultLifecycleObserver) Manifest / config - uncomment the CarAppService <meta-data> + <service> block in AndroidManifest.xml; bump minCarApiLevel 5 -> 7 (required by ConversationItem @RequiresCarApi(7)) - automotive_app_desc.xml: add <uses name="media"/> for the new CarAppService media category; keep notification and template Code - HomeScreen: ensure Person always carries a key, which the 1.7.x ConversationItem.validateSender() requires. Applied locally to the senderBuilder.setName("") branch in buildCarMessage, matching the upstream intent without touching the surrounding code (NagramX has a richer DefaultLifecycleObserver + NotificationCenter pipeline than the upstream). - MusicPlayerService: after every mediaSession.setPlaybackState() and mediaSession.setMetadata(), also publish the same state / metadata to TelegramMediaSession so the MediaBrowserService is in sync with the phone player. On onDestroy, publish STATE_STOPPED if nothing is playing. Without this, the Android Auto media surface had no view of what the phone player was doing. - TelegramMediaSession.publishPlaybackState: merge getAvailableActions() (skip next/prev, set shuffle, etc.) into the state before publishing, so Android Auto renders the full action set. NagramX-specific context - NagramX already ships androidx.car.app:app:1.7.0 and app-projected:1.7.0; the dependency swap itself is a no-op in this repo - only the two missing transitive dependencies are added. - Final diff against dev: 6 files, 26 insertions(+), 13 deletions(-). Refs: DrKLO/Telegram#2008 risin42@ec956e39
…ar.app:1.7.0 Aligns the Android Auto code path with the androidx.car.app:app:1.7.0 contract. Combines the dependency bump and manifest pieces from DrKLO/Telegram#2008 with the MediaPlayerService/MediaSession integration that risin42 added in ec956e3 ("fix: Android Auto support", co-authored by rainman74). The AndroidX media-compat artifact androidx.media:media:1.7.0 keeps its classes under the legacy android.support.v4.media.* package for binary compatibility reasons - the import migration to androidx.media.* is NOT applied here (it would reference non-existent classes). Only the new transitive dependency is added; existing android.support.v4.media.* imports are left as-is. Build - bump androidx.car.app:app:1.4.0 -> 1.7.0 - drop androidx.car.app:app-projected:1.4.0 (NagramXF pre-1.7.0 used the projected variant; the 1.7.0 line no longer needs it as a separate dependency) - add androidx.media:media:1.7.0 (AndroidX media session) - add androidx.lifecycle:lifecycle-runtime:2.7.0 (DefaultLifecycleObserver) Manifest / config - uncomment the CarAppService <meta-data> + <service> block in AndroidManifest.xml; bump minCarApiLevel 5 -> 7 (required by ConversationItem @RequiresCarApi(7)) - automotive_app_desc.xml: add <uses name="media"/> for the new CarAppService media category; keep notification and template Code - HomeScreen: ensure Person always carries a key, which the 1.7.x ConversationItem.validateSender() requires. Applied locally to the senderBuilder.setName("") branch in buildCarMessage, matching the upstream intent without touching the surrounding code (NagramXF has a richer DefaultLifecycleObserver + NotificationCenter pipeline than the upstream). - MusicPlayerService: after every mediaSession.setPlaybackState() and mediaSession.setMetadata(), also publish the same state / metadata to TelegramMediaSession so the MediaBrowserService is in sync with the phone player. On onDestroy, publish STATE_STOPPED if nothing is playing. Without this, the Android Auto media surface had no view of what the phone player was doing. - TelegramMediaSession.publishPlaybackState: merge getAvailableActions() (skip next/prev, set shuffle, etc.) into the state before publishing, so Android Auto renders the full action set. NagramXF-specific context - NagramXF pre-1.7.0 pinned androidx.car.app:app:1.4.0 + app-projected:1.4.0; this PR bumps both lines to 1.7.0 (the app-projected artifact is no longer needed in the 1.7.0 line). - Final diff against dev: 6 files, 25 insertions(+), 11 deletions(-). Refs: DrKLO/Telegram#2008 risin42/NagramX@ec956e39
Updates the Android Auto code path to the androidx.car.app:app:1.7.0 contract. The bulk of this PR is the 1.7.0 contract alignment from DrKLO#2008; the MediaPlayerService / TelegramMediaSession integration is a follow-up added by risin42 in risin42/NagramX@ec956e3 ("fix: Android Auto support", co-authored by rainman74). The AndroidX media-compat artifact androidx.media:media:1.7.0 keeps its classes under the legacy android.support.v4.media.* package for binary compatibility reasons - the import migration to androidx.media.* is NOT applied here (it would reference non-existent classes). Only the new transitive dependency is added; existing android.support.v4.media.* imports are left as-is. Build - bump androidx.car.app:app:1.4.0 -> 1.7.0 - drop androidx.car.app:app-projected:1.4.0 (upstream pre-1.7.0 used the projected variant; the 1.7.0 line no longer needs it as a separate dependency) - add androidx.media:media:1.7.0 (AndroidX media session) - add androidx.lifecycle:lifecycle-runtime:2.7.0 (DefaultLifecycleObserver) Manifest / config - uncomment the CarAppService <meta-data> + <service> block in AndroidManifest.xml; bump minCarApiLevel 5 -> 7 (required by ConversationItem @RequiresCarApi(7)) - automotive_app_desc.xml: add <uses name="media"/> for the new CarAppService media category; keep notification and template Code - HomeScreen: ensure Person always carries a key, which the 1.7.x ConversationItem.validateSender() requires. Applied locally to the senderBuilder.setName("") branch in buildCarMessage, matching the upstream intent without touching the surrounding code. - MusicPlayerService: after every mediaSession.setPlaybackState() and mediaSession.setMetadata(), also publish the same state / metadata to TelegramMediaSession so the MediaBrowserService is in sync with the phone player. On onDestroy, publish STATE_STOPPED if nothing is playing. Without this, the Android Auto media surface had no view of what the phone player was doing. - TelegramMediaSession.publishPlaybackState: merge getAvailableActions() (skip next/prev, set shuffle, etc.) into the state before publishing, so Android Auto renders the full action set. Upstream-specific context - This PR adds the risin42/NagramX@ec956e3 MediaPlayerService / TelegramMediaSession integration on top of the original DrKLO#2008 contract alignment, so all three repos (upstream / NagramXF / NagramX) are in sync. The ec956e3 version of MusicPlayerService.java is NOT copied verbatim because DrKLO's upstream code has additional MIUI-specific lock-screen logic and an accountLogin handler that NagramX does not carry; the four targeted hunks (publishPlaybackState after each setPlaybackState, publishMetadata after setMetadata, and STATE_STOPPED cleanup in onDestroy) are applied on top of DrKLO's current file instead. - Final diff against master: 6 files, 23 insertions(+), 10 deletions(-). Refs: risin42/NagramX@ec956e3
3d36a93 to
145bd31
Compare
Apply upstream DrKLO#2008 Android Auto 1.7 migration
What
Aligns the Android Auto code path in
DrKLO/Telegramwith theandroidx.car.app:app:1.7.0contract, and adds theMusicPlayerService -> TelegramMediaSessionpublish hooks so that the CarApp / MediaBrowserService surface is in sync with the phone player.Why
The 1.7.x line of androidx.car.app tightened the contract that CarAppService implementations have to satisfy:
ConversationItem.validateSender()now requires everyPersonpassed in to have a non-null key. A missing key throws at runtime.androidx.media:1.7.0(for theandroid.support.v4.media.*compat shims) andandroidx.lifecycle:lifecycle-runtime:2.7.0(forDefaultLifecycleObserverused byHomeScreen).minCarApiLevelhas to be bumped from 5 to 7.The phone player's
MusicPlayerServicekeeps its ownMediaSessionCompat, but the CarApp / MediaBrowserService surface that Android Auto uses is backed byTelegramMediaSession. Without explicitly publishing playback state and metadata toTelegramMediaSession, the Android Auto side has no view of what the phone player is doing. The same goes forSTATE_STOPPEDon service teardown.How
6 files changed (+23/-10 vs
master):Build
TMessagesProj/build.gradle- bumpandroidx.car.app:app:1.4.0 -> 1.7.0; dropapp-projected:1.4.0; addandroidx.media:1.7.0andandroidx.lifecycle:lifecycle-runtime:2.7.0Manifest / config
TMessagesProj/src/main/AndroidManifest.xml- uncomment the CarApp<meta-data>+<service>block, bumpminCarApiLevel5 -> 7TMessagesProj/src/main/res/xml/automotive_app_desc.xml- add<uses name="media"/>Code
TMessagesProj/src/main/java/org/telegram/messenger/car/HomeScreen.java- thesenderBuilder.setName("")empty-fallback branch inbuildCarMessagenow also callssetKey("d" + dialogId), so everyPersonhanded to aConversationItemhas a key.TMessagesProj/src/main/java/org/telegram/messenger/MusicPlayerService.java- after everymediaSession.setPlaybackState()andmediaSession.setMetadata(), alsopublishPlaybackState()/publishMetadata()onTelegramMediaSession; ononDestroypublishSTATE_STOPPEDwhen nothing is playing.TMessagesProj/src/main/java/org/telegram/messenger/TelegramMediaSession.java-publishPlaybackStatenow mergesgetAvailableActions()into the state so Android Auto renders the full action set.Notes
androidx.media:1.7.0artifact keeps its classes under the legacyandroid.support.v4.media.*package for binary compatibility - no import migration needed.MusicPlayerService/TelegramMediaSessionchanges are applied as targeted hunks on top of upstreammaster, not as a verbatim file copy, because upstreammastercarries additional MIUI-specific lock-screen logic insupportLockScreenControlsand anaccountLoginhandler indidReceivedNotificationthat the NagramX-derived forks do not have. Only the contract-alignment hunks are taken; the rest of the upstream file is preserved as-is.accountLoginhandler inMusicPlayerService(which is the NagramX-specific quirk that is being removed there). If upstream later wants to follow the same removal, that should be a separate change with its own discussion.