Merge "Fix the feature flag mis-checking cause exception issue" am: a78c7e67c9
Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/2424965 Change-Id: I5b8bd30578afefd87991a53d1f64d8e1c02e18e7 Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
This commit is contained in:
@@ -419,6 +419,7 @@ public final class NfcAdapter {
|
|||||||
static boolean sIsInitialized = false;
|
static boolean sIsInitialized = false;
|
||||||
static boolean sHasNfcFeature;
|
static boolean sHasNfcFeature;
|
||||||
static boolean sHasBeamFeature;
|
static boolean sHasBeamFeature;
|
||||||
|
static boolean sHasCeFeature;
|
||||||
|
|
||||||
// Final after first constructor, except for
|
// Final after first constructor, except for
|
||||||
// attemptDeadServiceRecovery() when NFC crashes - we accept a best effort
|
// attemptDeadServiceRecovery() when NFC crashes - we accept a best effort
|
||||||
@@ -616,11 +617,13 @@ public final class NfcAdapter {
|
|||||||
pm = context.getPackageManager();
|
pm = context.getPackageManager();
|
||||||
sHasNfcFeature = pm.hasSystemFeature(PackageManager.FEATURE_NFC);
|
sHasNfcFeature = pm.hasSystemFeature(PackageManager.FEATURE_NFC);
|
||||||
sHasBeamFeature = pm.hasSystemFeature(PackageManager.FEATURE_NFC_BEAM);
|
sHasBeamFeature = pm.hasSystemFeature(PackageManager.FEATURE_NFC_BEAM);
|
||||||
boolean hasHceFeature =
|
sHasCeFeature =
|
||||||
pm.hasSystemFeature(PackageManager.FEATURE_NFC_HOST_CARD_EMULATION)
|
pm.hasSystemFeature(PackageManager.FEATURE_NFC_HOST_CARD_EMULATION)
|
||||||
|| pm.hasSystemFeature(PackageManager.FEATURE_NFC_HOST_CARD_EMULATION_NFCF);
|
|| pm.hasSystemFeature(PackageManager.FEATURE_NFC_HOST_CARD_EMULATION_NFCF)
|
||||||
|
|| pm.hasSystemFeature(PackageManager.FEATURE_NFC_OFF_HOST_CARD_EMULATION_UICC)
|
||||||
|
|| pm.hasSystemFeature(PackageManager.FEATURE_NFC_OFF_HOST_CARD_EMULATION_ESE);
|
||||||
/* is this device meant to have NFC */
|
/* is this device meant to have NFC */
|
||||||
if (!sHasNfcFeature && !hasHceFeature) {
|
if (!sHasNfcFeature && !sHasCeFeature) {
|
||||||
Log.v(TAG, "this device does not have NFC support");
|
Log.v(TAG, "this device does not have NFC support");
|
||||||
throw new UnsupportedOperationException();
|
throw new UnsupportedOperationException();
|
||||||
}
|
}
|
||||||
@@ -643,7 +646,7 @@ public final class NfcAdapter {
|
|||||||
throw new UnsupportedOperationException();
|
throw new UnsupportedOperationException();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (hasHceFeature) {
|
if (sHasCeFeature) {
|
||||||
try {
|
try {
|
||||||
sNfcFCardEmulationService = sService.getNfcFCardEmulationInterface();
|
sNfcFCardEmulationService = sService.getNfcFCardEmulationInterface();
|
||||||
} catch (RemoteException e) {
|
} catch (RemoteException e) {
|
||||||
@@ -1846,7 +1849,7 @@ public final class NfcAdapter {
|
|||||||
@SystemApi
|
@SystemApi
|
||||||
@RequiresPermission(android.Manifest.permission.WRITE_SECURE_SETTINGS)
|
@RequiresPermission(android.Manifest.permission.WRITE_SECURE_SETTINGS)
|
||||||
public boolean enableSecureNfc(boolean enable) {
|
public boolean enableSecureNfc(boolean enable) {
|
||||||
if (!sHasNfcFeature) {
|
if (!sHasNfcFeature && !sHasCeFeature) {
|
||||||
throw new UnsupportedOperationException();
|
throw new UnsupportedOperationException();
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
@@ -1871,10 +1874,13 @@ public final class NfcAdapter {
|
|||||||
* Checks if the device supports Secure NFC functionality.
|
* Checks if the device supports Secure NFC functionality.
|
||||||
*
|
*
|
||||||
* @return True if device supports Secure NFC, false otherwise
|
* @return True if device supports Secure NFC, false otherwise
|
||||||
* @throws UnsupportedOperationException if FEATURE_NFC is unavailable.
|
* @throws UnsupportedOperationException if FEATURE_NFC,
|
||||||
|
* FEATURE_NFC_HOST_CARD_EMULATION, FEATURE_NFC_HOST_CARD_EMULATION_NFCF,
|
||||||
|
* FEATURE_NFC_OFF_HOST_CARD_EMULATION_UICC and FEATURE_NFC_OFF_HOST_CARD_EMULATION_ESE
|
||||||
|
* are unavailable
|
||||||
*/
|
*/
|
||||||
public boolean isSecureNfcSupported() {
|
public boolean isSecureNfcSupported() {
|
||||||
if (!sHasNfcFeature) {
|
if (!sHasNfcFeature && !sHasCeFeature) {
|
||||||
throw new UnsupportedOperationException();
|
throw new UnsupportedOperationException();
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
@@ -1900,11 +1906,14 @@ public final class NfcAdapter {
|
|||||||
* such as their relative positioning on the device.
|
* such as their relative positioning on the device.
|
||||||
*
|
*
|
||||||
* @return Information on the nfc antenna(s) on the device.
|
* @return Information on the nfc antenna(s) on the device.
|
||||||
* @throws UnsupportedOperationException if FEATURE_NFC is unavailable.
|
* @throws UnsupportedOperationException if FEATURE_NFC,
|
||||||
|
* FEATURE_NFC_HOST_CARD_EMULATION, FEATURE_NFC_HOST_CARD_EMULATION_NFCF,
|
||||||
|
* FEATURE_NFC_OFF_HOST_CARD_EMULATION_UICC and FEATURE_NFC_OFF_HOST_CARD_EMULATION_ESE
|
||||||
|
* are unavailable
|
||||||
*/
|
*/
|
||||||
@Nullable
|
@Nullable
|
||||||
public NfcAntennaInfo getNfcAntennaInfo() {
|
public NfcAntennaInfo getNfcAntennaInfo() {
|
||||||
if (!sHasNfcFeature) {
|
if (!sHasNfcFeature && !sHasCeFeature) {
|
||||||
throw new UnsupportedOperationException();
|
throw new UnsupportedOperationException();
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
@@ -1929,12 +1938,15 @@ public final class NfcAdapter {
|
|||||||
* Checks Secure NFC feature is enabled.
|
* Checks Secure NFC feature is enabled.
|
||||||
*
|
*
|
||||||
* @return True if Secure NFC is enabled, false otherwise
|
* @return True if Secure NFC is enabled, false otherwise
|
||||||
* @throws UnsupportedOperationException if FEATURE_NFC is unavailable.
|
* @throws UnsupportedOperationException if FEATURE_NFC,
|
||||||
|
* FEATURE_NFC_HOST_CARD_EMULATION, FEATURE_NFC_HOST_CARD_EMULATION_NFCF,
|
||||||
|
* FEATURE_NFC_OFF_HOST_CARD_EMULATION_UICC and FEATURE_NFC_OFF_HOST_CARD_EMULATION_ESE
|
||||||
|
* are unavailable
|
||||||
* @throws UnsupportedOperationException if device doesn't support
|
* @throws UnsupportedOperationException if device doesn't support
|
||||||
* Secure NFC functionality. {@link #isSecureNfcSupported}
|
* Secure NFC functionality. {@link #isSecureNfcSupported}
|
||||||
*/
|
*/
|
||||||
public boolean isSecureNfcEnabled() {
|
public boolean isSecureNfcEnabled() {
|
||||||
if (!sHasNfcFeature) {
|
if (!sHasNfcFeature && !sHasCeFeature) {
|
||||||
throw new UnsupportedOperationException();
|
throw new UnsupportedOperationException();
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
@@ -2281,14 +2293,17 @@ public final class NfcAdapter {
|
|||||||
* always on.
|
* always on.
|
||||||
* @param value if true the NFCC will be kept on (with no RF enabled if NFC adapter is
|
* @param value if true the NFCC will be kept on (with no RF enabled if NFC adapter is
|
||||||
* disabled), if false the NFCC will follow completely the Nfc adapter state.
|
* disabled), if false the NFCC will follow completely the Nfc adapter state.
|
||||||
* @throws UnsupportedOperationException if FEATURE_NFC is unavailable.
|
* @throws UnsupportedOperationException if FEATURE_NFC,
|
||||||
|
* FEATURE_NFC_HOST_CARD_EMULATION, FEATURE_NFC_HOST_CARD_EMULATION_NFCF,
|
||||||
|
* FEATURE_NFC_OFF_HOST_CARD_EMULATION_UICC and FEATURE_NFC_OFF_HOST_CARD_EMULATION_ESE
|
||||||
|
* are unavailable
|
||||||
* @return void
|
* @return void
|
||||||
* @hide
|
* @hide
|
||||||
*/
|
*/
|
||||||
@SystemApi
|
@SystemApi
|
||||||
@RequiresPermission(android.Manifest.permission.NFC_SET_CONTROLLER_ALWAYS_ON)
|
@RequiresPermission(android.Manifest.permission.NFC_SET_CONTROLLER_ALWAYS_ON)
|
||||||
public boolean setControllerAlwaysOn(boolean value) {
|
public boolean setControllerAlwaysOn(boolean value) {
|
||||||
if (!sHasNfcFeature) {
|
if (!sHasNfcFeature && !sHasCeFeature) {
|
||||||
throw new UnsupportedOperationException();
|
throw new UnsupportedOperationException();
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
@@ -2313,7 +2328,10 @@ public final class NfcAdapter {
|
|||||||
* Checks NFC controller always on feature is enabled.
|
* Checks NFC controller always on feature is enabled.
|
||||||
*
|
*
|
||||||
* @return True if NFC controller always on is enabled, false otherwise
|
* @return True if NFC controller always on is enabled, false otherwise
|
||||||
* @throws UnsupportedOperationException if FEATURE_NFC is unavailable.
|
* @throws UnsupportedOperationException if FEATURE_NFC,
|
||||||
|
* FEATURE_NFC_HOST_CARD_EMULATION, FEATURE_NFC_HOST_CARD_EMULATION_NFCF,
|
||||||
|
* FEATURE_NFC_OFF_HOST_CARD_EMULATION_UICC and FEATURE_NFC_OFF_HOST_CARD_EMULATION_ESE
|
||||||
|
* are unavailable
|
||||||
* @hide
|
* @hide
|
||||||
*/
|
*/
|
||||||
@SystemApi
|
@SystemApi
|
||||||
@@ -2341,13 +2359,16 @@ public final class NfcAdapter {
|
|||||||
* Checks if the device supports NFC controller always on functionality.
|
* Checks if the device supports NFC controller always on functionality.
|
||||||
*
|
*
|
||||||
* @return True if device supports NFC controller always on, false otherwise
|
* @return True if device supports NFC controller always on, false otherwise
|
||||||
* @throws UnsupportedOperationException if FEATURE_NFC is unavailable.
|
* @throws UnsupportedOperationException if FEATURE_NFC,
|
||||||
|
* FEATURE_NFC_HOST_CARD_EMULATION, FEATURE_NFC_HOST_CARD_EMULATION_NFCF,
|
||||||
|
* FEATURE_NFC_OFF_HOST_CARD_EMULATION_UICC and FEATURE_NFC_OFF_HOST_CARD_EMULATION_ESE
|
||||||
|
* are unavailable
|
||||||
* @hide
|
* @hide
|
||||||
*/
|
*/
|
||||||
@SystemApi
|
@SystemApi
|
||||||
@RequiresPermission(android.Manifest.permission.NFC_SET_CONTROLLER_ALWAYS_ON)
|
@RequiresPermission(android.Manifest.permission.NFC_SET_CONTROLLER_ALWAYS_ON)
|
||||||
public boolean isControllerAlwaysOnSupported() {
|
public boolean isControllerAlwaysOnSupported() {
|
||||||
if (!sHasNfcFeature) {
|
if (!sHasNfcFeature && !sHasCeFeature) {
|
||||||
throw new UnsupportedOperationException();
|
throw new UnsupportedOperationException();
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
|
|||||||
Reference in New Issue
Block a user