Add legacy service preservation and feature flag toggle infrastructure#5145
Add legacy service preservation and feature flag toggle infrastructure#5145
Conversation
Generated by 🚫 Danger |
There was a problem hiding this comment.
Pull request overview
This PR is part of the Media3 migration, preserving the existing MediaBrowserServiceCompat playback service implementation under new “legacy” service classes and adding a feature-flag-based toggle to switch between legacy and Media3 service components at runtime.
Changes:
- Extracted legacy playback service logic into
LegacyPlaybackServiceand added an automotive-specificLegacyAutoPlaybackServicesubclass. - Added
PlaybackServiceToggleto enable/disable the appropriate service components based on theMEDIA3_SESSIONfeature flag. - Added a ProGuard keep rule intended to retain the legacy service during minification.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 5 comments.
| File | Description |
|---|---|
| proguard-rules.pro | Adds a keep rule for the new legacy playback service class. |
| modules/services/repositories/.../PlaybackServiceToggle.kt | Introduces runtime component enable/disable logic based on a feature flag. |
| modules/services/repositories/.../LegacyPlaybackService.kt | New legacy MediaBrowserServiceCompat implementation extracted from existing playback service logic. |
| automotive/.../LegacyAutoPlaybackService.kt | Automotive-specific legacy service subclass with refresh/pause behavior. |
You can also share your feedback on Copilot code review. Take the survey.
.../src/main/java/au/com/shiftyjelly/pocketcasts/repositories/playback/PlaybackServiceToggle.kt
Show resolved
Hide resolved
.../src/main/java/au/com/shiftyjelly/pocketcasts/repositories/playback/LegacyPlaybackService.kt
Show resolved
Hide resolved
.../src/main/java/au/com/shiftyjelly/pocketcasts/repositories/playback/LegacyPlaybackService.kt
Outdated
Show resolved
Hide resolved
.../src/main/java/au/com/shiftyjelly/pocketcasts/repositories/playback/PlaybackServiceToggle.kt
Show resolved
Hide resolved
automotive/src/main/java/au/com/shiftyjelly/pocketcasts/LegacyAutoPlaybackService.kt
Fixed
Show fixed
Hide fixed
.../src/main/java/au/com/shiftyjelly/pocketcasts/repositories/playback/LegacyPlaybackService.kt
Show resolved
Hide resolved
d85dfab to
4841ed3
Compare
7992866 to
08ef9b3
Compare
|
Version |
4841ed3 to
497b54c
Compare
08ef9b3 to
da8949c
Compare
There was a problem hiding this comment.
Pull request overview
This PR is part of the Media3 migration stack, extracting the existing PlaybackService (MediaBrowserServiceCompat) behavior into a preserved LegacyPlaybackService and adding a small utility to toggle which service component is enabled at runtime via the MEDIA3_SESSION feature flag.
Changes:
- Add
LegacyPlaybackService(legacy MediaBrowserServiceCompat implementation) and an automotive-specificLegacyAutoPlaybackServicesubclass. - Introduce
PlaybackServiceToggleto enable/disable service components based onFeature.MEDIA3_SESSION. - Add an R8/ProGuard keep rule for
LegacyPlaybackService.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| proguard-rules.pro | Adds a keep rule for the legacy playback service class. |
| modules/services/repositories/.../PlaybackServiceToggle.kt | Adds feature-flag-driven component enable/disable utility for swapping service implementations. |
| modules/services/repositories/.../LegacyPlaybackService.kt | Introduces preserved legacy playback service logic (notifications, browsing, sleep timer). |
| automotive/.../LegacyAutoPlaybackService.kt | Adds an automotive-specific legacy service subclass mirroring the existing automotive service behavior. |
.../src/main/java/au/com/shiftyjelly/pocketcasts/repositories/playback/LegacyPlaybackService.kt
Show resolved
Hide resolved
da8949c to
bc1dd94
Compare
f992988 to
376454a
Compare
bc1dd94 to
3327e0e
Compare
automotive/src/main/java/au/com/shiftyjelly/pocketcasts/LegacyAutoPlaybackService.kt
Show resolved
Hide resolved
376454a to
8eceb80
Compare
3327e0e to
09906b3
Compare
.../src/main/java/au/com/shiftyjelly/pocketcasts/repositories/playback/LegacyPlaybackService.kt
Outdated
Show resolved
Hide resolved
.../src/main/java/au/com/shiftyjelly/pocketcasts/repositories/playback/LegacyPlaybackService.kt
Show resolved
Hide resolved
automotive/src/main/java/au/com/shiftyjelly/pocketcasts/LegacyAutoPlaybackService.kt
Show resolved
Hide resolved
Project manifest changes for automotiveThe following changes in the --- ./build/reports/diff_manifest/automotive/release/base_manifest.txt 2026-04-08 09:38:56.585481713 +0000
+++ ./build/reports/diff_manifest/automotive/release/head_manifest.txt 2026-04-08 09:39:00.335504706 +0000
@@ -105,6 +105,16 @@
<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" />
+ </intent-filter>
+ </service>
<!-- services which are periodic or trigerred by the app automatically triggered, eg: can run in the background -->
<service
@@ -127,10 +137,10 @@
android:name="androidx.lifecycle.ProcessLifecycleInitializer"
android:value="androidx.startup" />
<meta-data
- android:name="okhttp3.internal.platform.PlatformInitializer"
+ android:name="androidx.profileinstaller.ProfileInstallerInitializer"
android:value="androidx.startup" />
<meta-data
- android:name="androidx.profileinstaller.ProfileInstallerInitializer"
+ android:name="okhttp3.internal.platform.PlatformInitializer"
android:value="androidx.startup" />
</provider>
@@ -433,21 +443,6 @@
<uses-library
android:name="androidx.window.sidecar"
android:required="false" />
- <uses-library
- android:name="android.ext.adservices"
- android:required="false" />
-
- <meta-data
- android:name="com.google.android.gms.version"
- android:value="@integer/google_play_services_version" />
-
- <service
- android:name="com.google.android.datatransport.runtime.backends.TransportBackendDiscovery"
- android:exported="false" >
- <meta-data
- android:name="backend:com.google.android.datatransport.cct.CctBackendFactory"
- android:value="cct" />
- </service>
<receiver
android:name="androidx.profileinstaller.ProfileInstallReceiver"
@@ -469,6 +464,21 @@
</intent-filter>
</receiver>
+ <uses-library
+ android:name="android.ext.adservices"
+ android:required="false" />
+
+ <meta-data
+ android:name="com.google.android.gms.version"
+ android:value="@integer/google_play_services_version" />
+
+ <service
+ android:name="com.google.android.datatransport.runtime.backends.TransportBackendDiscovery"
+ android:exported="false" >
+ <meta-data
+ android:name="backend:com.google.android.datatransport.cct.CctBackendFactory"
+ android:value="cct" />
+ </service>
<service
android:name="com.google.android.datatransport.runtime.scheduling.jobscheduling.JobInfoSchedulerService"
android:exported="false"Go to https://buildkite.com/automattic/pocket-casts-android/builds/16265/canvas?sid=019d6c6e-a5fc-4e9f-a34a-9bc631ed2672, click on the |
8eceb80 to
9c15b07
Compare
a03231c to
b3edfd8
Compare
...n/java/au/com/shiftyjelly/pocketcasts/repositories/playback/auto/MediaItemCompatConverter.kt
Show resolved
Hide resolved
.../src/main/java/au/com/shiftyjelly/pocketcasts/repositories/playback/LegacyPlaybackService.kt
Show resolved
Hide resolved
...ries/src/main/java/au/com/shiftyjelly/pocketcasts/repositories/playback/SleepTimerHandler.kt
Show resolved
Hide resolved
...es/src/main/java/au/com/shiftyjelly/pocketcasts/repositories/playback/MediaSessionActions.kt
Show resolved
Hide resolved
...es/src/main/java/au/com/shiftyjelly/pocketcasts/repositories/playback/MediaSessionActions.kt
Show resolved
Hide resolved
...rc/test/java/au/com/shiftyjelly/pocketcasts/repositories/playback/MediaSessionActionsTest.kt
Show resolved
Hide resolved
Add SupervisorJob to LegacyPlaybackService coroutine context and cancel it in onDestroy() so coroutines are properly cleaned up. Fix misleading proguard comment to match the actual rule behavior. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
The class was introduced in this branch but the manifest entry was deferred to 06d, causing lint to fail on branches 05 through 06c. Register it now with android:enabled="false" — PlaybackServiceToggle enables the correct service at runtime. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
97409db to
2182d09
Compare
|
recheck |
Description
This is the 5th step of the media3 migration. This PR preserves the existing PlaybackService logic by extracting it into
LegacyPlaybackService(a MediaBrowserServiceCompat) and its thin LegacyAutoPlaybackService subclass, so the old service can continue to run alongside the new Media3 implementation. A PlaybackServiceToggle utility was added to resolve the correct service class based on theMEDIA3_SESSIONfeature flag, enabling a safe runtime switch between legacy and Media3 paths.A ProGuard keep rule was also added to ensure the legacy service class isn't stripped during minification.
Testing Instructions
Just review the code since the new components are not wired up yet
Checklist
./gradlew spotlessApplyto automatically apply formatting/linting)modules/services/localization/src/main/res/values/strings.xml