Merge "Add Secure NFC functionality" am: 3ffdb26aa8
am: c538141c6d
Change-Id: I5e1c1d44396099c841f09bfdd2ac956f01fd4ceb
This commit is contained in:
@@ -68,4 +68,8 @@ interface INfcAdapter
|
||||
void removeNfcUnlockHandler(INfcUnlockHandler unlockHandler);
|
||||
|
||||
void verifyNfcPermission();
|
||||
boolean isNfcSecureEnabled();
|
||||
boolean deviceSupportsNfcSecure();
|
||||
boolean setNfcSecure(boolean enable);
|
||||
|
||||
}
|
||||
|
||||
@@ -1701,6 +1701,63 @@ public final class NfcAdapter {
|
||||
mNfcActivityManager.setOnNdefPushCompleteCallback(activity, null);
|
||||
}
|
||||
|
||||
/**
|
||||
* 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.
|
||||
|
||||
Reference in New Issue
Block a user