From abd045e95cdc56327f8b3963cc28d32f9443d081 Mon Sep 17 00:00:00 2001 From: George Chang Date: Mon, 22 Mar 2021 17:06:37 +0800 Subject: [PATCH 1/3] Add new permission to set NFC always on states Bug: 182979907 Test: atest NfcNciInstrumentationTests Change-Id: I9a82c37f0b6716e68dc4c2d7e0f171d892f09112 --- core/api/system-current.txt | 7 ++++--- core/java/android/nfc/NfcAdapter.java | 6 +++--- core/res/AndroidManifest.xml | 6 ++++++ 3 files changed, 13 insertions(+), 6 deletions(-) diff --git a/core/api/system-current.txt b/core/api/system-current.txt index 4676523bbd6c1..7613266b94da7 100644 --- a/core/api/system-current.txt +++ b/core/api/system-current.txt @@ -155,6 +155,7 @@ package android { field public static final String NETWORK_SIGNAL_STRENGTH_WAKEUP = "android.permission.NETWORK_SIGNAL_STRENGTH_WAKEUP"; field public static final String NETWORK_STACK = "android.permission.NETWORK_STACK"; field public static final String NETWORK_STATS_PROVIDER = "android.permission.NETWORK_STATS_PROVIDER"; + field public static final String NFC_SET_CONTROLLER_ALWAYS_ON = "android.permission.NFC_SET_CONTROLLER_ALWAYS_ON"; field public static final String NOTIFICATION_DURING_SETUP = "android.permission.NOTIFICATION_DURING_SETUP"; field public static final String NOTIFY_TV_INPUTS = "android.permission.NOTIFY_TV_INPUTS"; field public static final String OBSERVE_APP_USAGE = "android.permission.OBSERVE_APP_USAGE"; @@ -6723,10 +6724,10 @@ package android.nfc { method @RequiresPermission(android.Manifest.permission.WRITE_SECURE_SETTINGS) public boolean enable(); method @RequiresPermission(android.Manifest.permission.WRITE_SECURE_SETTINGS) public boolean enableNdefPush(); method @RequiresPermission(android.Manifest.permission.WRITE_SECURE_SETTINGS) public boolean enableSecureNfc(boolean); - method @RequiresPermission(android.Manifest.permission.WRITE_SECURE_SETTINGS) public boolean isAlwaysOnEnabled(); - method @RequiresPermission(android.Manifest.permission.WRITE_SECURE_SETTINGS) public boolean isAlwaysOnSupported(); + method @RequiresPermission(android.Manifest.permission.NFC_SET_CONTROLLER_ALWAYS_ON) public boolean isAlwaysOnEnabled(); + method @RequiresPermission(android.Manifest.permission.NFC_SET_CONTROLLER_ALWAYS_ON) public boolean isAlwaysOnSupported(); method @RequiresPermission(android.Manifest.permission.WRITE_SECURE_SETTINGS) public boolean removeNfcUnlockHandler(android.nfc.NfcAdapter.NfcUnlockHandler); - method @RequiresPermission(android.Manifest.permission.WRITE_SECURE_SETTINGS) public boolean setAlwaysOn(boolean); + method @RequiresPermission(android.Manifest.permission.NFC_SET_CONTROLLER_ALWAYS_ON) public boolean setAlwaysOn(boolean); method public void setNdefPushMessage(android.nfc.NdefMessage, android.app.Activity, int); field public static final int FLAG_NDEF_PUSH_NO_CONFIRM = 1; // 0x1 } diff --git a/core/java/android/nfc/NfcAdapter.java b/core/java/android/nfc/NfcAdapter.java index e85eb935a8e7e..3aa02a044b89d 100644 --- a/core/java/android/nfc/NfcAdapter.java +++ b/core/java/android/nfc/NfcAdapter.java @@ -2254,7 +2254,7 @@ public final class NfcAdapter { * @hide */ @SystemApi - @RequiresPermission(android.Manifest.permission.WRITE_SECURE_SETTINGS) + @RequiresPermission(android.Manifest.permission.NFC_SET_CONTROLLER_ALWAYS_ON) public boolean setAlwaysOn(boolean value) { if (!sHasNfcFeature) { throw new UnsupportedOperationException(); @@ -2286,7 +2286,7 @@ public final class NfcAdapter { */ @SystemApi - @RequiresPermission(android.Manifest.permission.WRITE_SECURE_SETTINGS) + @RequiresPermission(android.Manifest.permission.NFC_SET_CONTROLLER_ALWAYS_ON) public boolean isAlwaysOnEnabled() { try { return sService.isAlwaysOnEnabled(); @@ -2315,7 +2315,7 @@ public final class NfcAdapter { */ @SystemApi - @RequiresPermission(android.Manifest.permission.WRITE_SECURE_SETTINGS) + @RequiresPermission(android.Manifest.permission.NFC_SET_CONTROLLER_ALWAYS_ON) public boolean isAlwaysOnSupported() { if (!sHasNfcFeature) { throw new UnsupportedOperationException(); diff --git a/core/res/AndroidManifest.xml b/core/res/AndroidManifest.xml index f65d7a7540e4d..4a222721558cb 100644 --- a/core/res/AndroidManifest.xml +++ b/core/res/AndroidManifest.xml @@ -1882,6 +1882,12 @@ android:label="@string/permlab_preferredPaymentInfo" android:protectionLevel="normal" /> + + +