"Allow apps to find accounts" has no effect on accounts added before it was enabled
- Dominant language
- Java
- Stars
- 14.6k
- Forks
- 3.2k
- PR merge metrics
- PR metrics pending
Description
The "Allow apps to find accounts" toggle (Legacy Settings, key `auth_manager_visible`)
only takes effect for accounts added after it was switched on. Turning it on later does
nothing to accounts that already exist, and nothing in the UI says so. This affects any
app that enumerates accounts with `getAccountsByType()` rather than going straight to
`getAuthToken()` — Viber and WhatsApp are the ones people keep reporting, but it is not
app-specific.
The visibility row lives in `/data/system_de/0/accounts_de.db`, table `visibility`, as
`android:accounts:key_legacy_not_visible`. Without it an app that holds neither
`GET_ACCOUNTS_PRIVILEGED` nor the authenticator signature gets an empty list back. In the
current tree `setAccountVisibility` is written in exactly one place, `LoginActivity.java`
(lines 186 and 441), guarded by `isAuthVisible`:
```java
if (isAuthVisible(this) && SDK_INT >= 26) {
accountManager.setAccountVisibility(account, PACKAGE_NAME_KEY_LEGACY_NOT_VISIBLE,
VISIBILITY_USER_MANAGED_VISIBLE);
}
```
The toggle itself is handled in `AccountsFragment.onCreatePreferences`, where the listener
persists the value and refreshes the UI, with follow-up actions for two other settings:
```kotlin
SettingsContract.setSettings(requireContext(), Auth.getContentUri(requireContext())) { put(preference.key, newValue) }
updateSettings()
if (preference.key == Auth.TWO_STEP_VERIFICATION && newValue) registerGcmInGms()
if (preference.key == Auth.FIND_DEVICES && newValue) registerGcmInGms()
```
`Auth.VISIBLE` has no such branch, so enabling it never reaches `setAccountVisibility`.
I confirmed that on device by toggling it off and on and re-reading the table: no write
happened.
To reproduce, add a Google account through microG with the toggle off, then enable the
toggle, then open any app that lists accounts — WhatsApp chat backup or Viber backup will
still show no account. Reading the table shows the missing row:
```
adb shell "sqlite3 /data/system_de/0/accounts_de.db \
\"SELECT _package, value FROM visibility WHERE _package LIKE 'android:%';\""
```
This is the mechanism behind the workaround people have been passing around in #1988 since
2024 — enable the toggle, then remove the Google account and add it back. That works
because re-adding is the only moment the row gets written. It has been independently
confirmed there by several users on CalyxOS and /e/OS, and the same root cause fits #2398
and #2244.
A fix would be to apply the setting when it is switched on, in the same place the other
two settings get their follow-up: iterate the existing `com.google` accounts and call
`setAccountVisibility(account, PACKAGE_NAME_KEY_LEGACY_NOT_VISIBLE, VISIBILITY_USER_MANAGED_VISIBLE)`.
Clearing it again when the toggle is switched off would keep the two directions symmetric.
Tested on LineageOS 23.2 for microG (Android 16), microG GmsCore 0.3.16.252432, on a
Redmi Note 10 Pro. The code references above are from current master.
Contributor guide
No contributing guide indexed for this repository
Research direction
Start in AccountsFragment.onCreatePreferences, where Auth.VISIBLE is persisted and the other settings trigger follow-up actions, then inspect setAccountVisibility in LoginActivity.java at lines 186 and 441. Reproduce with an existing account and inspect accounts_de.db; done means enabling and disabling the toggle updates visibility for existing com.google accounts without requiring removal and re-addition.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- android, java, kotlin
- Domain
- authentication, mobile
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Active
- Clarity
- Clearly specified
- Newbie friendliness
- 76/100