Skip to content

feat(android): exclude SDK state from Auto Backup via config plugin#4

Merged
jaymaycry merged 1 commit into
mainfrom
feat/android-backup-rules
Jun 2, 2026
Merged

feat(android): exclude SDK state from Auto Backup via config plugin#4
jaymaycry merged 1 commit into
mainfrom
feat/android-backup-rules

Conversation

@jaymaycry

Copy link
Copy Markdown
Contributor

Why

The MotionTag Android guide requires excluding the SDK's SharedPreferences file from Android Auto Backup — a backup restored on reinstall or device transfer would otherwise resurrect stale SDK state (device registration, tracking state) and confuse the backend.

The prefs file name motiontag_tracker.xml was verified against the de.motiontag:tracker:7.2.5 AAR (getSharedPreferences("motiontag_tracker", ...)).

What

New plugin/withAndroidBackupRules.js, registered in the config plugin chain. It runs as a finalized mod so it sees backup rules set by any other plugin regardless of app.json plugin ordering:

Host state Behavior
No backup rules Creates MotionTag-owned exclude-only rule files + manifest references
Existing rules (e.g. expo-secure-store) Merges the exclude into an app-level resource override with the same name — the manifest reference and the other plugin's idempotency check stay untouched
allowBackup="false" Skips (no stale-state risk)
Rules it cannot edit (e.g. literal values, missing files) Warns with manual instructions

Both rule formats are covered: full-backup-content (Android ≤ 11) and data-extraction-rules cloud-backup + device-transfer (Android 12+).

Also documents the manual exclusion for bare-RN hosts in the README.

Verification

Against the example app (which uses expo-secure-store):

  • Merge case: MotionTag exclude added alongside SecureStore's in both formats, no plugin warnings
  • Standalone case (secure-store temporarily removed): MotionTag-owned rule files created + referenced from manifest
  • Idempotency: re-running expo prebuild (with and without --clean) produces no duplicate excludes

🤖 Generated with Claude Code

The MotionTag Android guide requires excluding the SDK's SharedPreferences
file (motiontag_tracker.xml, verified against the tracker AAR) from Android
Auto Backup — a backup restored on reinstall or device transfer would
otherwise resurrect stale SDK state.

The new withAndroidBackupRules plugin runs as a finalized mod so it sees
backup rules set by any other plugin regardless of app.json ordering:

- no existing rules: creates MotionTag-owned exclude-only rule files and
  references them from the manifest
- existing rules (e.g. expo-secure-store): merges the exclude into an
  app-level resource override with the same name, leaving the manifest
  reference (and the other plugin's idempotency check) untouched
- allowBackup="false" or rules it cannot edit: skips, warning with manual
  instructions in the latter case

Both rule formats are covered: full-backup-content (Android <= 11) and
data-extraction-rules cloud-backup + device-transfer (Android 12+).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@jaymaycry jaymaycry force-pushed the feat/android-backup-rules branch from 1d649c2 to 171be3c Compare June 2, 2026 16:59
@jaymaycry jaymaycry merged commit 70ce1ff into main Jun 2, 2026
1 check passed
@github-actions github-actions Bot mentioned this pull request Jun 2, 2026
@jaymaycry jaymaycry deleted the feat/android-backup-rules branch June 2, 2026 17:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant