CVE-2026-0053 AI-generated analysis
platform/packages/apps/Nfc (NfcService Secure NFC setting) and platform/packages/apps/Settings (nfc/SecureNfcEnabler, nfc/SecureNfcPreferenceController)
Makes the Secure NFC on/off preference per-user in NfcService (per-user SharedPreferences key, reload on user switch and on query when the current user changed) and reworks the Settings toggle so non-primary users control their own setting while guest users cannot toggle it.
Root cause
NfcService stored the Secure NFC setting under one global SharedPreferences key (PREF_SECURE_NFC_ON) and one in-memory field (mIsSecureNfcEnabled). The value was read once in the constructor and written by setNfcSecure. Nothing in the service tied the value to a user, so a change made while any user was active replaced the setting for every user. The Settings app disabled the toggle for non-primary users (isPrimaryUser-based isToggleable checks in SecureNfcEnabler and SecureNfcPreferenceController). That was a UI restriction, not enforcement in the service. The commit message says the per-user change "prevents one user from changing another user's security settings."
How the fix works
- Nfc 09d6111fa3b4, src/com/android/nfc/NfcService.java: adds getSecureNfcPreferenceKeyForUser(int userId), which returns PREF_SECURE_NFC_ON + "_" + userId. Also adds loadSecureNfcSettings(int userId), which reads the per-user key (default SECURE_NFC_ON_DEFAULT), ANDs it with mIsSecureNfcCapable, stores the result in mIsSecureNfcEnabled and pushes it to mDeviceHost.setNfcSecure.
- Nfc 09d6111fa3b4, NfcService constructor: mIsSecureNfcCapable now requires mIsHceCapable as well as mNfcAdapter.deviceSupportsNfcSecure(). The initial mIsSecureNfcEnabled is read from the per-user key for mUserId instead of the global key.
- Nfc 09d6111fa3b4, setNfcSecure: saves the new value under the key for getUserId() instead of the global key. The rest of the method (admin permission check, keyguard check, same-state check, mBackupManager.dataChanged) is unchanged.
- Nfc 09d6111fa3b4, user-switch handler: after mCardEmulationManager.onUserSwitched(getUserId()), calls loadSecureNfcSettings(userId) inside the if (mIsHceCapable) block, so the controller gets the new user's own setting.
- Nfc 54e06116bb5e, isNfcSecureEnabled: before returning mIsSecureNfcEnabled, compares mUserId with ActivityManager.getCurrentUser(). If they differ, it calls loadSecureNfcSettings(current_userId).
- Settings 648d77dd382c, SecureNfcEnabler.handleNfcStateChanged and SecureNfcPreferenceController.setChecked: removes the isPrimaryUser-based isToggleable gates, so secondary users can change their own (now per-user) setting.
- Settings dc8f8abfcf83, same two files: adds isToggleable() back, now returning false only when mUserManager.isGuestUser(). For guest users the toggle is disabled in STATE_ON, and setChecked returns false without calling enableSecureNfc.
Completeness
- Covered: the stored setting is per-user. The in-memory value and the controller are refreshed on user switch, and in isNfcSecureEnabled when the tracked user differs from the current user. The Settings UI no longer lets guest users toggle the setting.
- The user identity used is the current (foreground) user via getUserId()/ActivityManager.getCurrentUser(), not the Binder calling user. setNfcSecure writes the key for the service's current user whoever calls it.
- The Android 14 commits do not migrate the old global PREF_SECURE_NFC_ON value. After the update, every user starts from SECURE_NFC_ON_DEFAULT. By contrast, the Android 16 code keeps a SYSTEM-user fallback to the old key, and the Android 17 commit f14ac3528f7b migrates it.
- loadSecureNfcSettings on user switch runs only when mIsHceCapable. Because mIsSecureNfcCapable now also requires mIsHceCapable, Secure NFC is always disabled on non-HCE devices.
- isNfcSecureEnabled reloads the setting but does not update mUserId. Repeated queries while the two differ each re-read the preference and call mDeviceHost.setNfcSecure.
Behavior changes
- The Secure NFC preference is now stored under PREF_SECURE_NFC_ON_<userId>. The old global value is no longer read on Android 14, so existing devices fall back to SECURE_NFC_ON_DEFAULT for every user.
- mIsSecureNfcCapable now requires HCE capability. On devices where deviceSupportsNfcSecure() is true but HCE is absent, Secure NFC is always disabled.
- On user switch (HCE-capable devices), the NFC controller gets the new user's Secure NFC setting and a log line is written.
- isNfcSecureEnabled can now read the preference and update the controller as a side effect.
- Settings: non-primary, non-guest users can now toggle Secure NFC. For guest users the toggle is disabled and setChecked returns false.
- setNfcSecure logs the current user id.
Per major
- Android 14: Resolved in android-security-14.0.0_r28 through four commits: Nfc 09d6111fa3b4 (per-user key, loadSecureNfcSettings, reload on user switch), Nfc 54e06116bb5e (reload in isNfcSecureEnabled), Settings 648d77dd382c (remove isPrimaryUser gates) and Settings dc8f8abfcf83 (block guest users). At android-security-14.0.0_r31 the Settings dc8f8abfcf83 region is fully present (8/8 lines). No migration of the old global key on this branch.
- Android 15: Resolved in android-security-15.0.0_r16. The material shows platform/packages/apps/Nfc da5a77b7fc72, the same isNfcSecureEnabled reload change as 54e06116bb5e. It calls an existing loadSecureNfcSettings, which suggests the per-user conversion was already in that tree. 3/3 lines present at android-security-15.0.0_r19.
- Android 16: Resolved in android-security-16.0.0_r10 by an adapted follow-up, platform/packages/modules/Nfc a041db277448 (NfcNci/src/com/android/nfc/NfcService.java, 'Fix Secure NFC init after DE migration'). Per-user keys and the SYSTEM-user fallback to the old PREF_SECURE_NFC_ON key already exist there. The commit wraps the Secure NFC setup after DE migration in synchronized (NfcService.this), saves the resolved value to the per-user key, notifies BackupManager, and triggers a routing table update or commitRouting. 8/8 lines present.
- Android 17: Resolved in android-security-17.0.0_r3 by platform/packages/modules/Nfc f14ac3528f7b ('A17 Secure Nfc Setting Migration'). In the constructor, for the SYSTEM user, it copies an old PREF_SECURE_NFC_ON value into the per-user key and removes the old key. Per-user keys and defaults from mDeviceConfigFacade were already present. 6/6 lines present.
Unknowns
- How mUserId/getUserId() is updated on user switch is not shown.
- What NfcPermissions.enforceAdminPermissions requires on this branch, and which callers in a secondary user could reach setNfcSecure before the fix, is not in the material.
- The original Android 15/16/17 commits that introduced the per-user key on those branches are not shown; only the follow-ups are.
- Whether 16-qpr2 or 17-qpr2-next needed changes beyond the listed commits is not shown.