Skip to content

Wire automotive and wear platforms for Media3 service toggle#5151

Open
sztomek wants to merge 4 commits intomedia3/06c-mobile-integrationfrom
media3/06d-automotive-wear-integration
Open

Wire automotive and wear platforms for Media3 service toggle#5151
sztomek wants to merge 4 commits intomedia3/06c-mobile-integrationfrom
media3/06d-automotive-wear-integration

Conversation

@sztomek
Copy link
Copy Markdown
Contributor

@sztomek sztomek commented Mar 19, 2026

Description

Last piece of the puzzle. Wear and Automotive integration.

Fixes #

Testing Instructions

Test the apps on both platforms with media3_session on 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.debug
adb reboot
./gradlew :automotive:installDebug

Checklist

  • If this is a user-facing change, I have added an entry in CHANGELOG.md
  • Ensure the linter passes (./gradlew spotlessApply to automatically apply formatting/linting)
  • I have considered whether it makes sense to add tests for my changes
  • All strings that need to be localized are in modules/services/localization/src/main/res/values/strings.xml
  • Any jetpack compose components I added or changed are covered by compose previews
  • I have updated (or requested that someone edit) the spreadsheet to reflect any new or changed analytics.

@sztomek sztomek added this to the 8.10 milestone Mar 19, 2026
@sztomek sztomek requested a review from a team as a code owner March 19, 2026 15:52
@sztomek sztomek added the [Type] Enhancement Improve an existing feature. label Mar 19, 2026
@sztomek sztomek requested review from MiSikora and removed request for a team March 19, 2026 15:52
@sztomek sztomek added the [Area] Playback Episode playback issue label Mar 19, 2026
Copilot AI review requested due to automatic review settings March 19, 2026 15:52
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 AutoPlaybackServiceTest instrumentation 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.

@wpmobilebot
Copy link
Copy Markdown
Collaborator

wpmobilebot commented Mar 19, 2026

Project manifest changes for wear

The following changes in the wear's merged AndroidManifest.xml file were detected (build variant: release):

--- ./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 Artifacts tab and audit the files.

@wpmobilebot
Copy link
Copy Markdown
Collaborator

wpmobilebot commented Mar 19, 2026

Project manifest changes for automotive

The following changes in the automotive's merged AndroidManifest.xml file were detected (build variant: release):

--- ./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 Artifacts tab and audit the files.

@sztomek sztomek modified the milestones: 8.10, 8.9 Mar 20, 2026
Copilot AI review requested due to automatic review settings March 23, 2026 15:58
@sztomek sztomek force-pushed the media3/06d-automotive-wear-integration branch from 5d39e63 to b38132f Compare March 23, 2026 15:58
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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) and LegacyAutoPlaybackService (legacy) via PlaybackServiceToggle.
  • 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).

@sztomek sztomek force-pushed the media3/06c-mobile-integration branch from 42a46be to f96355f Compare March 27, 2026 16:17
@sztomek sztomek force-pushed the media3/06d-automotive-wear-integration branch from b38132f to 965893a Compare March 27, 2026 16:19
@wpmobilebot wpmobilebot modified the milestones: 8.9, 8.10 Mar 30, 2026
@wpmobilebot
Copy link
Copy Markdown
Collaborator

Version 8.9 has now entered code-freeze, so the milestone of this PR has been updated to 8.10.

@sztomek sztomek force-pushed the media3/06c-mobile-integration branch from f96355f to 7f72738 Compare April 1, 2026 18:12
Copilot AI review requested due to automatic review settings April 1, 2026 18:14
@sztomek sztomek force-pushed the media3/06d-automotive-wear-integration branch from 965893a to 7646499 Compare April 1, 2026 18:14
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 5 out of 5 changed files in this pull request and generated 2 comments.

@sztomek sztomek force-pushed the media3/06c-mobile-integration branch from 7f72738 to 713ec73 Compare April 1, 2026 20:38
@sztomek sztomek force-pushed the media3/06d-automotive-wear-integration branch from 7646499 to 3124484 Compare April 1, 2026 20:40
@sztomek sztomek force-pushed the media3/06c-mobile-integration branch from 713ec73 to a382432 Compare April 2, 2026 10:57
Copilot AI review requested due to automatic review settings April 2, 2026 10:58
@sztomek sztomek force-pushed the media3/06d-automotive-wear-integration branch from 3124484 to 39c3d91 Compare April 2, 2026 10:58
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 5 out of 5 changed files in this pull request and generated 1 comment.

@sztomek sztomek force-pushed the media3/06c-mobile-integration branch from a382432 to f18a518 Compare April 2, 2026 11:18
@sztomek sztomek force-pushed the media3/06d-automotive-wear-integration branch from 39c3d91 to 50814f2 Compare April 2, 2026 11:19
@sztomek sztomek force-pushed the media3/06c-mobile-integration branch from f18a518 to 8e47b50 Compare April 2, 2026 11:31
@sztomek sztomek force-pushed the media3/06d-automotive-wear-integration branch from 50814f2 to 8cc1208 Compare April 2, 2026 11:32
Copilot AI review requested due to automatic review settings April 2, 2026 11:32
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 5 out of 5 changed files in this pull request and generated no new comments.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

[Area] Playback Episode playback issue [Type] Enhancement Improve an existing feature.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants