From c635ccd586913dc9055aab535526ab4b19b2bb8b Mon Sep 17 00:00:00 2001 From: Linus Rath <139418639+rathlinus@users.noreply.github.com> Date: Sun, 27 Sep 2026 07:49:53 +0200 Subject: [PATCH] fix: open the account's sync page from the sync settings #34 "Android account settings" opened Android's page for the Bulwark account through `ACCOUNT_SYNC_SETTINGS` with the account as the `account` extra. The Settings app of Android 12L and later passes only `:settings:show_fragment_args` on to that page, which then found no account and closed at once ("Account provided does not exist: null"). Since starting it succeeded, the fallback to the list of synced accounts never ran, and the button seemed to do nothing. The account now also goes in the fragment arguments, where those Settings apps read it; older ones still read the plain extra. Checked on the API 32 and API 34 emulators: the button opens the account's "Account sync" page with its Contacts and Calendar switches. --- .../bulwarkmobile/sync/BulwarkDeviceSyncModule.kt | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/android/app/src/main/java/com/anonymous/bulwarkmobile/sync/BulwarkDeviceSyncModule.kt b/android/app/src/main/java/com/anonymous/bulwarkmobile/sync/BulwarkDeviceSyncModule.kt index 34b95d3f..230141db 100644 --- a/android/app/src/main/java/com/anonymous/bulwarkmobile/sync/BulwarkDeviceSyncModule.kt +++ b/android/app/src/main/java/com/anonymous/bulwarkmobile/sync/BulwarkDeviceSyncModule.kt @@ -7,6 +7,7 @@ import android.content.ActivityNotFoundException import android.content.ContentResolver import android.content.Intent import android.os.Build +import android.os.Bundle import android.os.Handler import android.os.Looper import android.provider.Settings @@ -162,7 +163,12 @@ class BulwarkDeviceSyncModule(reactContext: ReactApplicationContext) : @ReactMethod fun openAccountSettings(name: String, promise: Promise) = settle(promise) { val account = DeviceSyncAccounts.account(reactApplicationContext, name) - val perAccount = Intent(ACTION_ACCOUNT_SYNC_SETTINGS).putExtra(EXTRA_ACCOUNT, account) + val perAccount = Intent(ACTION_ACCOUNT_SYNC_SETTINGS) + .putExtra(EXTRA_ACCOUNT, account) + // Newer Settings apps pass only these arguments on to the account's + // screen; without them it closes at once ("Account provided does + // not exist: null", Android 12L), and no exception tells us so. + .putExtra(EXTRA_SHOW_FRAGMENT_ARGUMENTS, Bundle().apply { putParcelable(EXTRA_ACCOUNT, account) }) val overview = Intent(Settings.ACTION_SYNC_SETTINGS) .putExtra(Settings.EXTRA_ACCOUNT_TYPES, arrayOf(account.type)) val activity = reactApplicationContext.currentActivity @@ -309,6 +315,8 @@ class BulwarkDeviceSyncModule(reactContext: ReactApplicationContext) : /** Settings' per-account sync screen; public on AOSP-based settings apps, but not in the SDK. */ private const val ACTION_ACCOUNT_SYNC_SETTINGS = "android.settings.ACCOUNT_SYNC_SETTINGS" private const val EXTRA_ACCOUNT = "account" + /** SettingsActivity.EXTRA_SHOW_FRAGMENT_ARGUMENTS: the arguments of the screen it shows. */ + private const val EXTRA_SHOW_FRAGMENT_ARGUMENTS = ":settings:show_fragment_args" @Volatile private var currentInstance: BulwarkDeviceSyncModule? = null