Wire automotive and wear platforms for Media3 service toggle#5151
Wire automotive and wear platforms for Media3 service toggle#5151sztomek wants to merge 4 commits intomedia3/06c-mobile-integrationfrom
Conversation
There was a problem hiding this comment.
Pull request overview
This PR wires the Wear OS and Automotive apps into the existing PlaybackServiceToggle mechanism so the correct playback service implementation (Media3 vs legacy) is enabled based on the media3_session feature flag.
Changes:
- Invoke
PlaybackServiceToggle.ensureCorrectServiceEnabled(...)during app startup for Wear and Automotive. - Update Wear and Automotive manifests to declare Media3/legacy playback services with appropriate enabled states and intent-filters.
- Remove the existing Automotive
AutoPlaybackServiceTestinstrumentation test.
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| wear/src/main/kotlin/au/com/shiftyjelly/pocketcasts/wear/PocketCastsWearApplication.kt | Enables the correct playback service at Wear app startup via PlaybackServiceToggle. |
| wear/src/main/AndroidManifest.xml | Declares Media3 + legacy playback services for Wear with both initially disabled for runtime toggling. |
| automotive/src/main/java/au/com/shiftyjelly/pocketcasts/AutomotiveApplication.kt | Enables the correct Automotive playback service pair at startup via PlaybackServiceToggle using AAOS-specific service class names. |
| automotive/src/main/AndroidManifest.xml | Adds foreground-service permissions and declares Media3 + legacy Automotive services with one enabled for AAOS discovery. |
| automotive/src/androidTest/java/au/com/shiftyjelly/pocketcasts/AutoPlaybackServiceTest.kt | Removes the Automotive service instrumentation test. |
You can also share your feedback on Copilot code review. Take the survey.
wear/src/main/kotlin/au/com/shiftyjelly/pocketcasts/wear/PocketCastsWearApplication.kt
Show resolved
Hide resolved
automotive/src/main/java/au/com/shiftyjelly/pocketcasts/AutomotiveApplication.kt
Outdated
Show resolved
Hide resolved
automotive/src/main/java/au/com/shiftyjelly/pocketcasts/AutomotiveApplication.kt
Outdated
Show resolved
Hide resolved
Project manifest changes for wearThe following changes in the --- ./build/reports/diff_manifest/wear/release/base_manifest.txt 2026-04-02 15:30:57.501273782 +0000
+++ ./build/reports/diff_manifest/wear/release/head_manifest.txt 2026-04-02 15:31:03.101328105 +0000
@@ -126,8 +126,21 @@
</intent-filter>
</activity>
+ <!-- Both services start disabled; PlaybackServiceToggle enables the correct one. -->
<service
android:name="au.com.shiftyjelly.pocketcasts.repositories.playback.PlaybackService"
+ android:enabled="false"
+ android:exported="true"
+ android:foregroundServiceType="mediaPlayback"
+ android:label="@string/app_name" >
+ <intent-filter>
+ <action android:name="android.media.browse.MediaBrowserService" />
+ <action android:name="androidx.media3.session.MediaLibraryService" />
+ </intent-filter>
+ </service>
+ <service
+ android:name="au.com.shiftyjelly.pocketcasts.repositories.playback.LegacyPlaybackService"
+ android:enabled="false"
android:exported="true"
android:foregroundServiceType="mediaPlayback"
android:label="@string/app_name" >Go to https://buildkite.com/automattic/pocket-casts-android/builds/16232/canvas?sid=019d4ec7-db9d-4371-8b95-2db5c116ecfc, click on the |
Project manifest changes for automotiveThe following changes in the --- ./build/reports/diff_manifest/automotive/release/base_manifest.txt 2026-04-02 15:31:31.041596140 +0000
+++ ./build/reports/diff_manifest/automotive/release/head_manifest.txt 2026-04-02 15:31:37.101653077 +0000
@@ -24,6 +24,8 @@
android:name="android.hardware.camera"
android:required="false" />
+ <uses-permission android:name="android.permission.FOREGROUND_SERVICE" />
+ <uses-permission android:name="android.permission.FOREGROUND_SERVICE_MEDIA_PLAYBACK" />
<uses-permission android:name="android.permission.DETECT_SCREEN_CAPTURE" />
<queries>
@@ -54,8 +56,7 @@
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.POST_NOTIFICATIONS" />
<uses-permission android:name="android.permission.INTERNET" />
- <uses-permission android:name="android.permission.WAKE_LOCK" /> <!-- This permission is required to start foreground services in Android P. -->
- <uses-permission android:name="android.permission.FOREGROUND_SERVICE" />
+ <uses-permission android:name="android.permission.WAKE_LOCK" />
<uses-permission android:name="android.permission.USE_BIOMETRIC" /> <!-- suppress DeprecatedClassUsageInspection -->
<uses-permission android:name="android.permission.USE_FINGERPRINT" />
<uses-permission android:name="com.android.vending.BILLING" />
@@ -98,21 +99,13 @@
<service
android:name="au.com.shiftyjelly.pocketcasts.AutoPlaybackService"
+ android:enabled="true"
android:exported="true"
android:foregroundServiceType="mediaPlayback"
android:label="@string/app_name" >
<intent-filter>
<action android:name="android.media.browse.MediaBrowserService" />
- </intent-filter>
- </service>
- <service
- android:name="au.com.shiftyjelly.pocketcasts.LegacyAutoPlaybackService"
- android:enabled="false"
- android:exported="true"
- android:foregroundServiceType="mediaPlayback"
- android:label="@string/app_name" >
- <intent-filter>
- <action android:name="android.media.browse.MediaBrowserService" />
+ <action android:name="androidx.media3.session.MediaLibraryService" />
</intent-filter>
</service>
Go to https://buildkite.com/automattic/pocket-casts-android/builds/16232/canvas?sid=019d4ec7-db9d-4371-8b95-2db5c116ecfc, click on the |
5d39e63 to
b38132f
Compare
There was a problem hiding this comment.
Pull request overview
Wires Wear OS and Automotive variants into the existing Media3/Legacy playback service toggle so the correct media browser service is enabled based on the MEDIA3_SESSION feature flag.
Changes:
- Wear OS: enable runtime toggling by invoking
PlaybackServiceToggle.ensureCorrectServiceEnabled()during app startup and declaring both playback services disabled-by-default in the manifest. - Automotive: initialize feature-flag providers on startup and toggle between
AutoPlaybackService(Media3) andLegacyAutoPlaybackService(legacy) viaPlaybackServiceToggle. - Cleanup: remove stray whitespace and delete an Automotive instrumentation test.
Reviewed changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| wear/src/main/kotlin/au/com/shiftyjelly/pocketcasts/wear/PocketCastsWearApplication.kt | Calls PlaybackServiceToggle during Wear app initialization. |
| wear/src/main/AndroidManifest.xml | Declares Media3 + legacy playback services (disabled by default) for runtime enabling. |
| modules/services/repositories/src/main/java/au/com/shiftyjelly/pocketcasts/repositories/playback/MediaSessionManager.kt | Whitespace cleanup only. |
| modules/services/repositories/src/main/java/au/com/shiftyjelly/pocketcasts/repositories/playback/LegacyPlaybackService.kt | Whitespace cleanup only. |
| automotive/src/main/java/au/com/shiftyjelly/pocketcasts/AutomotiveApplication.kt | Adds feature-flag initialization and toggles the correct Automotive playback service at startup. |
| automotive/src/main/AndroidManifest.xml | Adds foreground-service permissions and declares both Automotive playback services with appropriate enabled defaults. |
| automotive/src/androidTest/java/au/com/shiftyjelly/pocketcasts/AutoPlaybackServiceTest.kt | Removes Automotive instrumentation test coverage for the media browse tree. |
Comments suppressed due to low confidence (1)
automotive/src/androidTest/java/au/com/shiftyjelly/pocketcasts/AutoPlaybackServiceTest.kt:1
- This PR removes the only Automotive instrumentation test coverage for the media browse tree (tabs/root + discover/filters/podcasts/episodes). Since this PR also changes which playback service is enabled at runtime, it would be good to keep at least one test that validates the Automotive service still exposes the expected browse roots (either by reworking this test for the new service setup or by adding equivalent unit/Robolectric coverage around the Automotive browse-root behavior).
42a46be to
f96355f
Compare
b38132f to
965893a
Compare
|
Version |
f96355f to
7f72738
Compare
965893a to
7646499
Compare
automotive/src/main/java/au/com/shiftyjelly/pocketcasts/AutomotiveApplication.kt
Outdated
Show resolved
Hide resolved
automotive/src/main/java/au/com/shiftyjelly/pocketcasts/AutomotiveApplication.kt
Show resolved
Hide resolved
7f72738 to
713ec73
Compare
7646499 to
3124484
Compare
713ec73 to
a382432
Compare
3124484 to
39c3d91
Compare
app/src/main/java/au/com/shiftyjelly/pocketcasts/PocketCastsApplication.kt
Show resolved
Hide resolved
a382432 to
f18a518
Compare
39c3d91 to
50814f2
Compare
f18a518 to
8e47b50
Compare
50814f2 to
8cc1208
Compare
Description
Last piece of the puzzle. Wear and Automotive integration.
Fixes #
Testing Instructions
Test the apps on both platforms with
media3_sessionon and off. you'll need to manually change the flag in code and build the apps.Caveat: on automotive i found it very troublesome to test the app. However these steps was quite usable for me:
adb uninstall au.com.shiftyjelly.pocketcasts.debugadb reboot./gradlew :automotive:installDebugChecklist
./gradlew spotlessApplyto automatically apply formatting/linting)modules/services/localization/src/main/res/values/strings.xml