Skip to content

pcolby/nfc-quick-settings

Repository files navigation

NFC Quick Settings

Build Status CodeQL Analysis Codacy Grade Maintainability Rating Reliability Rating Security Rating Vulnerabilities

NFC Quick Settings is a really basic Android app with no GUI of it's own, that simply adds an NFC tile to the tiles available to the Quick Settings panel.

The Quick Settings tile indicates the current NFC status (enabled, or disabled), but the action it takes when tapped varies a little depending on the permissions available. See Basic and Advanced modes below.

Get itGet it

Basic Mode

In the basic mode, which requires no special permissions, tapping the tile will simply open the device's NFC Settings page (assuming the device has one). This is actually the best that can be done using official Android APIs.

Advanced Mode

The advanced mode requires special permissions (see below), but once enabled, tapping the NFC Quick Settings tile will turn the NFC service on or off directly, without having to open the NFC settings page at all. Unfortunately, to acheive this advanced mode, NFC Quick Settings needs to use APIs not intended for third-party applications (specifically NfcAdapter::enable() and NfcAdapter::disable()), and to use those methods the tile needs the special WRITE_SECURE_SETTINGS permission.

Granting WRITE_SECURE_SETTINGS Permission

As the WRITE_SECURE_SETTINGS permission is not intended to be used by third-party applications, it needs to be granted via the Android Debug Bridge (adb) tool.

  1. Install Android Debug Bridge (adb):

    adb is included in the Android SDK Platform Tools package. Download this package with the SDK Manager, which installs it at android_sdk/platform-tools/. If you want the standalone Android SDK Platform Tools package, download it here.

  2. Install NFC Quick Settings, via Google Play, F-Droid, or GitHub Releases.

  3. Enable adb debugging on your device.

  4. Connect your device via Wi-Fi.

  5. Grant the permission to NFC Quick Settings via adb:

    adb shell pm grant au.id.colby.nfcquicksettings android.permission.WRITE_SECURE_SETTINGS

If for some reason you want to revoke the WRITE_SECURE_SETTINGS permission, and restore the basic mode, then simply follow the same steps as above, but replace grant with revoke. That is, run:

adb shell pm revoke au.id.colby.nfcquicksettings android.permission.WRITE_SECURE_SETTINGS