summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Ruchi Kandoi <kandoiruchi@google.com> 2019-01-08 14:16:25 -0800
committer Ruchi Kandoi <kandoiruchi@google.com> 2019-01-23 15:11:36 -0800
commitd97bb0929efdd3f7d1841987155e3c75c60f195d (patch)
treed02dec494aec1f183097386e72270f5dc6e6fbc8
parentbc40469e19fbca8a1bc7a70514cc84aa7e9717a4 (diff)
Add Secure NFC functionality
Test: Toggle NFC switch; Manual check functionality Change-Id: Ib57e6f8162f93f2f028e6bcc063ab3466f9c5474
-rwxr-xr-xapi/current.txt2
-rw-r--r--api/system-current.txt1
-rw-r--r--core/java/android/nfc/INfcAdapter.aidl4
-rw-r--r--core/java/android/nfc/NfcAdapter.java57
4 files changed, 64 insertions, 0 deletions
diff --git a/api/current.txt b/api/current.txt
index 35cedf3c3df4..300912b79f0d 100755
--- a/api/current.txt
+++ b/api/current.txt
@@ -29053,6 +29053,7 @@ package android.nfc {
}
public final class NfcAdapter {
+ method public boolean deviceSupportsNfcSecure();
method public void disableForegroundDispatch(android.app.Activity);
method @Deprecated public void disableForegroundNdefPush(android.app.Activity);
method public void disableReaderMode(android.app.Activity);
@@ -29065,6 +29066,7 @@ package android.nfc {
method @Deprecated public boolean invokeBeam(android.app.Activity);
method public boolean isEnabled();
method @Deprecated public boolean isNdefPushEnabled();
+ method public boolean isNfcSecureEnabled();
method @Deprecated public void setBeamPushUris(android.net.Uri[], android.app.Activity);
method @Deprecated public void setBeamPushUrisCallback(android.nfc.NfcAdapter.CreateBeamUrisCallback, android.app.Activity);
method @Deprecated public void setNdefPushMessage(android.nfc.NdefMessage, android.app.Activity, android.app.Activity...);
diff --git a/api/system-current.txt b/api/system-current.txt
index dae0049cfbb0..08d5ca063358 100644
--- a/api/system-current.txt
+++ b/api/system-current.txt
@@ -3834,6 +3834,7 @@ package android.nfc {
method @RequiresPermission(android.Manifest.permission.WRITE_SECURE_SETTINGS) public boolean enableNdefPush();
method @RequiresPermission(android.Manifest.permission.WRITE_SECURE_SETTINGS) public boolean removeNfcUnlockHandler(android.nfc.NfcAdapter.NfcUnlockHandler);
method public void setNdefPushMessage(android.nfc.NdefMessage, android.app.Activity, int);
+ method @RequiresPermission(android.Manifest.permission.WRITE_SECURE_SETTINGS) public boolean setNfcSecure(boolean);
field public static final int FLAG_NDEF_PUSH_NO_CONFIRM = 1; // 0x1
}
diff --git a/core/java/android/nfc/INfcAdapter.aidl b/core/java/android/nfc/INfcAdapter.aidl
index 6801618e6a68..0b2cfdd9ece3 100644
--- a/core/java/android/nfc/INfcAdapter.aidl
+++ b/core/java/android/nfc/INfcAdapter.aidl
@@ -68,4 +68,8 @@ interface INfcAdapter
void removeNfcUnlockHandler(INfcUnlockHandler unlockHandler);
void verifyNfcPermission();
+ boolean isNfcSecureEnabled();
+ boolean deviceSupportsNfcSecure();
+ boolean setNfcSecure(boolean enable);
+
}
diff --git a/core/java/android/nfc/NfcAdapter.java b/core/java/android/nfc/NfcAdapter.java
index e55e0364f5d4..a7d2ee98b45c 100644
--- a/core/java/android/nfc/NfcAdapter.java
+++ b/core/java/android/nfc/NfcAdapter.java
@@ -1702,6 +1702,63 @@ public final class NfcAdapter {
}
/**
+ * Sets Secure NFC feature.
+ * <p>This API is for the Settings application.
+ * @hide
+ */
+ @SystemApi
+ @RequiresPermission(android.Manifest.permission.WRITE_SECURE_SETTINGS)
+ public boolean setNfcSecure(boolean enable) {
+ if (!sHasNfcFeature) {
+ throw new UnsupportedOperationException();
+ }
+ try {
+ return sService.setNfcSecure(enable);
+ } catch (RemoteException e) {
+ attemptDeadServiceRecovery(e);
+ return false;
+ }
+ }
+
+ /**
+ * Checks if the device supports Secure NFC functionality.
+ *
+ * @return True if device supports Secure NFC, false otherwise
+ * @throws UnsupportedOperationException if FEATURE_NFC is unavailable.
+ */
+ public boolean deviceSupportsNfcSecure() {
+ if (!sHasNfcFeature) {
+ throw new UnsupportedOperationException();
+ }
+ try {
+ return sService.deviceSupportsNfcSecure();
+ } catch (RemoteException e) {
+ attemptDeadServiceRecovery(e);
+ return false;
+ }
+ }
+
+ /**
+ * Checks Secure NFC feature is enabled.
+ *
+ * @return True if device supports Secure NFC is enabled, false otherwise
+ * @throws UnsupportedOperationException if FEATURE_NFC is unavailable.
+ * @throws UnsupportedOperationException if device doesn't support
+ * Secure NFC functionality. {@link #deviceSupportsNfcSecure}
+ */
+ public boolean isNfcSecureEnabled() {
+ if (!sHasNfcFeature) {
+ throw new UnsupportedOperationException();
+ }
+ try {
+ return sService.isNfcSecureEnabled();
+ } catch (RemoteException e) {
+ attemptDeadServiceRecovery(e);
+ return false;
+ }
+ }
+
+ /**
* Enable NDEF Push feature.
* <p>This API is for the Settings application.
* @hide