Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
([#6196](https://github.com/Automattic/pocket-casts-android/pull/6196))
* Keep the TV from going into standby while an episode is playing in the TV app
([#6199](https://github.com/Automattic/pocket-casts-android/pull/6199))
* Fix playback stopping early when Android backs up the app in the background on Android 16 and newer
([#6205](https://github.com/Automattic/pocket-casts-android/pull/6205))
* Dismiss the Smart Bookmarks tooltip when the More button is tapped
([#6206](https://github.com/Automattic/pocket-casts-android/pull/6206))

Expand Down
8 changes: 7 additions & 1 deletion app/src/release/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,11 @@
tools:replace="android:allowBackup,android:fullBackupContent,android:dataExtractionRules"
android:allowBackup="true"
android:fullBackupContent="@xml/backup_scheme"
android:dataExtractionRules="@xml/extraction_rules"/>
android:dataExtractionRules="@xml/extraction_rules">

<!-- Stops Android 16+ killing the app (and interrupting playback) after a full backup -->
<property
android:name="android.app.backup.PROPERTY_USE_RESTRICTED_BACKUP_MODE"
Comment on lines +11 to +13

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

On Android 16+, a user restoring to a new phone can end up with their restored podcasts and settings overwritten or reset, because restore now runs inside the full app process.

This property turns off restricted mode for restore as well as backup. That means PocketCastsApplication.onCreate runs first: Hilt init, Room opening and migrating pocketcasts, and Settings loading au.com.shiftyjelly.pocketcasts_preferences.xml into the SharedPreferences cache. Then the transport replaces those files underneath it. Because the process is no longer killed on unbind (the shouldKillAppOnUnbind path you cite), it keeps running with an open Room connection to the old file and a stale prefs cache. The next apply() writes the pre-restore prefs back over the restored file, and DB writes go to the replaced inode. Step 6 of the test plan probably won't catch this, because the restore usually runs before anything in the app touches prefs or the DB.

Fix: keep the backup benefit but make restore safe. Add a minimal android:backupAgent with android:fullBackupOnly="true" (it stays a full backup with the same rules) and end the process in onRestoreFinished() (exitProcess(0)) so the next launch reads the restored files. Then test restore with the app already running, e.g. bmgr restore <token> au.com.shiftyjelly.pocketcasts while it's in the foreground.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I completed the restore successfully in my testing, and everything worked as expected.

android:value="false" />
</application>
</manifest>
Loading