Skip to content

Add persistent storage module#7877

Open
CDRussell wants to merge 1 commit intodevelopfrom
feature/craig/sync-auto-recovery-persistent-storage
Open

Add persistent storage module#7877
CDRussell wants to merge 1 commit intodevelopfrom
feature/craig/sync-auto-recovery-persistent-storage

Conversation

@CDRussell
Copy link
Member

@CDRussell CDRussell commented Mar 5, 2026

Task/Issue URL: https://app.asana.com/1/137249556945/project/488551667048375/task/1211766481496469?focus=true

Description

Implements the persistent-storage module to be a reusable, key-based abstraction over Google Play Block Store.

Changes since the previous placeholder approach in a lower branch

  • New PersistentStorageKey base class — modules define their own keys with a key string and shouldBackupToCloud flag
  • Operations are now store/retrieve/clear with ByteArray values and Result return types
  • Availability model simplified to Available(isEndToEndEncryptionSupported) and Unavailable (removed BuildTypeUnsupported and split encrypted/unencrypted variants)

Implementation changes:

  • Extracted BlockStoreWrapper to isolate Block Store API calls behind a testable interface
  • DummyPersistentStorage (F-Droid) returns Unavailable / Result.failure with logcat for debugging

Observer changes:

  • SyncAutoRecoveryCapabilityObserver now early-returns on F-Droid builds via AppBuildConfig.flavor check (instead of relying on BuildTypeUnsupported availability)

Steps to test this PR

Internal/Play build on emulator with Play Services

  1. Install: ./gradlew installInternalDebug
  2. Launch app, wait ~15s for privacy config download
  3. Filter logcat: message~:"Block Store|Sync-Recovery"
  4. Verify logs show:
    • Sync-Recovery: capability detection enabled (write=true, read=true)
    • Block Store: available, E2E encryption supported = true
    • Sync-Recovery: persistent storage available with E2E encryption
    • Sync-Recovery: attempting to read from persistent storage...
    • Sync-Recovery: read success
    • Sync-Recovery: attempting to write to persistent storage...
    • Block Store: stored com.duckduckgo.sync.derisk.test (N bytes)
    • Sync-Recovery: write success

Second launch (verifies cross-session persistence)
5. Force-stop and relaunch the app
6. Verify read returns previous session's value: read success (value=N chars)

Internal/Play build on device without Play Services (e.g., AOSP emulator)
7. Install: ./gradlew installInternalDebug on an emulator without GMS
8. Launch app, wait ~15s for privacy config download
9. Filter logcat: message~:"Block Store|Sync-Recovery"
10. Verify logs show:
- Sync-Recovery: capability detection enabled (write=true, read=true)
- Block Store: Play Services not available
- Sync-Recovery: persistent storage unavailable
11. Verify no read/write attempts — observer exits after unavailable pixel

F-Droid build (validates no-crash on builds without Play Services)
12. Apply patch to enable fdroidDebug variant (comment out variantFilter in app/build.gradle)
13. Install: ./gradlew installFdroidDebug
14. Launch app — verify no crash
15. Filter logcat: message~:"Block Store|Sync-Recovery" — verify no logs (observer early-returns before touching Block Store)
16. Re-enable variant filter after testing

diff --git a/app/build.gradle b/app/build.gradle
index abc1234..def5678 100644
--- a/app/build.gradle
+++ b/app/build.gradle
@@ -179,7 +179,7 @@
-    variantFilter { variant ->
-        def names = variant.flavors*.name
-        if (names.contains("fdroid") && variant.buildType.name == "debug") {
-            // We don't need fdroidDebug build type
-            setIgnore(true)
-        }
-    }
+    // variantFilter { variant ->
+    //     def names = variant.flavors*.name
+    //     if (names.contains("fdroid") && variant.buildType.name == "debug") {
+    //         // We don't need fdroidDebug build type
+    //         setIgnore(true)
+    //     }
+    // }

Copy link
Member Author

This stack of pull requests is managed by Graphite. Learn more about stacking.

@CDRussell CDRussell force-pushed the feature/craig/sync-auto-recovery-persistent-storage branch from 6ee45c1 to bd65ea2 Compare March 5, 2026 12:50
@CDRussell CDRussell force-pushed the feature/craig/sync-auto-recovery-persistent-storage branch from bd65ea2 to c6b0d1b Compare March 5, 2026 12:54
@CDRussell CDRussell marked this pull request as ready for review March 5, 2026 12:56
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.

2 participants