aboutsummaryrefslogtreecommitdiffstats
path: root/nci
diff options
context:
space:
mode:
Diffstat (limited to 'nci')
-rw-r--r--nci/jni/JavaClassConstants.h1
-rwxr-xr-xnci/jni/NativeNfcManager.cpp1736
-rwxr-xr-xnci/jni/NativeSecureElement.cpp17
-rwxr-xr-xnci/jni/RoutingManager.cpp1466
-rwxr-xr-xnci/jni/RoutingManager.h48
-rwxr-xr-xnci/jni/SecureElement.cpp37
-rw-r--r--nci/jni/SecureElement.h13
-rwxr-xr-x[-rw-r--r--]nci/jni/TransactionController.h1
-rwxr-xr-xnci/src/com/android/nfc/dhimpl/NativeNfcManager.java515
-rwxr-xr-xnci/src/com/android/nfc/dhimpl/NativeNfcSecureElement.java70
-rwxr-xr-xnci/src/com/android/nfc/dhimpl/NativeNfcTag.java26
-rw-r--r--nci/src/com/gsma/nfc/internal/NxpNfcController.java428
-rw-r--r--nci/src/com/gsma/nfc/internal/RegisteredNxpServicesCache.java409
13 files changed, 887 insertions, 3880 deletions
diff --git a/nci/jni/JavaClassConstants.h b/nci/jni/JavaClassConstants.h
index 3301e710..b5d166c8 100644
--- a/nci/jni/JavaClassConstants.h
+++ b/nci/jni/JavaClassConstants.h
@@ -38,7 +38,6 @@
namespace android {
extern jmethodID gCachedNfcManagerNotifyNdefMessageListeners;
extern jmethodID gCachedNfcManagerNotifyTransactionListeners;
-extern jmethodID gCachedNfcManagerNotifyConnectivityListeners;
extern jmethodID gCachedNfcManagerNotifyEmvcoMultiCardDetectedListeners;
extern jmethodID gCachedNfcManagerNotifyLlcpLinkActivation;
extern jmethodID gCachedNfcManagerNotifyLlcpLinkDeactivated;
diff --git a/nci/jni/NativeNfcManager.cpp b/nci/jni/NativeNfcManager.cpp
index 263db03d..77d89abe 100755
--- a/nci/jni/NativeNfcManager.cpp
+++ b/nci/jni/NativeNfcManager.cpp
@@ -118,7 +118,6 @@ extern uint8_t swp_getconfig_status;
extern int gUICCVirtualWiredProtectMask;
extern int gEseVirtualWiredProtectMask;
extern bool IsEseCeDisabled;
-static int32_t gNfcInitTimeout;
int32_t gdisc_timeout;
int32_t gSeDiscoverycount = 0;
int32_t gActualSeCount = 0;
@@ -130,6 +129,8 @@ int32_t gSelfTestType = TEST_TYPE_NONE;
bool nfcManager_getTransanctionRequest(int t3thandle, bool registerRequest);
extern bool createSPIEvtHandlerThread();
extern void releaseSPIEvtHandlerThread();
+jint nfcManager_getUiccId(jint uicc_slot);
+jint nfcManager_getUiccRoute(jint uicc_slot);
#endif
namespace android {
extern bool gIsTagDeactivating;
@@ -165,7 +166,6 @@ extern tNFA_STATUS SendAutonomousMode(int state, uint8_t num);
extern tNFA_STATUS Nxp_SelfTest(uint8_t testcase, uint8_t* param);
extern void SetCbStatus(tNFA_STATUS status);
extern tNFA_STATUS GetCbStatus(void);
-static void nfaNxpSelfTestNtfTimerCb(union sigval);
extern tNFA_STATUS ResetEseSession();
// Factory Test Code --end
extern bool getReconnectState(void);
@@ -181,6 +181,7 @@ extern bool gIsWaiting4Deact2SleepNtf;
extern bool gGotDeact2IdleNtf;
bool nfcManager_isTransanctionOnGoing(bool isInstallRequest);
bool nfcManager_isRequestPending(void);
+static jint nfcManager_doaccessControlForCOSU(JNIEnv* e, jobject o, jint mode);
extern tNFA_STATUS enableSWPInterface();
extern tNFA_STATUS NxpNfc_Send_CoreResetInit_Cmd(void);
jmethodID gCachedNfcManagerNotifyFwDwnldRequested;
@@ -210,7 +211,6 @@ namespace android {
int gGeneralPowershutDown = 0;
jmethodID gCachedNfcManagerNotifyNdefMessageListeners;
jmethodID gCachedNfcManagerNotifyTransactionListeners;
-jmethodID gCachedNfcManagerNotifyConnectivityListeners;
jmethodID gCachedNfcManagerNotifyEmvcoMultiCardDetectedListeners;
jmethodID gCachedNfcManagerNotifyLlcpLinkActivation;
jmethodID gCachedNfcManagerNotifyLlcpLinkDeactivated;
@@ -229,7 +229,6 @@ jmethodID gCachedNfcManagerNotifyAidRoutingTableFull;
int gMaxEERecoveryTimeout = MAX_EE_RECOVERY_TIMEOUT;
jmethodID gCachedNfcManagerNotifyUiccStatusEvent;
jmethodID gCachedNfcManagerNotifyT3tConfigure;
-jmethodID gCachedNfcManagerNotifyJcosDownloadInProgress;
jmethodID gCachedNfcManagerNotifyReRoutingEntry;
#endif
const char* gNativeP2pDeviceClassName =
@@ -258,11 +257,9 @@ void enableRfDiscovery();
void disableRfDiscovery();
void storeLastDiscoveryParams(int technologies_mask, bool enable_lptd,
bool reader_mode, bool enable_p2p, bool restart);
-static tNFA_STATUS configureListening(uint8_t aListenMask);
-static tNFA_STATUS configurePolling(uint8_t aPollMask);
-static tNFA_STATUS performRFTest(bool on);
-static tNFA_STATUS performTransacAB(uint8_t aType);
static void activatedNtf_Cb();
+static void nfcManager_changeDiscoveryTech(JNIEnv* e, jobject o, jint pollTech,
+ jint listenTech);
#endif
} // namespace android
@@ -273,10 +270,6 @@ static void activatedNtf_Cb();
*****************************************************************************/
namespace android {
static jint sLastError = ERROR_BUFFER_TOO_SMALL;
-static jmethodID sCachedNfcManagerNotifySeApduReceived;
-static jmethodID sCachedNfcManagerNotifySeMifareAccess;
-static jmethodID sCachedNfcManagerNotifySeEmvCardRemoval;
-static jmethodID sCachedNfcManagerNotifyTargetDeselected;
static SyncEvent sNfaEnableEvent; // event for NFA_Enable()
static SyncEvent sNfaDisableEvent; // event for NFA_Disable()
static SyncEvent sNfaTransitConfigEvent; // event for NFA_SetTransitConfig()
@@ -304,6 +297,7 @@ static uint8_t sIsSecElemSelected = 0; // has NFC service selected a sec elem
static uint8_t sIsSecElemDetected = 0; // has NFC service deselected a sec elem
static bool sDiscCmdwhleNfcOff = false;
static uint8_t sAutonomousSet = 0;
+static bool sRoutingInitialized = false;
#define CONFIG_UPDATE_TECH_MASK (1 << 1)
#define TRANSACTION_TIMER_VALUE 50
@@ -343,8 +337,6 @@ static void nfcManager_doSetScreenState(JNIEnv* e, jobject o,
jint screen_state_mask);
static jint nfcManager_doGetNciVersion(JNIEnv*, jobject);
static int NFA_SCREEN_POLLING_TAG_MASK = 0x10;
-static void nfcManager_doSetScreenOrPowerState(JNIEnv* e, jobject o,
- jint state);
static void StoreScreenState(int state);
int getScreenState();
static void nfaConnectionCallback(uint8_t event, tNFA_CONN_EVT_DATA* eventData);
@@ -356,14 +348,8 @@ static tNFA_STATUS stopPolling_rfDiscoveryDisabled();
static tNFA_STATUS startPolling_rfDiscoveryDisabled(
tNFA_TECHNOLOGY_MASK tech_mask);
-static int nfcManager_getChipVer(JNIEnv* e, jobject o);
static std::string ConvertJavaStrToStdString(JNIEnv* env, jstring s);
-static int nfcManager_getNfcInitTimeout(JNIEnv* e, jobject o);
-static int nfcManager_doJcosDownload(JNIEnv* e, jobject o);
-static void nfcManager_doCommitRouting(JNIEnv* e, jobject o);
-static jint nfcManager_getSecureElementTechList(JNIEnv* e, jobject o);
-static void nfcManager_setSecureElementListenTechMask(JNIEnv* e, jobject o,
- jint tech_mask);
+static jboolean nfcManager_doCommitRouting(JNIEnv* e, jobject o);
static void notifyPollingEventwhileNfcOff();
static uint8_t getJCOPOS_UpdaterState();
@@ -375,7 +361,6 @@ static int prevScreenState = NFA_SCREEN_STATE_OFF_LOCKED;
#if (NXP_EXTNS == TRUE)
static uint8_t sNfcState = NFC_OFF;
bool isp2pActivated();
-static void nfcManager_doSetNfcMode(JNIEnv* e, jobject o, jint nfcMode);
typedef struct {
uint8_t sUicc1Cntx[256];
uint16_t sUicc1CntxLen;
@@ -442,18 +427,10 @@ static IntervalTimer uiccEventTimer; // notification timer for uicc select
static void notifyUiccEvent(union sigval);
static SyncEvent sNfaNxpNtfEvent;
static SyncEvent sNfaSetPowerSubState; // event for power substate
-static void nfaNxpSelfTestNtfTimerCb(union sigval);
static int nfcManager_setPreferredSimSlot(JNIEnv* e, jobject o, jint uiccSlot);
-static void nfcManager_doSetEEPROM(JNIEnv* e, jobject o, jbyteArray val);
static jint nfcManager_getFwVersion(JNIEnv* e, jobject o);
-static jint nfcManager_SWPSelfTest(JNIEnv* e, jobject o, jint ch);
-static void nfcManager_doPrbsOff(JNIEnv* e, jobject o);
-static void nfcManager_doPrbsOn(JNIEnv* e, jobject o, jint prbs, jint hw_prbs,
- jint tech, jint rate);
static void nfcManager_Enablep2p(JNIEnv* e, jobject o, jboolean p2pFlag);
// self test end
-static void nfcManager_setProvisionMode(JNIEnv* e, jobject o,
- jboolean provisionMode);
static bool nfcManager_doPartialDeInitialize();
static int nfcManager_doSelectUicc(JNIEnv* e, jobject o, jint uiccSlot);
static void restartUiccListen(jint uiccSlot);
@@ -511,6 +488,13 @@ typedef enum transcation_events {
NFA_TRANS_CE_DEACTIVATED = 0x19,
} eTranscation_events_t;
+typedef enum se_client {
+ DEFAULT = 0x00,
+ LDR_SRVCE,
+ JCOP_SRVCE,
+ LTSM_SRVCE
+} seClient_t;
+
/*Structure to store discovery parameters*/
typedef struct discovery_Parameters {
int technologies_mask;
@@ -557,6 +541,7 @@ static void nfcManager_enableDiscovery(JNIEnv* e, jobject o,
jint technologies_mask,
jboolean enable_lptd,
jboolean reader_mode,
+ jboolean enable_host_routing,
jboolean enable_p2p, jboolean restart);
void nfcManager_disableDiscovery(JNIEnv*, jobject);
static char get_last_request(void);
@@ -1529,10 +1514,6 @@ static void nfaConnectionCallback(uint8_t connEvent,
gCachedNfcManagerNotifyNdefMessageListeners =
e->GetMethodID(cls.get(), "notifyNdefMessageListeners",
"(Lcom/android/nfc/dhimpl/NativeNfcTag;)V");
- gCachedNfcManagerNotifyConnectivityListeners =
- e->GetMethodID(cls.get(), "notifyConnectivityListeners", "(I)V");
- gCachedNfcManagerNotifyEmvcoMultiCardDetectedListeners = e->GetMethodID(
- cls.get(), "notifyEmvcoMultiCardDetectedListeners", "()V");
gCachedNfcManagerNotifyLlcpLinkActivation =
e->GetMethodID(cls.get(), "notifyLlcpLinkActivation",
"(Lcom/android/nfc/dhimpl/NativeP2pDevice;)V");
@@ -1542,12 +1523,6 @@ static void nfaConnectionCallback(uint8_t connEvent,
gCachedNfcManagerNotifyLlcpFirstPacketReceived =
e->GetMethodID(cls.get(), "notifyLlcpLinkFirstPacketReceived",
"(Lcom/android/nfc/dhimpl/NativeP2pDevice;)V");
- sCachedNfcManagerNotifyTargetDeselected =
- e->GetMethodID(cls.get(), "notifyTargetDeselected", "()V");
- gCachedNfcManagerNotifySeFieldActivated =
- e->GetMethodID(cls.get(), "notifySeFieldActivated", "()V");
- gCachedNfcManagerNotifySeFieldDeactivated =
- e->GetMethodID(cls.get(), "notifySeFieldDeactivated", "()V");
gCachedNfcManagerNotifySeListenActivated =
e->GetMethodID(cls.get(), "notifySeListenActivated", "()V");
gCachedNfcManagerNotifySeListenDeactivated =
@@ -1556,8 +1531,6 @@ static void nfaConnectionCallback(uint8_t connEvent,
gCachedNfcManagerNotifyHostEmuActivated =
e->GetMethodID(cls.get(), "notifyHostEmuActivated", "(I)V");
- gCachedNfcManagerNotifyAidRoutingTableFull =
- e->GetMethodID(cls.get(), "notifyAidRoutingTableFull", "()V");
gCachedNfcManagerNotifyHostEmuData =
e->GetMethodID(cls.get(), "notifyHostEmuData", "(I[B)V");
@@ -1570,36 +1543,9 @@ static void nfaConnectionCallback(uint8_t connEvent,
gCachedNfcManagerNotifyRfFieldDeactivated =
e->GetMethodID(cls.get(), "notifyRfFieldDeactivated", "()V");
- sCachedNfcManagerNotifySeApduReceived =
- e->GetMethodID(cls.get(), "notifySeApduReceived", "([B)V");
-
- sCachedNfcManagerNotifySeMifareAccess =
- e->GetMethodID(cls.get(), "notifySeMifareAccess", "([B)V");
-
- sCachedNfcManagerNotifySeEmvCardRemoval =
- e->GetMethodID(cls.get(), "notifySeEmvCardRemoval", "()V");
-
gCachedNfcManagerNotifyTransactionListeners = e->GetMethodID(
cls.get(), "notifyTransactionListeners", "([B[BLjava/lang/String;)V");
-#if (NXP_EXTNS == TRUE)
- gCachedNfcManagerNotifyReRoutingEntry =
- e->GetMethodID(cls.get(), "notifyReRoutingEntry", "()V");
-
- gCachedNfcManagerNotifyUiccStatusEvent =
- e->GetMethodID(cls.get(), "notifyUiccStatusEvent", "(I)V");
-
-#if (NXP_NFCC_HCE_F == TRUE)
- gCachedNfcManagerNotifyT3tConfigure =
- e->GetMethodID(cls.get(), "notifyT3tConfigure", "()V");
-#endif
- gCachedNfcManagerNotifyJcosDownloadInProgress =
- e->GetMethodID(cls.get(), "notifyJcosDownloadInProgress", "(I)V");
-
- gCachedNfcManagerNotifyFwDwnldRequested =
- e->GetMethodID(cls.get(), "notifyFwDwnldRequested", "()V");
-
-#endif
if (nfc_jni_cache_object(e, gNativeNfcTagClassName,
&(nat->cached_NfcTag)) == -1) {
LOG(ERROR) << StringPrintf("%s: fail cache NativeNfcTag", __func__);
@@ -2052,52 +1998,6 @@ static void nfaConnectionCallback(uint8_t connEvent,
#if (NXP_EXTNS == TRUE)
/*******************************************************************************
**
- ** Function: nfcManager_nfcSelfTest
- **
- ** Description: Function to perform different types of analog tests
- ** i'e RF ON, RF OFF, Transc A, Transc B.
- **
- ** Returns: success/failure
- **
- *******************************************************************************/
-
- static jint nfcManager_nfcSelfTest(JNIEnv * e, jobject o, jint aType) {
- tNFA_STATUS status = NFA_STATUS_FAILED;
-
- if (!sIsNfaEnabled) {
- DLOG_IF(INFO, nfc_debug_enabled)
- << StringPrintf("NFC does not enabled!! returning...");
- return status;
- }
- gSelfTestType = aType;
- if (sDiscoveryEnabled) {
- startRfDiscovery(false);
- }
-
- switch (aType) {
- case TEST_TYPE_RF_ON:
- status = performRFTest(true);
- break;
- case TEST_TYPE_RF_OFF:
- status = performRFTest(false);
- break;
- case TEST_TYPE_TRANSAC_A:
- status = performTransacAB(NFC_CMD_TYPE_TRANSAC_A);
- break;
- case TEST_TYPE_TRANSAC_B:
- status = performTransacAB(NFC_CMD_TYPE_TRANSAC_B);
- break;
- default:
- DLOG_IF(INFO, nfc_debug_enabled)
- << StringPrintf("nfcManager_nfcSelfTest Invalid Parameter!!");
- break;
- }
- gSelfTestType = TEST_TYPE_NONE;
- return status;
- }
-
- /*******************************************************************************
- **
** Function: nfcManager_setRoutingEntry
**
** Description: Set the routing entry in routing table
@@ -2120,8 +2020,10 @@ static void nfaConnectionCallback(uint8_t connEvent,
result = RoutingManager::getInstance().setRoutingEntry(type, value, route,
power);
+ gsRouteUpdated = true;
return result;
}
+
/*******************************************************************************
**
** Function: nfcManager_clearRoutingEntry
@@ -2139,58 +2041,24 @@ static void nfaConnectionCallback(uint8_t connEvent,
result = RoutingManager::getInstance().clearRoutingEntry(type);
return result;
}
-#endif
/*******************************************************************************
**
- ** Function: nfcManager_setDefaultRoute
+ ** Function: nfcManager_setEmptyAidRoute
**
- ** Description: Set the default route in routing table
+ ** Description: Set the routing entry in routing table
** e: JVM environment.
** o: Java object.
+ ** type:technology/protocol/aid clear routing
**
*******************************************************************************/
- static jboolean nfcManager_setDefaultRoute(
- JNIEnv*, jobject, jint defaultRouteEntry, jint defaultProtoRouteEntry,
- jint defaultTechRouteEntry) {
- jboolean result = false;
- DLOG_IF(INFO, nfc_debug_enabled) << StringPrintf("%s : enter", __func__);
-#if (NXP_EXTNS == TRUE)
- if (!pTransactionController->transactionAttempt(
- TRANSACTION_REQUESTOR(setDefaultRoute))) {
- LOG(ERROR) << StringPrintf(
- "%s : Transaction in progress, Store the request", __FUNCTION__);
- set_last_request(RE_ROUTING, NULL);
- return result;
- }
-#endif
- if (sRfEnabled) {
- // Stop RF discovery to reconfigure
- startRfDiscovery(false);
- }
-
-#if (NXP_EXTNS == TRUE)
- result = RoutingManager::getInstance().setDefaultRoute(
- defaultRouteEntry, defaultProtoRouteEntry, defaultTechRouteEntry);
- if (result)
- result = RoutingManager::getInstance().commitRouting();
- else
- DLOG_IF(INFO, nfc_debug_enabled)
- << StringPrintf("%s : Commit routing failed ", __func__);
- gsRouteUpdated = true;
-#else
- result = RoutingManager::getInstance().setDefaultRouting();
-#endif
+ static void nfcManager_setEmptyAidRoute(JNIEnv*, jobject) {
+ RoutingManager::getInstance().setEmptyAidEntry();
+ return;
+ }
- startRfDiscovery(true);
-#if (NXP_EXTNS == TRUE)
- pTransactionController->transactionEnd(
- TRANSACTION_REQUESTOR(setDefaultRoute));
#endif
- DLOG_IF(INFO, nfc_debug_enabled) << StringPrintf("%s : exit", __func__);
- return result;
- }
/*******************************************************************************
**
@@ -2217,30 +2085,7 @@ static void nfaConnectionCallback(uint8_t connEvent,
static jint nfcManager_getRemainingAidTableSize(JNIEnv*, jobject) {
return NFA_GetRemainingAidTableSize();
}
- /*******************************************************************************
- **
- ** Function: nfcManager_clearAidTable
- **
- ** Description: Clean all AIDs in routing table
- ** e: JVM environment.
- ** o: Java object.
- **
- *******************************************************************************/
- static bool nfcManager_clearAidTable(JNIEnv*, jobject) {
-#if (NXP_EXTNS == TRUE)
- /*In case of 66T/67T field on is observed as last field event once reader
- is removed from proximity, which will hold the transaction lock
- unnecessarily
- In such cases end the lock as it is not required*/
- if (((nfcFL.chipType == pn548C2) || (nfcFL.chipType == pn551)) &&
- pTransactionController->getCurTransactionRequestor() ==
- TRANSACTION_REQUESTOR(RF_FIELD_EVT)) {
- pTransactionController->transactionEnd(
- TRANSACTION_REQUESTOR(RF_FIELD_EVT));
- }
-#endif
- return RoutingManager::getInstance().clearAidTable();
- }
+
/*******************************************************************************
**
** Function: nfcManager_doRegisterT3tIdentifier
@@ -2393,7 +2238,8 @@ static void nfaConnectionCallback(uint8_t connEvent,
// sIsNfaEnabled indicates whether stack started successfully
if (sIsNfaEnabled) {
SecureElement::getInstance().initialize(getNative(e, o));
- RoutingManager::getInstance().initialize(getNative(e, o));
+ sRoutingInitialized =
+ RoutingManager::getInstance().initialize(getNative(e, o));
HciRFParams::getInstance().initialize();
MposManager::getInstance().initialize(getNative(e, o));
sIsSecElemSelected =
@@ -2832,7 +2678,8 @@ static void nfcManager_doFactoryReset(JNIEnv*, jobject) {
DLOG_IF(INFO, nfc_debug_enabled) << StringPrintf("%s: enter", __FUNCTION__);
nfcManager_enableDiscovery(NULL, NULL, mDiscParams.technologies_mask,
mDiscParams.enable_lptd, mDiscParams.reader_mode,
- mDiscParams.enable_p2p, mDiscParams.restart);
+ 0x00, mDiscParams.enable_p2p,
+ mDiscParams.restart);
}
void disableRfDiscovery() { nfcManager_disableDiscovery(NULL, NULL); }
@@ -2865,7 +2712,9 @@ static void nfcManager_doFactoryReset(JNIEnv*, jobject) {
*******************************************************************************/
static void nfcManager_enableDiscovery(
JNIEnv * e, jobject o, jint technologies_mask, jboolean enable_lptd,
- jboolean reader_mode, jboolean enable_p2p, jboolean restart) {
+ jboolean reader_mode,
+ __attribute__((unused)) jboolean enable_host_routing, jboolean enable_p2p,
+ jboolean restart) {
tNFA_STATUS status = NFA_STATUS_OK;
tNFA_STATUS stat = NFA_STATUS_OK;
tNFA_TECHNOLOGY_MASK tech_mask = DEFAULT_TECH_MASK;
@@ -3564,9 +3413,6 @@ static void nfcManager_doFactoryReset(JNIEnv*, jobject) {
DLOG_IF(INFO, nfc_debug_enabled)
<< StringPrintf("%s: timeout waiting for Os Dowload", __func__);
usleep(MAX_WAIT_TIME_FOR_RETRY * 1000000);
- e->CallVoidMethod(
- gNativeData->manager,
- android::gCachedNfcManagerNotifyJcosDownloadInProgress, true);
if (e->ExceptionCheck()) {
e->ExceptionClear();
DwpChannel::getInstance().forceClose();
@@ -3756,194 +3602,6 @@ static void nfcManager_doFactoryReset(JNIEnv*, jobject) {
return NULL;
}
- /*******************************************************************************
- **
- ** Function: nfcManager_doGetSecureElementList
- **
- ** Description: Get a list of secure element handles.
- ** e: JVM environment.
- ** o: Java object.
- **
- ** Returns: List of secure element handles.
- **
- *******************************************************************************/
- static jintArray nfcManager_doGetSecureElementList(JNIEnv * e, jobject) {
- DLOG_IF(INFO, nfc_debug_enabled) << StringPrintf("%s", __func__);
- return SecureElement::getInstance().getListOfEeHandles(e);
- }
-
- /*******************************************************************************
- **
- ** Function: nfcManager_doSelectSecureElement
- **
- ** Description: NFC controller starts routing data in listen mode.
- ** e: JVM environment.
- ** o: Java object.
- **
- ** Returns: None
- **
- *******************************************************************************/
- static void nfcManager_doSelectSecureElement(JNIEnv * e, jobject o,
- jint seId) {
- (void)e;
- (void)o;
- DLOG_IF(INFO, nfc_debug_enabled) << StringPrintf("%s: enter", __func__);
- bool stat = true;
-
- if (sIsSecElemSelected >= sIsSecElemDetected) {
- DLOG_IF(INFO, nfc_debug_enabled)
- << StringPrintf("%s: already selected", __func__);
- goto TheEnd;
- }
-
- PowerSwitch::getInstance().setLevel(PowerSwitch::FULL_POWER);
-
- if (sRfEnabled) {
- // Stop RF Discovery if we were polling
- startRfDiscovery(false);
- }
-
- stat = SecureElement::getInstance().activate(seId);
- if (stat) {
- SecureElement::getInstance().routeToSecureElement();
- sIsSecElemSelected++;
- }
-
- startRfDiscovery(true);
- PowerSwitch::getInstance().setModeOn(PowerSwitch::SE_ROUTING);
- TheEnd:
- DLOG_IF(INFO, nfc_debug_enabled) << StringPrintf("%s: exit", __func__);
- }
-
- /*******************************************************************************
- **
- ** Function: nfcManager_activateSecureElement
- **
- ** Description: This function shall activate the SE as per given
- *identifier.
- ** e: JVM environment.
- ** o: Java object.
- ** seId: Secure element identifier
- **
- ** Returns: None
- **
- *******************************************************************************/
- static void nfcManager_activateSecureElement(JNIEnv * e, jobject o,
- jint seId) {
- (void)e;
- (void)o;
- DLOG_IF(INFO, nfc_debug_enabled) << StringPrintf("%s: enter", __func__);
- bool stat;
- int maxRetryCount = 3;
-
- SecureElement::getInstance().deactivate(seId);
- DLOG_IF(INFO, nfc_debug_enabled)
- << StringPrintf("%s: Deactivated", __func__);
- do {
- stat = SecureElement::getInstance().activate(seId);
- DLOG_IF(INFO, nfc_debug_enabled)
- << StringPrintf("%s: Activate status %d", __func__, stat);
- } while (!stat && maxRetryCount-- > 0);
-
- DLOG_IF(INFO, nfc_debug_enabled) << StringPrintf("%s: exit", __func__);
- }
-
- /*******************************************************************************
- **
- ** Function: nfcManager_doSetSEPowerOffState
- **
- ** Description: NFC controller enable/disabe card emulation in power off
- ** state from EE.
- ** e: JVM environment.
- ** o: Java object.
- **
- ** Returns: None
- **
- *******************************************************************************/
- static void nfcManager_doSetSEPowerOffState(JNIEnv * e, jobject o, jint seId,
- jboolean enable) {
- (void)e;
- (void)o;
- tNFA_HANDLE ee_handle;
- uint8_t power_state_mask = ~NFA_EE_PWR_STATE_SWITCH_OFF;
-
- if (enable == true) {
- power_state_mask = NFA_EE_PWR_STATE_SWITCH_OFF;
- }
-
- ee_handle = SecureElement::getInstance().getEseHandleFromGenericId(seId);
-
- if (sRfEnabled) {
- // Stop RF Discovery if we were polling
- startRfDiscovery(false);
- }
-
- tNFA_STATUS status = NFA_AddEePowerState(ee_handle, power_state_mask);
-
- // Commit the routing configuration
- status |= NFA_EeUpdateNow();
-
- if (status != NFA_STATUS_OK)
- LOG(ERROR) << StringPrintf("Failed to commit routing configuration");
-
- startRfDiscovery(true);
-
- // TheEnd: /*commented to eliminate warning label
- // defined but not used*/
- DLOG_IF(INFO, nfc_debug_enabled) << StringPrintf("%s: exit", __func__);
- }
-
- /*******************************************************************************
- **
- ** Function: nfcManager_GetDefaultSE
- **
- ** Description: Get default Secure Element.
- **
- **
- ** Returns: Returns 0.
- **
- *******************************************************************************/
- static jint nfcManager_GetDefaultSE(JNIEnv * e, jobject o) {
- (void)e;
- (void)o;
- unsigned long num = 0;
- if (NfcConfig::hasKey(NAME_NXP_DEFAULT_SE)) {
- num = NfcConfig::getUnsigned(NAME_NXP_DEFAULT_SE);
- }
- DLOG_IF(INFO, nfc_debug_enabled)
- << StringPrintf("%lu: nfcManager_GetDefaultSE", num);
- return num;
- }
-
- static jint nfcManager_getSecureElementTechList(JNIEnv * e, jobject o) {
- (void)e;
- (void)o;
- uint8_t sak;
- jint tech = 0x00;
- DLOG_IF(INFO, nfc_debug_enabled)
- << StringPrintf("nfcManager_getSecureElementTechList -Enter");
- sak = HciRFParams::getInstance().getESeSak();
- bool isTypeBPresent = HciRFParams::getInstance().isTypeBSupported();
-
- DLOG_IF(INFO, nfc_debug_enabled) << StringPrintf(
- "nfcManager_getSecureElementTechList - sak is %0x", sak);
-
- if (sak & 0x08) {
- tech |= TARGET_TYPE_MIFARE_CLASSIC;
- }
-
- if (sak & 0x20) {
- tech |= NFA_TECHNOLOGY_MASK_A;
- }
-
- if (isTypeBPresent == true) {
- tech |= NFA_TECHNOLOGY_MASK_B;
- }
- DLOG_IF(INFO, nfc_debug_enabled) << StringPrintf(
- "nfcManager_getSecureElementTechList - tech is %0x", tech);
- return tech;
- }
-
static jintArray nfcManager_getActiveSecureElementList(JNIEnv * e,
jobject o) {
(void)e;
@@ -3951,174 +3609,6 @@ static void nfcManager_doFactoryReset(JNIEnv*, jobject) {
return SecureElement::getInstance().getActiveSecureElementList(e);
}
- static void nfcManager_setSecureElementListenTechMask(JNIEnv * e, jobject o,
- jint tech_mask) {
- (void)e;
- (void)o;
- DLOG_IF(INFO, nfc_debug_enabled) << StringPrintf("%s: ENTER", __func__);
- // tNFA_STATUS status; /*commented to eliminate unused
- // variable warning*/
-
- if (sRfEnabled) {
- // Stop RF Discovery if we were polling
- startRfDiscovery(false);
- }
- SecureElement::getInstance().setEseListenTechMask(tech_mask);
-
- startRfDiscovery(true);
-
- DLOG_IF(INFO, nfc_debug_enabled) << StringPrintf("%s: EXIT", __func__);
- }
-
- static jbyteArray nfcManager_getSecureElementUid(JNIEnv * e, jobject o) {
- jbyteArray jbuff = NULL;
- uint8_t bufflen = 0;
- uint8_t buf[16] = {
- 0,
- };
-
- DLOG_IF(INFO, nfc_debug_enabled)
- << StringPrintf("nfcManager_getSecureElementUid -Enter");
- HciRFParams::getInstance().getESeUid(&buf[0], &bufflen);
- if (bufflen > 0) {
- jbuff = e->NewByteArray(bufflen);
- e->SetByteArrayRegion(jbuff, 0, bufflen, (jbyte*)buf);
- }
- return jbuff;
- }
-
- static tNFA_STATUS nfcManager_setEmvCoPollProfile(
- JNIEnv * e, jobject o, jboolean enable, jint route) {
- tNFA_STATUS status = NFA_STATUS_FAILED;
- tNFA_TECHNOLOGY_MASK tech_mask = 0;
-
- LOG(ERROR) << StringPrintf(
- "In nfcManager_setEmvCoPollProfile enable = 0x%x route = 0x%x", enable,
- route);
- /* Stop polling */
- if (isDiscoveryStarted()) {
- // Stop RF discovery to reconfigure
- startRfDiscovery(false);
- }
-
- status = EmvCo_dosetPoll(enable);
- if (status != NFA_STATUS_OK) {
- LOG(ERROR) << StringPrintf("%s: fail enable polling; error=0x%X",
- __func__, status);
- goto TheEnd;
- }
-
- if (enable) {
- if (route == 0x00) {
- /* DH enable polling for A and B*/
- tech_mask = NFA_TECHNOLOGY_MASK_A | NFA_TECHNOLOGY_MASK_B;
- } else if (route == 0x01) {
- /* UICC is end-point at present not supported by FW */
- /* TBD : Get eeinfo (use handle appropirately, depending up
- * on it enable the polling */
- } else if (route == 0x02) {
- /* ESE is end-point at present not supported by FW */
- /* TBD : Get eeinfo (use handle appropirately, depending up
- * on it enable the polling */
- } else {
- }
- } else {
- if (NfcConfig::hasKey(NAME_POLLING_TECH_MASK)) {
- tech_mask = NfcConfig::getUnsigned(NAME_POLLING_TECH_MASK);
- }
- }
-
- DLOG_IF(INFO, nfc_debug_enabled)
- << StringPrintf("%s: enable polling", __func__);
- {
- SyncEventGuard guard(sNfaEnableDisablePollingEvent);
- status = NFA_EnablePolling(tech_mask);
- if (status == NFA_STATUS_OK) {
- DLOG_IF(INFO, nfc_debug_enabled)
- << StringPrintf("%s: wait for enable event", __func__);
- sNfaEnableDisablePollingEvent.wait(); // wait for NFA_POLL_ENABLED_EVT
- } else {
- LOG(ERROR) << StringPrintf("%s: fail enable polling; error=0x%X",
- __func__, status);
- }
- }
-
- TheEnd:
- /* start polling */
- if (!isDiscoveryStarted()) {
- // Start RF discovery to reconfigure
- startRfDiscovery(true);
- }
- return status;
- }
-
- /*******************************************************************************
- **
- ** Function: nfcManager_doDeselectSecureElement
- **
- ** Description: NFC controller stops routing data in listen mode.
- ** e: JVM environment.
- ** o: Java object.
- **
- ** Returns: None
- **
- *******************************************************************************/
- static void nfcManager_doDeselectSecureElement(JNIEnv * e, jobject o,
- jint seId) {
- (void)e;
- (void)o;
- DLOG_IF(INFO, nfc_debug_enabled) << StringPrintf("%s: enter", __func__);
- bool stat = false;
- bool bRestartDiscovery = false;
-
- if (!sIsSecElemSelected) {
- LOG(ERROR) << StringPrintf("%s: already deselected", __func__);
- goto TheEnd2;
- }
-
- if (PowerSwitch::getInstance().getLevel() == PowerSwitch::LOW_POWER) {
- DLOG_IF(INFO, nfc_debug_enabled)
- << StringPrintf("%s: do not deselect while power is OFF", __func__);
- // sIsSecElemSelected = false;
- sIsSecElemSelected--;
- goto TheEnd;
- }
-
- if (sRfEnabled) {
- // Stop RF Discovery if we were polling
- startRfDiscovery(false);
- bRestartDiscovery = true;
- }
- // sIsSecElemSelected = false;
- // sIsSecElemSelected--;
-
- // if controller is not routing to sec elems AND there is no pipe connected,
- // then turn off the sec elems
- if (SecureElement::getInstance().isBusy() == false) {
- // SecureElement::getInstance().deactivate (0xABCDEF);
- stat = SecureElement::getInstance().deactivate(seId);
- if (stat) {
- sIsSecElemSelected--;
- // RoutingManager::getInstance().commitRouting();
- }
- }
-
- TheEnd:
- /*
- * conditional check is added to avoid multiple dicovery cmds
- * at the time of NFC OFF in progress
- */
- if ((gGeneralPowershutDown != NFC_MODE_OFF) && bRestartDiscovery)
- startRfDiscovery(true);
-
- // if nothing is active after this, then tell the controller to power down
- if (!PowerSwitch::getInstance().setModeOff(PowerSwitch::SE_ROUTING))
- PowerSwitch::getInstance().setLevel(PowerSwitch::LOW_POWER);
-
- TheEnd2:
- DLOG_IF(INFO, nfc_debug_enabled) << StringPrintf("%s: exit", __func__);
- }
-
/*******************************************************************************
**
** Function: nfcManager_getDefaultAidRoute
@@ -4157,8 +3647,8 @@ static void nfcManager_doFactoryReset(JNIEnv*, jobject) {
#if (NXP_EXTNS == TRUE)
if (NfcConfig::hasKey(NAME_DEFAULT_ROUTE))
num = NfcConfig::getUnsigned(NAME_DEFAULT_ROUTE);
- DLOG_IF(INFO, nfc_debug_enabled) << StringPrintf(
- "%s: enter; NAME_DEFAULT_ROUTE = %02lx", __func__, num);
+ DLOG_IF(INFO, nfc_debug_enabled)
+ << StringPrintf("%s: enter; NAME_DEFAULT_ROUTE = %02lx", __func__, num);
#endif
return num;
}
@@ -4185,6 +3675,41 @@ static void nfcManager_doFactoryReset(JNIEnv*, jobject) {
#if (NXP_EXTNS == TRUE)
/*******************************************************************************
**
+ ** Function: nfcManager_getDefaultFelicaCLTPowerState
+ **
+ ** Description: Get the default mifare CLT Power States.
+ ** e: JVM environment.
+ ** o: Java object.
+ **
+ ** Returns: Power State
+ **
+ *******************************************************************************/
+ static jint nfcManager_getDefaultFelicaCLTPowerState(JNIEnv * e, jobject o) {
+ unsigned long num = 0;
+ if (NfcConfig::hasKey(NAME_DEFAULT_FELICA_CLT_PWR_STATE))
+ num = NfcConfig::getUnsigned(NAME_DEFAULT_FELICA_CLT_PWR_STATE);
+ return num;
+ }
+ /*******************************************************************************
+ **
+ ** Function: nfcManager_getDefaultFelicaCLTRoute
+ **
+ ** Description: Get the default mifare CLT Route Entry.
+ ** e: JVM environment.
+ ** o: Java object.
+ ** mode: Not used.
+ **
+ ** Returns: None
+ **
+ *******************************************************************************/
+ static jint nfcManager_getDefaultFelicaCLTRoute(JNIEnv * e, jobject o) {
+ unsigned long num = 0;
+ if (NfcConfig::hasKey(NAME_DEFAULT_FELICA_CLT_ROUTE))
+ num = NfcConfig::getUnsigned(NAME_DEFAULT_FELICA_CLT_ROUTE);
+ return num;
+ }
+ /*******************************************************************************
+ **
** Function: nfcManager_getDefaultAidPowerState
**
** Description: Get the default Desfire Power States.
@@ -4220,6 +3745,12 @@ static void nfcManager_doFactoryReset(JNIEnv*, jobject) {
}
return num;
}
+
+ static int nfcManager_getDefaulGsmaPowerState(JNIEnv * e, jobject o) {
+ return 0;
+ // Commented as part of QSSI
+ // return RoutingManager::getInstance().mDefaultGsmaPowerState;
+ }
/*******************************************************************************
**
** Function: nfcManager_getDefaultMifareCLTPowerState
@@ -4238,71 +3769,6 @@ static void nfcManager_doFactoryReset(JNIEnv*, jobject) {
}
return num;
}
- /*******************************************************************************
- **
- ** Function: nfcManager_setDefaultTechRoute
- **
- ** Description: Setting Default Technology Routing
- ** e: JVM environment.
- ** o: Java object.
- ** seId: SecureElement Id
- ** tech_swithon: technology switch_on
- ** tech_switchoff: technology switch_off
- **
- ** Returns: None
- **
- *******************************************************************************/
- static void nfcManager_setDefaultTechRoute(JNIEnv * e, jobject o, jint seId,
- jint tech_switchon,
- jint tech_switchoff) {
- (void)e;
- (void)o;
- DLOG_IF(INFO, nfc_debug_enabled) << StringPrintf("%s: ENTER", __func__);
- // tNFA_STATUS status; /*commented to eliminate unused
- // variable warning*/
-
- if (sRfEnabled) {
- // Stop RF Discovery if we were polling
- startRfDiscovery(false);
- }
- RoutingManager::getInstance().setDefaultTechRouting(seId, tech_switchon,
- tech_switchoff);
- // start discovery.
- startRfDiscovery(true);
- }
-
- /*******************************************************************************
- **
- ** Function: nfcManager_setDefaultProtoRoute
- **
- ** Description: Setting Default Protocol Routing
- **
- ** e: JVM environment.
- ** o: Java object.
- ** seId: SecureElement Id
- ** proto_swithon: Protocol switch_on
- ** proto_switchoff: Protocol switch_off
- **
- ** Returns: None
- **
- *******************************************************************************/
- static void nfcManager_setDefaultProtoRoute(JNIEnv * e, jobject o, jint seId,
- jint proto_switchon,
- jint proto_switchoff) {
- (void)e;
- (void)o;
- DLOG_IF(INFO, nfc_debug_enabled) << StringPrintf("%s: ENTER", __func__);
- // tNFA_STATUS status; /*commented to eliminate unused
- // variable warning*/
- // if (sRfEnabled) {
- // // Stop RF Discovery if we were polling
- // startRfDiscovery (false);
- // }
- RoutingManager::getInstance().setDefaultProtoRouting(seId, proto_switchon,
- proto_switchoff);
- // start discovery.
- // startRfDiscovery (true);
- }
/*******************************************************************************
**
@@ -4333,25 +3799,6 @@ static void nfcManager_doFactoryReset(JNIEnv*, jobject) {
/*******************************************************************************
**
- ** Function: nfcManager_isVzwFeatureEnabled
- **
- ** Description: Check vzw feature is enabled or not
- **
- ** Returns: True if the VZW_FEATURE_ENABLE is set.
- **
- *******************************************************************************/
- static bool nfcManager_isVzwFeatureEnabled(JNIEnv * e, jobject o) {
- bool mStat = false;
-
- if (NfcConfig::hasKey("VZW_FEATURE_ENABLE")) {
- mStat = NfcConfig::getUnsigned("VZW_FEATURE_ENABLE");
- } else {
- mStat = false;
- }
- return mStat;
- }
- /*******************************************************************************
- **
** Function: nfcManager_isNfccBusy
**
** Description: Check If NFCC is busy
@@ -4377,6 +3824,26 @@ static void nfcManager_doFactoryReset(JNIEnv*, jobject) {
<< StringPrintf("%s: Exit statBusy : 0x%02x", __func__, statBusy);
return statBusy;
}
+ /*******************************************************************************
+ **
+ ** Function: nfcManager_changeDiscoveryTech
+ **
+ ** Description: set listen mode
+ ** e: JVM environment.l
+ ** o: Java object.
+ **
+ ** Returns: None.
+ **
+ *******************************************************************************/
+ static void nfcManager_changeDiscoveryTech(JNIEnv * e, jobject o,
+ jint pollTech, jint listenTech) {
+ DLOG_IF(INFO, nfc_debug_enabled)
+ << StringPrintf("Enter :%s pollTech = 0x%x, listenTech = 0x%x",
+ __func__, pollTech, listenTech);
+
+ // NFA_ChangeDiscoveryTech(pollTech, listenTech); --Commented as part of
+ // QSSI.
+ }
#endif
/*******************************************************************************
**
@@ -4436,21 +3903,6 @@ static void nfcManager_doFactoryReset(JNIEnv*, jobject) {
return JNI_TRUE;
}
- static jboolean nfcManager_doCheckJcopDlAtBoot(JNIEnv * e, jobject o) {
- unsigned int num = 0;
- DLOG_IF(INFO, nfc_debug_enabled) << StringPrintf("%s", __func__);
- if (NfcConfig::hasKey(NAME_NXP_JCOPDL_AT_BOOT_ENABLE)) {
- num = NfcConfig::getUnsigned(NAME_NXP_JCOPDL_AT_BOOT_ENABLE);
- if (num == 0x01) {
- return JNI_TRUE;
- } else {
- return JNI_FALSE;
- }
- } else {
- return JNI_FALSE;
- }
- }
-
/*******************************************************************************
**
** Function: nfcManager_doActivateLlcp
@@ -4610,89 +4062,6 @@ static void nfcManager_doFactoryReset(JNIEnv*, jobject) {
nat->tech_mask = mask;
}
-#if (NXP_EXTNS == TRUE)
- /*******************************************************************************
- **
- ** Function: nfcManager_getRouting
- **
- ** Description: Get Routing Table information.
- ** e: JVM environment.
- ** o: Java object.
- **
- ** Returns: Current routing Settings.
- **
- *******************************************************************************/
- static jbyteArray nfcManager_getRouting(JNIEnv * e, jobject o) {
- DLOG_IF(INFO, nfc_debug_enabled) << StringPrintf("%s : Enter", __func__);
- jbyteArray jbuff = NULL;
- if (sRfEnabled) {
- // Stop RF Discovery if we were polling
- startRfDiscovery(false);
- }
- SyncEventGuard guard(sNfaGetRoutingEvent);
- sRoutingBuffLen = 0;
- RoutingManager::getInstance().getRouting();
- sNfaGetRoutingEvent.wait();
- if (sRoutingBuffLen > 0) {
- jbuff = e->NewByteArray(sRoutingBuffLen);
- e->SetByteArrayRegion(jbuff, 0, sRoutingBuffLen, (jbyte*)sRoutingBuff);
- }
-
- startRfDiscovery(true);
- return jbuff;
- }
-
- /*******************************************************************************
- **
- ** Function: nfcManager_getNfcInitTimeout
- **
- ** Description: Gets the chip version.
- ** e: JVM environment.
- ** o: Java object.
- **
- ** Returns: timeout in seconds
- **
- *******************************************************************************/
- static int nfcManager_getNfcInitTimeout(JNIEnv * e, jobject o) {
- (void)e;
- (void)o;
- DLOG_IF(INFO, nfc_debug_enabled) << StringPrintf("%s: enter", __func__);
- unsigned long disc_timeout = 0;
- unsigned long session_id_timeout = 0;
- disc_timeout = 0;
- gNfcInitTimeout = 0;
- gdisc_timeout = 0;
-
- if (NfcConfig::hasKey(NAME_NXP_DEFAULT_NFCEE_DISC_TIMEOUT)) {
- disc_timeout =
- NfcConfig::getUnsigned(NAME_NXP_DEFAULT_NFCEE_DISC_TIMEOUT);
- } else {
- DLOG_IF(INFO, nfc_debug_enabled)
- << StringPrintf("NAME_NXP_DEFAULT_NFCEE_DISC_TIMEOUT not found");
- disc_timeout = 0;
- }
-
- if (NfcConfig::hasKey(NAME_NXP_DEFAULT_NFCEE_TIMEOUT)) {
- session_id_timeout =
- NfcConfig::getUnsigned(NAME_NXP_DEFAULT_NFCEE_TIMEOUT);
- } else {
- DLOG_IF(INFO, nfc_debug_enabled)
- << StringPrintf("NAME_NXP_DEFAULT_NFCEE_TIMEOUT not found");
- session_id_timeout = 0;
- }
-
- gNfcInitTimeout = (disc_timeout + session_id_timeout) * 1000;
- gdisc_timeout = disc_timeout * 1000;
-
- DLOG_IF(INFO, nfc_debug_enabled) << StringPrintf(
- " gNfcInitTimeout = %d: gdisc_timeout = %d "
- "nfcManager_getNfcInitTimeout",
- gNfcInitTimeout, gdisc_timeout);
- return gNfcInitTimeout;
- }
-
-#endif
-
/*******************************************************************************
**
** Function: nfcManager_doSetP2pTargetModes
@@ -4729,34 +4098,6 @@ static void nfcManager_doFactoryReset(JNIEnv*, jobject) {
PowerSwitch::POWER_STATE_OFF);
}
#if (NXP_EXTNS == TRUE)
- /*******************************************************************************
- **
- ** Function: nfcManager_doUpdateScreenState
- **
- ** Description: Update If any Pending screen state is present
- ** e: JVM environment.
- ** o: Java object.
- **
- ** Returns: None.
- **
- *******************************************************************************/
- static void nfcManager_doUpdateScreenState(JNIEnv * e, jobject o) {
- DLOG_IF(INFO, nfc_debug_enabled) << StringPrintf("%s: Enter ", __func__);
- if (nfcFL.nfcNxpEse && nfcFL.eseFL._ESE_ETSI_READER_ENABLE) {
- eScreenState_t last_screen_state_request;
-
- if (pendingScreenState == true) {
- DLOG_IF(INFO, nfc_debug_enabled)
- << StringPrintf("%s: pendingScreenState = true ", __func__);
- pendingScreenState = false;
- last_screen_state_request = get_lastScreenStateRequest();
- nfcManager_doSetScreenState(NULL, NULL, last_screen_state_request);
- } else {
- DLOG_IF(INFO, nfc_debug_enabled)
- << StringPrintf("%s: pendingScreenState = false ", __func__);
- }
- }
- }
/*******************************************************************************
**
** Function: restartUiccListen()
@@ -5088,6 +4429,27 @@ static void restartUiccListen(jint uiccSlot) {
return NfcConfig::getUnsigned(NAME_ISO_DEP_MAX_TRANSCEIVE, 261);
}
+ static jboolean nfcManager_doSetNfcSecure(JNIEnv * e, jobject o,
+ jboolean enable) {
+ RoutingManager& routingManager = RoutingManager::getInstance();
+ routingManager.setNfcSecure(enable);
+#if (NXP_EXTNS != TRUE)
+ bool rfEnabled = sRfEnabled;
+#endif
+ if (sRoutingInitialized) {
+#if (NXP_EXTNS != TRUE)
+ routingManager.disableRoutingToHost();
+ if (rfEnabled) startRfDiscovery(false);
+ routingManager.updateRoutingTable();
+ routingManager.enableRoutingToHost();
+ routingManager.commitRouting();
+ if (rfEnabled) startRfDiscovery(true);
+#else
+ routingManager.updateRoutingTable();
+#endif
+ }
+ return true;
+ }
/*****************************************************************************
**
** JNI functions for android-4.0.1_r1
@@ -5104,17 +4466,15 @@ static void restartUiccListen(jint uiccSlot) {
{"sendRawFrame", "([B)Z", (void*)nfcManager_sendRawFrame},
- {"doRouteAid", "([BIII)Z", (void*)nfcManager_routeAid},
+ {"routeAid", "([BIII)Z", (void*)nfcManager_routeAid},
- {"doUnrouteAid", "([B)Z", (void*)nfcManager_unrouteAid},
+ {"unrouteAid", "([B)Z", (void*)nfcManager_unrouteAid},
{"doSetRoutingEntry", "(IIII)Z", (void*)nfcManager_setRoutingEntry},
{"doClearRoutingEntry", "(I)Z", (void*)nfcManager_clearRoutingEntry},
- {"clearAidTable", "()Z", (void*)nfcManager_clearAidTable},
-
- {"setDefaultRoute", "(III)Z", (void*)nfcManager_setDefaultRoute},
+ {"setEmptyAidRoute", "(I)V", (void*)nfcManager_setEmptyAidRoute},
{"getAidTableSize", "()I", (void*)nfcManager_getAidTableSize},
@@ -5125,19 +4485,25 @@ static void restartUiccListen(jint uiccSlot) {
{"getDefaultDesfireRoute", "()I", (void*)nfcManager_getDefaultDesfireRoute},
- {"getDefaultMifareCLTRoute", "()I",
- (void*)nfcManager_getDefaultMifareCLTRoute},
{"readerPassThruMode", "(BB)[B", (void*)nfcManager_readerPassThruMode},
{"transceiveAppData", "([B)[B", (void*)nfcManager_transceiveAppData},
#if (NXP_EXTNS == TRUE)
+ {"getGsmaPwrState", "()I", (void*)nfcManager_getDefaulGsmaPowerState},
+
{"getDefaultAidPowerState", "()I",
(void*)nfcManager_getDefaultAidPowerState},
{"getDefaultDesfirePowerState", "()I",
(void*)nfcManager_getDefaultDesfirePowerState},
+ {"getDefaultMifareCLTRoute", "()I",
+ (void*)nfcManager_getDefaultMifareCLTRoute},
+
{"getDefaultMifareCLTPowerState", "()I",
(void*)nfcManager_getDefaultMifareCLTPowerState},
+ {"doChangeDiscoveryTech", "(II)V", (void*)nfcManager_changeDiscoveryTech},
+ {"doaccessControlForCOSU", "(I)I",
+ (void*)nfcManager_doaccessControlForCOSU},
#endif
{"doRegisterT3tIdentifier", "([B)I",
(void*)nfcManager_doRegisterT3tIdentifier},
@@ -5147,25 +4513,7 @@ static void restartUiccListen(jint uiccSlot) {
{"getLfT3tMax", "()I", (void*)nfcManager_getLfT3tMax},
- {"doEnableDiscovery", "(IZZZZ)V", (void*)nfcManager_enableDiscovery},
-
- {"doGetSecureElementList", "()[I",
- (void*)nfcManager_doGetSecureElementList},
-
- {"doSelectSecureElement", "(I)V", (void*)nfcManager_doSelectSecureElement},
-
- {"doActivateSecureElement", "(I)V",
- (void*)nfcManager_activateSecureElement},
-
- {"doDeselectSecureElement", "(I)V",
- (void*)nfcManager_doDeselectSecureElement},
-
- {"doSetSEPowerOffState", "(IZ)V", (void*)nfcManager_doSetSEPowerOffState},
- {"setDefaultTechRoute", "(III)V", (void*)nfcManager_setDefaultTechRoute},
-
- {"setDefaultProtoRoute", "(III)V", (void*)nfcManager_setDefaultProtoRoute},
-
- {"GetDefaultSE", "()I", (void*)nfcManager_GetDefaultSE},
+ {"doEnableDiscovery", "(IZZZZZ)V", (void*)nfcManager_enableDiscovery},
{"doCheckLlcp", "()Z", (void*)nfcManager_doCheckLlcp},
@@ -5208,52 +4556,25 @@ static void restartUiccListen(jint uiccSlot) {
{"doDump", "(Ljava/io/FileDescriptor;)V", (void*)nfcManager_doDump},
- {"getChipVer", "()I", (void*)nfcManager_getChipVer},
-
- {"JCOSDownload", "()I", (void*)nfcManager_doJcosDownload},
- {"doCommitRouting", "()V", (void*)nfcManager_doCommitRouting},
#if (NXP_EXTNS == TRUE)
- {"doSetNfcMode", "(I)V", (void*)nfcManager_doSetNfcMode},
-
{"setTransitConfig", "(Ljava/lang/String;)I",
(void*)nfcManager_setTransitConfig},
-
+ {"getDefaultFelicaCLTPowerState", "()I",
+ (void*)nfcManager_getDefaultFelicaCLTPowerState},
+ {"getDefaultFelicaCLTRoute", "()I",
+ (void*)nfcManager_getDefaultFelicaCLTRoute},
#endif
- {"doGetSecureElementTechList", "()I",
- (void*)nfcManager_getSecureElementTechList},
-
+ {"commitRouting", "()Z", (void*)nfcManager_doCommitRouting},
{"doGetActiveSecureElementList", "()[I",
(void*)nfcManager_getActiveSecureElementList},
-
- {"doGetSecureElementUid", "()[B", (void*)nfcManager_getSecureElementUid},
-
- {"setEmvCoPollProfile", "(ZI)I", (void*)nfcManager_setEmvCoPollProfile},
-
- {"doSetSecureElementListenTechMask", "(I)V",
- (void*)nfcManager_setSecureElementListenTechMask},
{"getNciVersion", "()I", (void*)nfcManager_doGetNciVersion},
{"doSetScreenState", "(I)V", (void*)nfcManager_doSetScreenState},
- {"doSetScreenOrPowerState", "(I)V",
- (void*)nfcManager_doSetScreenOrPowerState},
- // Factory Test Code
- {"doPrbsOn", "(IIII)V", (void*)nfcManager_doPrbsOn},
- {"doPrbsOff", "()V", (void*)nfcManager_doPrbsOff},
- // SWP self test
- {"SWPSelfTest", "(I)I", (void*)nfcManager_SWPSelfTest},
// check firmware version
{"getFWVersion", "()I", (void*)nfcManager_getFwVersion},
#if (NXP_EXTNS == TRUE)
- {"updateScreenState", "()V", (void*)nfcManager_doUpdateScreenState},
- {"doEnablep2p", "(Z)V", (void*)nfcManager_Enablep2p},
- {"doSetProvisionMode", "(Z)V", (void*)nfcManager_setProvisionMode},
- {"doGetRouting", "()[B", (void*)nfcManager_getRouting},
- {"getNfcInitTimeout", "()I", (void*)nfcManager_getNfcInitTimeout},
- {"isVzwFeatureEnabled", "()Z", (void*)nfcManager_isVzwFeatureEnabled},
{"isNfccBusy", "()Z", (void*)nfcManager_isNfccBusy},
#endif
- {"doSetEEPROM", "([B)V", (void*)nfcManager_doSetEEPROM},
// Factory Test Code
- {"doCheckJcopDlAtBoot", "()Z", (void*)nfcManager_doCheckJcopDlAtBoot},
{"doEnableDtaMode", "()V", (void*)nfcManager_doEnableDtaMode},
{"doDisableDtaMode", "()V", (void*)nfcManager_doDisableDtaMode},
{"doFactoryReset", "()V", (void*)nfcManager_doFactoryReset},
@@ -5267,8 +4588,8 @@ static void restartUiccListen(jint uiccSlot) {
{"setPreferredSimSlot", "(I)I", (void*)nfcManager_setPreferredSimSlot},
{"routeApduPattern", "(II[B[B)Z", (void*)nfcManager_routeApduPattern},
{"unrouteApduPattern", "([B)Z", (void*)nfcManager_unrouteApduPattern},
- {"doNfcSelfTest", "(I)I", (void*)nfcManager_nfcSelfTest}
#endif
+ {"doSetNfcSecure", "(Z)Z", (void*)nfcManager_doSetNfcSecure},
};
/*******************************************************************************
@@ -5529,33 +4850,6 @@ static void restartUiccListen(jint uiccSlot) {
/*******************************************************************************
**
- ** Function: nfcManager_getChipVer
- **
- ** Description: Gets the chip version.
- ** e: JVM environment.
- ** o: Java object.
- **
- ** Returns: None 0x00
- ** PN547C2 0x01
- ** PN65T 0x02 .
- **
- *******************************************************************************/
- static int nfcManager_getChipVer(JNIEnv * e, jobject o) {
- (void)e;
- (void)o;
- DLOG_IF(INFO, nfc_debug_enabled) << StringPrintf("%s: enter", __func__);
- unsigned long num = 0;
-
- if (NfcConfig::hasKey(NAME_NXP_NFC_CHIP)) {
- num = NfcConfig::getUnsigned(NAME_NXP_NFC_CHIP);
- }
- DLOG_IF(INFO, nfc_debug_enabled)
- << StringPrintf("%ld: nfcManager_getChipVer", num);
- return num;
- }
-
- /*******************************************************************************
- **
** Function: nfcManager_setTransitConfig
**
** Description: Set Transit Configuration
@@ -5630,121 +4924,6 @@ static void restartUiccListen(jint uiccSlot) {
DWP->doeSE_JcopDownLoadReset = doeSE_JcopDownLoadReset;
}
}
- /*******************************************************************************
- **
- ** Function: nfcManager_doJcosDownload
- **
- ** Description: start jcos download.
- ** e: JVM environment.
- ** o: Java object.
- **
- ** Returns: True if ok.
- **
- *******************************************************************************/
- static int nfcManager_doJcosDownload(JNIEnv * e, jobject o) {
- (void)e;
- (void)o;
- tNFA_STATUS status = NFA_STATUS_FAILED;
-#if (NXP_EXTNS == TRUE)
- if (nfcFL.nfcNxpEse) {
- DLOG_IF(INFO, nfc_debug_enabled) << StringPrintf("%s: enter", __func__);
- bool stat = false;
- int ret_val = -1;
- NFCSTATUS ese_status = NFA_STATUS_FAILED;
- p61_access_state_t p61_current_state = P61_STATE_INVALID;
- eScreenState_t last_screen_state_request = get_lastScreenStateRequest();
- SecureElement& se = SecureElement::getInstance();
-
- if (nfcFL.eseFL._ESE_JCOP_DWNLD_PROTECTION) {
- if (sIsDisabling || !sIsNfaEnabled || nfcManager_checkNfcStateBusy()) {
- return NFA_STATUS_FAILED;
- }
-
- ret_val = NFC_GetP61Status((void*)&p61_current_state);
- if (ret_val < 0) {
- DLOG_IF(INFO, nfc_debug_enabled)
- << StringPrintf("NFC_GetP61Status failed");
- return NFA_STATUS_FAILED;
- }
- if (p61_current_state & P61_STATE_JCP_DWNLD ||
- p61_current_state & P61_STATE_WIRED ||
- p61_current_state & P61_STATE_SPI ||
- p61_current_state & P61_STATE_SPI_PRIO) {
- return NFA_STATUS_BUSY;
- }
-
- if (sIsDisabling || !sIsNfaEnabled || nfcManager_checkNfcStateBusy()) {
- return NFA_STATUS_FAILED;
- }
-
- LOG(ERROR) << StringPrintf("%s: start JcopOs_Download 0x%X", __func__,
- p61_current_state);
-
- ret_val = NFC_SetP61Status((void*)&ese_status, JCP_DWNLD_START);
- if (ret_val < 0) {
- DLOG_IF(INFO, nfc_debug_enabled)
- << StringPrintf("NFC_SetP61Status failed");
- } else {
- if (ese_status != NFCSTATUS_SUCCESS) {
- DLOG_IF(INFO, nfc_debug_enabled)
- << StringPrintf("Denying to set Jcop OS Download state");
- } else {
- if (!pTransactionController->transactionAttempt(
- TRANSACTION_REQUESTOR(jcosDownload))) {
- LOG(ERROR) << StringPrintf(
- "%s: Transaction in progress. Returning", __func__);
- return NFA_STATUS_FAILED;
- }
- }
- }
- }
- if (sRfEnabled) {
- // Stop RF Discovery if we were polling
- startRfDiscovery(false);
- }
- DWPChannel_init(&Dwp);
- status = pJcopMgr->JCDnldInit(&Dwp);
- if (status != NFA_STATUS_OK) {
- LOG(ERROR) << StringPrintf("%s: JCDND initialization failed", __func__);
- } else {
- LOG(ERROR) << StringPrintf("%s: start JcopOs_Download", __func__);
- se.mDownloadMode = JCOP_DOWNLOAD;
- status = pJcopMgr->JCDnldStartDownload();
- }
- if (nfcFL.eseFL._ESE_JCOP_DWNLD_PROTECTION) {
- ret_val = NFC_SetP61Status((void*)&ese_status, JCP_DWP_DWNLD_COMPLETE);
- if (ret_val < 0) {
- DLOG_IF(INFO, nfc_debug_enabled) << StringPrintf(
- "NFC_SetP61Status failed Deinit and starting discovery");
- } else {
- if (ese_status != NFCSTATUS_SUCCESS) {
- DLOG_IF(INFO, nfc_debug_enabled) << StringPrintf(
- "Denying to set Jcop OS Download complete state");
- status = ese_status;
- }
- }
- }
- stat = pJcopMgr->JCDnldDeInit();
- if (nfcFL.eseFL._ESE_JCOP_DWNLD_PROTECTION) {
- pTransactionController->transactionEnd(
- TRANSACTION_REQUESTOR(jcosDownload));
- if (pendingScreenState == true) {
- pendingScreenState = false;
- last_screen_state_request = get_lastScreenStateRequest();
- nfcManager_doSetScreenState(NULL, NULL, last_screen_state_request);
- }
- }
- startRfDiscovery(true);
- se.mDownloadMode = NONE;
- DLOG_IF(INFO, nfc_debug_enabled)
- << StringPrintf("%s: exit; status =0x%X", __func__, status);
- } else {
- status = 0x0F;
- DLOG_IF(INFO, nfc_debug_enabled) << StringPrintf("%s: No p61", __func__);
- }
-#endif
- return status;
- }
#if (NXP_EXTNS == TRUE)
uint8_t getJCOPOS_UpdaterState() {
@@ -5777,10 +4956,11 @@ static void restartUiccListen(jint uiccSlot) {
}
#endif
- static void nfcManager_doCommitRouting(JNIEnv * e, jobject o) {
+ static jboolean nfcManager_doCommitRouting(JNIEnv * e, jobject o) {
(void)e;
(void)o;
DLOG_IF(INFO, nfc_debug_enabled) << StringPrintf("%s: enter", __func__);
+ bool status = false;
PowerSwitch::getInstance().setLevel(PowerSwitch::FULL_POWER);
PowerSwitch::getInstance().setModeOn(PowerSwitch::HOST_ROUTING);
#if (NXP_EXTNS == TRUE && NXP_NFCC_HCE_F == TRUE)
@@ -5794,7 +4974,7 @@ static void restartUiccListen(jint uiccSlot) {
/*Stop RF discovery to reconfigure*/
startRfDiscovery(false);
}
- RoutingManager::getInstance().commitRouting();
+ status = RoutingManager::getInstance().commitRouting();
startRfDiscovery(true);
#if (NXP_EXTNS == TRUE && NXP_NFCC_HCE_F == TRUE)
pTransactionController->transactionEnd(
@@ -5802,13 +4982,9 @@ static void restartUiccListen(jint uiccSlot) {
}
#endif
DLOG_IF(INFO, nfc_debug_enabled) << StringPrintf("%s: exit", __func__);
+ return status;
}
-#if (NXP_EXTNS == TRUE)
- static void nfcManager_doSetNfcMode(JNIEnv * e, jobject o, jint nfcMode) {
- /* Store the shutdown state */
- gGeneralPowershutDown = nfcMode;
- }
-#endif
+
bool isNfcInitializationDone() {
if (nfcFL.nfccFL._NFCEE_REMOVED_NTF_RECOVERY) {
return sIsNfaEnabled;
@@ -6101,47 +5277,6 @@ static void restartUiccListen(jint uiccSlot) {
}
#if (NXP_EXTNS == TRUE)
/*******************************************************************************
- **
- ** Function: nfcManager_doSetScreenOrPowerState
- ** This function combines both screen state and power
- *state(ven power) values.
- **
- ** Description: Set screen or power state
- ** e: JVM environment.
- ** o: Java object.
- ** state:represents power or screen state (0-3 screen
- *state),6 (power on),7(power off)
- **
- ** Returns: None
- **
- *******************************************************************************/
- static void nfcManager_doSetScreenOrPowerState(JNIEnv * e, jobject o,
- jint state) {
- LOG(ERROR) << StringPrintf("%s: Enter", __func__);
- if ((state & NFA_SCREEN_STATE_MASK) <=
- NFA_SCREEN_STATE_ON_UNLOCKED) // SCREEN_STATE
- nfcManager_doSetScreenState(e, o, state);
- else if ((state & NFA_SCREEN_STATE_MASK) ==
- VEN_POWER_STATE_ON) // POWER_ON NFC_OFF
- {
- nfcManager_doSetNfcMode(e, o, NFC_MODE_OFF);
- } else if ((state & NFA_SCREEN_STATE_MASK) ==
- VEN_POWER_STATE_OFF) // POWER_OFF
- {
- if (sIsNfaEnabled) {
- if (nfcFL.eseFL._ESE_JCOP_DWNLD_PROTECTION &&
- (SecureElement::getInstance().mDownloadMode == JCOP_DOWNLOAD)) {
- DwpChannel::getInstance().forceClose();
- }
- nfcManager_doSetNfcMode(e, o, NFC_MODE_ON); // POWER_OFF NFC_ON
- } else {
- nfcManager_doSetNfcMode(e, o, NFC_MODE_OFF); // POWER_OFF NFC_OFF
- }
- } else
- LOG(ERROR) << StringPrintf("%s: unknown screen or power state. state=%d",
- __func__, state);
- }
- /*******************************************************************************
**
** Function: nfcManager_isRequestPending()
**
@@ -6603,7 +5738,7 @@ bool update_transaction_stat(const char * req_handle, transaction_state_t req_st
nfcManager_enableDiscovery(
NULL, NULL, transaction_data.discovery_params.technologies_mask,
transaction_data.discovery_params.enable_lptd,
- transaction_data.discovery_params.reader_mode,
+ transaction_data.discovery_params.reader_mode, 0x00,
transaction_data.discovery_params.enable_p2p,
transaction_data.discovery_params.restart);
}
@@ -6809,31 +5944,6 @@ bool update_transaction_stat(const char * req_handle, transaction_state_t req_st
}
/*******************************************************************************
- **
- ** Function: nfcManager_setProvisionMode
- **
- ** Description: set/reset provision mode
- ** e: JVM environment.
- ** o: Java object.
- **
- ** Returns: None.
- **
- *******************************************************************************/
- static void nfcManager_setProvisionMode(JNIEnv * e, jobject o,
- jboolean provisionMode) {
- DLOG_IF(INFO, nfc_debug_enabled) << StringPrintf(
- "Enter :%s provisionMode = %d", __func__, provisionMode);
- sProvisionMode = provisionMode;
- NFA_setProvisionMode(provisionMode);
- // When disabling provisioning mode, make sure configuration of routing
- // table is also updated
- // this is required to make sure p2p is blocked during locked screen
- if (!provisionMode) {
- RoutingManager::getInstance().commitRouting();
- }
- }
-
- /*******************************************************************************
**
** Function: isActivatedTypeF
**
@@ -7169,15 +6279,6 @@ bool update_transaction_stat(const char * req_handle, transaction_state_t req_st
#endif
#if (NXP_EXTNS == TRUE)
- static void nfaNxpSelfTestNtfTimerCb(union sigval) {
- DLOG_IF(INFO, nfc_debug_enabled) << StringPrintf("%s", __func__);
- DLOG_IF(INFO, nfc_debug_enabled) << StringPrintf(
- "NXP SWP SelfTest : Can't get a notification about SWP Status!!");
- SyncEventGuard guard(sNfaNxpNtfEvent);
- sNfaNxpNtfEvent.notifyOne();
- SetCbStatus(NFA_STATUS_FAILED);
- }
-
/**********************************************************************************
**
** Function: performNfceeETSI12Config
@@ -7891,302 +6992,34 @@ bool update_transaction_stat(const char * req_handle, transaction_state_t req_st
return retStat;
}
- static void nfaNxpSelfTestNtfCallback(uint8_t event, uint16_t param_len,
- uint8_t * p_param) {
- (void)event;
- DLOG_IF(INFO, nfc_debug_enabled) << StringPrintf("%s", __func__);
-
- if (param_len == 0x05 &&
- p_param[3] == 00) // p_param[4] 0x00:SWP Link OK 0x03:SWP link dead.
- {
- DLOG_IF(INFO, nfc_debug_enabled)
- << StringPrintf("NXP SWP SelfTest : SWP Link OK ");
- SetCbStatus(NFA_STATUS_OK);
- } else {
- if (p_param[3] == 0x03)
- DLOG_IF(INFO, nfc_debug_enabled)
- << StringPrintf("NXP SWP SelfTest : SWP Link dead ");
- SetCbStatus(NFA_STATUS_FAILED);
- }
-
- switch (p_param[4]) { // information of PMUVCC.
- case 0x00:
- DLOG_IF(INFO, nfc_debug_enabled)
- << StringPrintf("NXP SWP SelfTest : No PMUVCC ");
- break;
- case 0x01:
- DLOG_IF(INFO, nfc_debug_enabled)
- << StringPrintf("NXP SWP SelfTest : PMUVCC = 1.8V ");
- break;
- case 0x02:
- DLOG_IF(INFO, nfc_debug_enabled)
- << StringPrintf("NXP SWP SelfTest : PMUVCC = 3.3V ");
- break;
- case 0x03:
- DLOG_IF(INFO, nfc_debug_enabled)
- << StringPrintf("NXP SWP SelfTest : PMUVCC = undetermined ");
- break;
- default:
- DLOG_IF(INFO, nfc_debug_enabled)
- << StringPrintf("NXP SWP SelfTest : unknown PMUVCC ");
- break;
- }
-
- SyncEventGuard guard(sNfaNxpNtfEvent);
- sNfaNxpNtfEvent.notifyOne();
- }
-
- static void nfcManager_doPrbsOn(JNIEnv * e, jobject o, jint prbs,
- jint hw_prbs, jint tech, jint rate) {
- (void)e;
- (void)o;
- DLOG_IF(INFO, nfc_debug_enabled) << StringPrintf("%s: enter", __func__);
- tNFA_STATUS status = NFA_STATUS_FAILED;
- // bool stat = false; /*commented to eliminate unused
- // variable warning*/
-
- if (!sIsNfaEnabled) {
- DLOG_IF(INFO, nfc_debug_enabled)
- << StringPrintf("NFC does not enabled!!");
- return;
- }
-
- if (sDiscoveryEnabled) {
- DLOG_IF(INFO, nfc_debug_enabled)
- << StringPrintf("Discovery must not be enabled for SelfTest");
- return;
- }
-
- if (tech < 0 || tech > 2) {
- DLOG_IF(INFO, nfc_debug_enabled)
- << StringPrintf("Invalid tech! please choose A or B or F");
- return;
- }
-
- if (rate < 0 || rate > 3) {
- DLOG_IF(INFO, nfc_debug_enabled) << StringPrintf(
- "Invalid bitrate! please choose 106 or 212 or 424 or 848");
- return;
- }
-
- // Technology to stream 0x00:TypeA 0x01:TypeB 0x02:TypeF
- // Bitrate 0x00:106kbps 0x01:212kbps 0x02:424kbps
- // 0x03:848kbps
- // prbs and hw_prbs 0x00 or 0x01 two extra parameters included
- // in case of pn548AD
- uint8_t param[4];
- memset(param, 0x00, sizeof(param));
- if (nfcFL.chipType != pn547C2) {
- param[0] = prbs;
- param[1] = hw_prbs;
- param[2] = tech; // technology
- param[3] = rate; // bitrate
- DLOG_IF(INFO, nfc_debug_enabled) << StringPrintf(
- "phNxpNciHal_getPrbsCmd: PRBS = %d HW_PRBS = %d", prbs, hw_prbs);
- } else {
- param[0] = tech;
- param[1] = rate;
- }
- switch (tech) {
- case 0x00:
- DLOG_IF(INFO, nfc_debug_enabled)
- << StringPrintf("phNxpNciHal_getPrbsCmd - NFC_RF_TECHNOLOGY_A");
- break;
- case 0x01:
- DLOG_IF(INFO, nfc_debug_enabled)
- << StringPrintf("phNxpNciHal_getPrbsCmd - NFC_RF_TECHNOLOGY_B");
- break;
- case 0x02:
- DLOG_IF(INFO, nfc_debug_enabled)
- << StringPrintf("phNxpNciHal_getPrbsCmd - NFC_RF_TECHNOLOGY_F");
- break;
- }
- switch (rate) {
- case 0x00:
- DLOG_IF(INFO, nfc_debug_enabled)
- << StringPrintf("phNxpNciHal_getPrbsCmd - NFC_BIT_RATE_106");
- break;
- case 0x01:
- DLOG_IF(INFO, nfc_debug_enabled)
- << StringPrintf("phNxpNciHal_getPrbsCmd - NFC_BIT_RATE_212");
- break;
- case 0x02:
- DLOG_IF(INFO, nfc_debug_enabled)
- << StringPrintf("phNxpNciHal_getPrbsCmd - NFC_BIT_RATE_424");
- break;
- case 0x03:
- DLOG_IF(INFO, nfc_debug_enabled)
- << StringPrintf("phNxpNciHal_getPrbsCmd - NFC_BIT_RATE_848");
- break;
- }
- // step2. PRBS Test stop : CORE RESET_CMD
- status = Nxp_SelfTest(NFC_CMD_TYPE_CORE_RESET, param); // CORE_RESET_CMD
- if (NFA_STATUS_OK != status) {
- DLOG_IF(INFO, nfc_debug_enabled)
- << StringPrintf("%s: CORE RESET_CMD Fail!", __func__);
- status = NFA_STATUS_FAILED;
- goto TheEnd;
- }
- // step3. PRBS Test stop : CORE_INIT_CMD
- status = Nxp_SelfTest(NFC_CMD_TYPE_CORE_INIT, param); // CORE_INIT_CMD
- if (NFA_STATUS_OK != status) {
- DLOG_IF(INFO, nfc_debug_enabled)
- << StringPrintf("%s: CORE_INIT_CMD Fail!", __func__);
- status = NFA_STATUS_FAILED;
- goto TheEnd;
- }
- // step4. : NXP_ACT_PROP_EXTN
- status =
- Nxp_SelfTest(NFC_CMD_TYPE_ACT_PROP_EXTN, param); // NXP_ACT_PROP_EXTN
- if (NFA_STATUS_OK != status) {
- DLOG_IF(INFO, nfc_debug_enabled)
- << StringPrintf("%s: NXP_ACT_PROP_EXTN Fail!", __func__);
- status = NFA_STATUS_FAILED;
- goto TheEnd;
- }
-
- status = Nxp_SelfTest(NFC_CMD_TYPE_PRBS_START, param);
- DLOG_IF(INFO, nfc_debug_enabled)
- << StringPrintf("%s: exit; status =0x%X", __func__, status);
-
- TheEnd:
- // Factory Test Code
- DLOG_IF(INFO, nfc_debug_enabled)
- << StringPrintf("%s: exit; status =0x%X", __func__, status);
- return;
- }
-
- static void nfcManager_doPrbsOff(JNIEnv * e, jobject o) {
- (void)e;
- (void)o;
- DLOG_IF(INFO, nfc_debug_enabled) << StringPrintf("%s: enter", __func__);
- tNFA_STATUS status = NFA_STATUS_FAILED;
- // bool stat = false; /*commented to eliminate unused
- // variable warning*/
- uint8_t param;
-
- if (!sIsNfaEnabled) {
- DLOG_IF(INFO, nfc_debug_enabled)
- << StringPrintf("NFC does not enabled!!");
- return;
- }
-
- if (sDiscoveryEnabled) {
- DLOG_IF(INFO, nfc_debug_enabled)
- << StringPrintf("Discovery must not be enabled for SelfTest");
- return;
- }
-
- // Factory Test Code
- // step1. PRBS Test stop : VEN RESET
- status = Nxp_SelfTest(NFC_CMD_TYPE_PRBS_STOP, &param); // VEN RESET
- if (NFA_STATUS_OK != status) {
- DLOG_IF(INFO, nfc_debug_enabled)
- << StringPrintf("step1. PRBS Test stop : VEN RESET Fail!");
- status = NFA_STATUS_FAILED;
- goto TheEnd;
- }
-
- TheEnd:
- // Factory Test Code
- DLOG_IF(INFO, nfc_debug_enabled)
- << StringPrintf("%s: exit; status =0x%X", __func__, status);
-
- return;
- }
-
- static jint nfcManager_SWPSelfTest(JNIEnv * e, jobject o, jint ch) {
- (void)e;
- (void)o;
- DLOG_IF(INFO, nfc_debug_enabled) << StringPrintf("%s: enter", __func__);
- tNFA_STATUS status = NFA_STATUS_FAILED;
- tNFA_STATUS regcb_stat = NFA_STATUS_FAILED;
- uint8_t param[1];
-
- if (!sIsNfaEnabled) {
- DLOG_IF(INFO, nfc_debug_enabled)
- << StringPrintf("NFC does not enabled!!");
- return status;
- }
-
- if (sDiscoveryEnabled) {
- DLOG_IF(INFO, nfc_debug_enabled)
- << StringPrintf("Discovery must not be enabled for SelfTest");
- return status;
- }
-
- if (ch < 0 || ch > 1) {
- DLOG_IF(INFO, nfc_debug_enabled)
- << StringPrintf("Invalid channel!! please choose 0 or 1");
- return status;
- }
-
- // step1. : CORE RESET_CMD
- status = Nxp_SelfTest(NFC_CMD_TYPE_CORE_RESET, param); // CORE_RESET_CMD
- if (NFA_STATUS_OK != status) {
- DLOG_IF(INFO, nfc_debug_enabled)
- << StringPrintf("step2. PRBS Test stop : CORE RESET_CMD Fail!");
- status = NFA_STATUS_FAILED;
- goto TheEnd;
- }
-
- // step2. : CORE_INIT_CMD
- status = Nxp_SelfTest(NFC_CMD_TYPE_CORE_INIT, param); // CORE_INIT_CMD
- if (NFA_STATUS_OK != status) {
- DLOG_IF(INFO, nfc_debug_enabled)
- << StringPrintf("step3. PRBS Test stop : CORE_INIT_CMD Fail!");
- status = NFA_STATUS_FAILED;
- goto TheEnd;
- }
-
- // step3. : NXP_ACT_PROP_EXTN
- status =
- Nxp_SelfTest(NFC_CMD_TYPE_ACT_PROP_EXTN, param); // NXP_ACT_PROP_EXTN
- if (NFA_STATUS_OK != status) {
- DLOG_IF(INFO, nfc_debug_enabled)
- << StringPrintf("step: NXP_ACT_PROP_EXTN Fail!");
- status = NFA_STATUS_FAILED;
- goto TheEnd;
- }
-
- regcb_stat = NFA_RegVSCback(
- true, nfaNxpSelfTestNtfCallback); // Register CallBack for NXP NTF
- if (NFA_STATUS_OK != regcb_stat) {
- DLOG_IF(INFO, nfc_debug_enabled)
- << StringPrintf("To Regist Ntf Callback is Fail!");
- goto TheEnd;
- }
-
- param[0] = ch; // SWP channel 0x00 : SWP1(UICC) 0x01:SWP2(eSE)
- status = Nxp_SelfTest(NFC_CMD_TYPE_SWP, param);
- if (NFA_STATUS_OK != status) {
- status = NFA_STATUS_FAILED;
- goto TheEnd;
- }
-
- {
- DLOG_IF(INFO, nfc_debug_enabled)
- << StringPrintf("NFC NXP SelfTest wait for Notificaiton");
- nfaNxpSelfTestNtfTimer.set(1000, nfaNxpSelfTestNtfTimerCb);
- SyncEventGuard guard(sNfaNxpNtfEvent);
- sNfaNxpNtfEvent.wait(); // wait for NXP Self NTF to come
- }
-
- status = GetCbStatus();
- if (NFA_STATUS_OK != status) {
- status = NFA_STATUS_FAILED;
- }
-
- TheEnd:
- if (NFA_STATUS_OK == regcb_stat) {
- regcb_stat = NFA_RegVSCback(
- false, nfaNxpSelfTestNtfCallback); // DeRegister CallBack for NXP NTF
- }
- nfaNxpSelfTestNtfTimer.kill();
- DLOG_IF(INFO, nfc_debug_enabled)
- << StringPrintf("%s: exit; status =0x%X", __func__, status);
- return status;
+#if (NXP_EXTNS == TRUE)
+ /*******************************************************************************
+ **
+ ** Function: nfcManager_doaccessControlForCOSU
+ **
+ ** Description: Access control for card OS update
+ **
+ ** Returns: NFA_STATUS_OK
+ **
+ *******************************************************************************/
+ static jint nfcManager_doaccessControlForCOSU(JNIEnv * e, jobject o,
+ jint mode) {
+ return NFA_STATUS_FAILED;
+ // Commented Following code as per QSSI.
+ // tNFA_STATUS stat = NFA_STATUS_OK;
+
+ // DLOG_IF(INFO, nfc_debug_enabled) << StringPrintf("%s: enter", __func__);
+ // if (mode == MODE_DEDICATED) {
+ // stat = nfcManager_doPartialInitialize(e,o);
+ // } else if(mode == MODE_NORMAL){
+ // stat = nfcManager_doPartialDeInitialize(e,o);
+ // } else {
+ // stat = NFA_STATUS_FAILED;
+ // }
+ // DLOG_IF(INFO, nfc_debug_enabled) << StringPrintf("%s: Exit", __func__);
+ // return stat;
}
+#endif
/*******************************************************************************
**
@@ -8267,29 +7100,6 @@ bool update_transaction_stat(const char * req_handle, transaction_state_t req_st
return version;
}
- static void nfcManager_doSetEEPROM(JNIEnv * e, jobject o, jbyteArray val) {
- (void)e;
- (void)o;
- (void)val;
- DLOG_IF(INFO, nfc_debug_enabled) << StringPrintf("%s: enter", __func__);
- tNFA_STATUS status = NFA_STATUS_FAILED;
- // bool stat = false; /*commented to eliminate
- // unused variable warning*/
- // uint8_t param; /*commented to eliminate
- // unused variable warning*/
-
- if (!sIsNfaEnabled) {
- DLOG_IF(INFO, nfc_debug_enabled)
- << StringPrintf("NFC does not enabled!!");
- return;
- }
-
- DLOG_IF(INFO, nfc_debug_enabled)
- << StringPrintf("%s: exit; status =0x%X", __func__, status);
-
- return;
- }
-
/*******************************************************************************
**
** Function: getUICC_RF_Param_SetSWPBitRate()
@@ -8998,188 +7808,6 @@ bool update_transaction_stat(const char * req_handle, transaction_state_t req_st
*******************************************************************************/
bool isLowRamDevice() { return sIsLowRamDevice; }
- /*
- * This API mainly used for Self-Test
- * */
- /*******************************************************************************
- **
- ** Function: configureListening
- **
- ** Description: Configure listen technologies
- **
- ** Returns: success/failure
- **
- *******************************************************************************/
- tNFA_STATUS configureListening(uint8_t aListenMask) {
- tNFA_STATUS stat = NFA_STATUS_FAILED;
- SecureElement& se = SecureElement::getInstance();
- {
- SyncEventGuard guard(se.mUiccListenEvent);
- stat = NFA_CeConfigureUiccListenTech(se.mActiveEeHandle, aListenMask);
- if (stat == NFA_STATUS_OK) {
- se.mUiccListenEvent.wait();
- if (!aListenMask) stat = NFA_DisableListening();
- } else {
- LOG(ERROR) << StringPrintf("fail to start UICC listen");
- }
- }
- return stat;
- }
-
- /*******************************************************************************
- **
- ** Function: configurePolling
- **
- ** Description: Configure polling technologies
- **
- ** Returns: success/failure
- **
- *******************************************************************************/
- tNFA_STATUS configurePolling(uint8_t aPollMask) {
- DLOG_IF(INFO, nfc_debug_enabled)
- << StringPrintf("%s: enter poll mask=0x%02X", __func__, aPollMask);
- tNFA_STATUS stat = NFA_STATUS_FAILED;
-
- if (aPollMask > 0) {
- SyncEventGuard guard(sNfaEnableDisablePollingEvent);
- DLOG_IF(INFO, nfc_debug_enabled) << StringPrintf("enable polling");
- stat = NFA_EnablePolling(aPollMask);
- if (stat == NFA_STATUS_OK) {
- DLOG_IF(INFO, nfc_debug_enabled)
- << StringPrintf("wait for enable event");
- sPollingEnabled = true;
- sNfaEnableDisablePollingEvent.wait(); // Wait for NFA_POLL_ENABLED_EVT.
- } else {
- LOG(ERROR) << StringPrintf("NFA_EnablePolling fail, error=0x%X", stat);
- }
- } else {
- SyncEventGuard guard(sNfaEnableDisablePollingEvent);
- DLOG_IF(INFO, nfc_debug_enabled) << StringPrintf("disable polling");
- stat = NFA_DisablePolling();
- if (stat == NFA_STATUS_OK) {
- sPollingEnabled = false;
- sNfaEnableDisablePollingEvent
- .wait(); // Wait for NFA_POLL_DISABLED_EVT.
- } else {
- LOG(ERROR) << StringPrintf("NFA_DisablePolling fail, error=0x%X", stat);
- }
- }
- if (aPollMask > 0) startRfDiscovery(true);
- DLOG_IF(INFO, nfc_debug_enabled) << StringPrintf("%s: exit", __func__);
- return stat;
- }
-
- /*******************************************************************************
- **
- ** Function: performRFTest
- **
- ** Description: SelfTest, Analog RF ON/OFF commands
- **
- ** Returns: success/failure
- **
- *******************************************************************************/
- tNFA_STATUS performRFTest(bool on) {
- tNFA_STATUS status = NFA_STATUS_FAILED;
- uint8_t aNumOfCmds = 0;
- uint8_t count = 0;
- uint8_t NFCInitCmdSeq[5] = {NFC_CMD_TYPE_CORE_RESET, NFC_CMD_TYPE_CORE_INIT,
- NFC_CMD_TYPE_ACT_PROP_EXTN};
- aNumOfCmds = sizeof(NFCInitCmdSeq);
- if (on) {
- NFCInitCmdSeq[3] = NFC_CMD_TYPE_NFCC_STANDBY_OFF;
- NFCInitCmdSeq[4] = NFC_CMD_TYPE_RF_ON;
- } else {
- NFCInitCmdSeq[3] = NFC_CMD_TYPE_RF_OFF;
- NFCInitCmdSeq[4] = NFC_CMD_TYPE_NFCC_STANDBY_ON;
- }
-
- do {
- status = Nxp_SelfTest(NFCInitCmdSeq[count], 0x00);
- } while ((status == NFA_STATUS_OK) && (++count < aNumOfCmds));
-
- return status;
- }
-
- /*******************************************************************************
- **
- ** Function: performTransacAB
- **
- ** Description: SelfTest SWP, PRBS
- **
- ** Returns: success/failure
- **
- *******************************************************************************/
- tNFA_STATUS performTransacAB(uint8_t aType) {
- tNFA_STATUS status = NFA_STATUS_FAILED;
- uint8_t val[][1] = {{0x03}, {0x63}};
- uint8_t len[] = {0x01, 0x01};
- uint8_t tech_mask = 0;
- uint8_t count = 0, addCnt = 0;
- tNFA_PMID addBuf[][2] = {{0xA0, 0x3F}, {0xA0, 0x44}};
- uint8_t aNumOfCmds = 0;
- uint8_t NFCInitCmdSeq[3] = {NFC_CMD_TYPE_CORE_RESET, NFC_CMD_TYPE_CORE_INIT,
- NFC_CMD_TYPE_ACT_PROP_EXTN};
- DLOG_IF(INFO, nfc_debug_enabled) << StringPrintf("%s: enter", __func__);
-
- configureListening(0x00); // Disable listen phase
- configurePolling(
- 0x00); // This is remove previous poll config as part of Nfc-ON
- if (aType == NFC_CMD_TYPE_TRANSAC_A) {
- tech_mask = NFA_TECHNOLOGY_MASK_A;
- } else {
- *val[1] = 0x43;
- tech_mask = NFA_TECHNOLOGY_MASK_A | NFA_TECHNOLOGY_MASK_B;
- }
-
- aNumOfCmds = sizeof(NFCInitCmdSeq);
- do {
- status = Nxp_SelfTest(NFCInitCmdSeq[count], 0x00);
- } while ((status == NFA_STATUS_OK) && (++count < aNumOfCmds));
- count = 0;
- if (status == NFA_STATUS_OK) {
- addCnt = sizeof(addBuf) / sizeof(addBuf[0]);
- while ((status == NFA_STATUS_OK) && (count < addCnt)) {
- status = NxpNfcUpdateEeprom(addBuf[count], len[count], val[count]);
- count++;
- }
- } else {
- LOG(ERROR) << StringPrintf("failed in to reset and init NFCC");
- }
- if (status == NFA_STATUS_OK) {
- uint8_t val68[] = {0x00};
- SyncEventGuard guard(sNfaSetConfigEvent);
- status = NFA_SetConfig(NXP_NFC_NCI_PACM_BIT_RATE, 1, val68);
- if (status == NFA_STATUS_OK) {
- if (sNfaSetConfigEvent.wait(2 * ONE_SECOND_MS)) {
- status = Nxp_SelfTest(NFC_CMD_TYPE_DISC_MAP, 0x00);
- } else {
- LOG(ERROR) << StringPrintf("Wait timeout");
- status = NFA_STATUS_FAILED;
- }
- } else {
- LOG(ERROR) << StringPrintf("failed to send set config command");
- }
- }
- if (status == NFA_STATUS_OK) {
- if ((status = configurePolling(tech_mask)) == NFA_STATUS_OK) {
- SyncEventGuard gaurd(mSelfTestTransacAB);
- if (mSelfTestTransacAB.wait(30 * ONE_SECOND_MS)) {
- DLOG_IF(INFO, nfc_debug_enabled)
- << StringPrintf("Received activated ntf");
- status = Nxp_SelfTest(NFC_CMD_TYPE_DEACTIVATE, 0x00);
- }
- } else {
- // Do nothing
- }
- } else {
- // Do nothing, enter in to normal polling mode
- }
- startRfDiscovery(true);
- DLOG_IF(INFO, nfc_debug_enabled)
- << StringPrintf("%s: exit status = 0X%02X", __func__, status);
- return status;
- }
-
/*******************************************************************************
**
** Function: activatedNtf_Cb
@@ -9194,7 +7822,35 @@ bool update_transaction_stat(const char * req_handle, transaction_state_t req_st
SyncEventGuard gaurd(mSelfTestTransacAB);
mSelfTestTransacAB.notifyOne();
}
-#endif
}
/* namespace android */
+/*******************************************************************************
+ **
+ ** Function: nfcManager_getUiccId()
+ **
+ ** Description:
+ **
+ ** Returns: success/failure
+ **
+ *******************************************************************************/
+jint nfcManager_getUiccId(jint uicc_slot) {
+ if ((uicc_slot == 0x00) || (uicc_slot == 0x01)) {
+ return 0x02;
+ } else if (uicc_slot == 0x02) {
+ return 0x04;
+ } else {
+ return 0xFF;
+ }
+}
+
+jint nfcManager_getUiccRoute(jint uicc_slot) {
+ if (uicc_slot == 0x01) {
+ return 0x402;
+ } else if (uicc_slot == 0x02) {
+ return 0x481;
+ } else {
+ return 0xFF;
+ }
+}
+#endif \ No newline at end of file
diff --git a/nci/jni/NativeSecureElement.cpp b/nci/jni/NativeSecureElement.cpp
index 6595500a..1873bec7 100755
--- a/nci/jni/NativeSecureElement.cpp
+++ b/nci/jni/NativeSecureElement.cpp
@@ -81,13 +81,8 @@ static const int EE_ERROR_INIT = -3;
** Returns: Handle of secure element. values < 0 represent failure.
**
*******************************************************************************/
-#if (NXP_EXTNS == TRUE)
-static jint nativeNfcSecureElement_doOpenSecureElementConnection(
- JNIEnv*, jobject, __attribute__((unused)) jint seId)
-#else
static jint nativeNfcSecureElement_doOpenSecureElementConnection(JNIEnv*,
jobject)
-#endif
{
DLOG_IF(INFO, nfc_debug_enabled) << StringPrintf("%s: enter", __func__);
bool stat = false;
@@ -492,8 +487,8 @@ static jboolean nativeNfcSecureElement_doResetSecureElement(JNIEnv*, jobject,
** Returns: True if ok.
**
*******************************************************************************/
-static jboolean nativeNfcSecureElement_doeSEChipResetSecureElement(JNIEnv*,
- jobject) {
+__attribute__((unused)) static jboolean
+nativeNfcSecureElement_doeSEChipResetSecureElement(JNIEnv*, jobject) {
bool stat = false;
NFCSTATUS status = NFCSTATUS_FAILED;
unsigned long num = 0x01;
@@ -616,19 +611,13 @@ static jbyteArray nativeNfcSecureElement_doTransceive(JNIEnv* e, jobject,
**
*****************************************************************************/
static JNINativeMethod gMethods[] = {
-#if (NXP_EXTNS == TRUE)
- {"doNativeOpenSecureElementConnection", "(I)I",
- (void*)nativeNfcSecureElement_doOpenSecureElementConnection},
-#else
{"doNativeOpenSecureElementConnection", "()I",
(void*)nativeNfcSecureElement_doOpenSecureElementConnection},
-#endif
{"doNativeDisconnectSecureElementConnection", "(I)Z",
(void*)nativeNfcSecureElement_doDisconnectSecureElementConnection},
{"doNativeResetSecureElement", "(I)Z",
(void*)nativeNfcSecureElement_doResetSecureElement},
- {"doNativeeSEChipResetSecureElement", "()Z",
- (void*)nativeNfcSecureElement_doeSEChipResetSecureElement},
+
{"doTransceive", "(I[B)[B", (void*)nativeNfcSecureElement_doTransceive},
{"doNativeGetAtr", "(I)[B", (void*)nativeNfcSecureElement_doGetAtr},
};
diff --git a/nci/jni/RoutingManager.cpp b/nci/jni/RoutingManager.cpp
index 3746b089..bc9403ee 100755
--- a/nci/jni/RoutingManager.cpp
+++ b/nci/jni/RoutingManager.cpp
@@ -74,20 +74,27 @@ const JNINativeMethod RoutingManager::sMethods[] = {
{"doGetDefaultRouteDestination", "()I",
(void*)RoutingManager::
com_android_nfc_cardemulation_doGetDefaultRouteDestination},
+ {"doGetOffHostEseDestination", "()[B",
+ (void*)RoutingManager::
+ com_android_nfc_cardemulation_doGetOffHostEseDestination},
+ {"doGetOffHostUiccDestination", "()[B",
+ (void*)RoutingManager::
+ com_android_nfc_cardemulation_doGetOffHostUiccDestination},
{"doGetDefaultOffHostRouteDestination", "()I",
(void*)RoutingManager::
com_android_nfc_cardemulation_doGetDefaultOffHostRouteDestination},
{"doGetAidMatchingMode", "()I",
(void*)RoutingManager::com_android_nfc_cardemulation_doGetAidMatchingMode},
- {"doGetAidMatchingPlatform", "()I",
+ {"doGetDefaultIsoDepRouteDestination", "()I",
(void*)RoutingManager::
- com_android_nfc_cardemulation_doGetAidMatchingPlatform}};
+ com_android_nfc_cardemulation_doGetDefaultIsoDepRouteDestination}};
uint16_t lastcehandle = 0;
// SCBR from host works only when App is in foreground
static const uint8_t SYS_CODE_PWR_STATE_HOST = 0x01;
static const uint16_t DEFAULT_SYS_CODE = 0xFEFE;
-
+extern jint nfcManager_getUiccId(jint uicc_slot);
+extern jint nfcManager_getUiccRoute(jint uicc_slot);
namespace android {
extern void checkforTranscation(uint8_t connEvent, void* eventData);
#if (NXP_EXTNS == TRUE)
@@ -114,13 +121,19 @@ RoutingManager::RoutingManager()
: mNativeData(NULL),
mDefaultEe(NFA_HANDLE_INVALID),
mHostListnTechMask(0),
- mEseListnTechMask(0),
mUiccListnTechMask(0),
mFwdFuntnEnable(true),
mAddAid(0),
mDefaultHCEFRspTimeout(5000) {
static const char fn[] = "RoutingManager::RoutingManager()";
DLOG_IF(INFO, nfc_debug_enabled) << StringPrintf("%s:enter", fn);
+ if (NfcConfig::hasKey(NAME_OFFHOST_ROUTE_UICC)) {
+ mOffHostRouteUicc = NfcConfig::getBytes(NAME_OFFHOST_ROUTE_UICC);
+ }
+
+ if (NfcConfig::hasKey(NAME_OFFHOST_ROUTE_ESE)) {
+ mOffHostRouteEse = NfcConfig::getBytes(NAME_OFFHOST_ROUTE_ESE);
+ }
mDefaultOffHostRoute =
NfcConfig::getUnsigned(NAME_DEFAULT_OFFHOST_ROUTE, 0x00);
@@ -152,6 +165,9 @@ RoutingManager::RoutingManager()
mSeTechMask = 0x00; // unused
mNfcFOnDhHandle = NFA_HANDLE_INVALID;
mIsScbrSupported = false;
+ mDefaultIsoDepRoute = NfcConfig::getUnsigned(NAME_DEFAULT_ISODEP_ROUTE, 0x0);
+ mOffHostAidRoutingPowerState =
+ NfcConfig::getUnsigned(NAME_OFFHOST_AID_ROUTE_PWR_STATE, 0x01);
DLOG_IF(INFO, nfc_debug_enabled) << StringPrintf("%s:exit", fn);
}
@@ -208,28 +224,42 @@ bool RoutingManager::initialize(nfc_jni_native_data* native) {
mHostListnTechMask = 0x07;
}
- if (NfcConfig::hasKey(NAME_NXP_ESE_LISTEN_TECH_MASK)) {
- mEseListnTechMask = NfcConfig::getUnsigned(NAME_NXP_ESE_LISTEN_TECH_MASK);
+ if (NfcConfig::hasKey(NAME_NXP_FWD_FUNCTIONALITY_ENABLE)) {
+ mFwdFuntnEnable = NfcConfig::getUnsigned(NAME_NXP_FWD_FUNCTIONALITY_ENABLE);
} else {
- mEseListnTechMask = 0x07;
+ mFwdFuntnEnable = false;
}
+ LOG(ERROR) << StringPrintf("%s: mFwdFuntnEnable=0x%X", fn, mFwdFuntnEnable);
+
if (NfcConfig::hasKey(NAME_UICC_LISTEN_TECH_MASK)) {
mUiccListnTechMask = NfcConfig::getUnsigned(NAME_UICC_LISTEN_TECH_MASK);
} else {
mUiccListnTechMask = 0x07;
}
- if (NfcConfig::hasKey(NAME_NXP_FWD_FUNCTIONALITY_ENABLE)) {
- mFwdFuntnEnable = NfcConfig::getUnsigned(NAME_NXP_FWD_FUNCTIONALITY_ENABLE);
+ if (NfcConfig::hasKey(NAME_DEFAULT_AID_ROUTE)) {
+ mDefaultIso7816SeID = NfcConfig::getUnsigned(NAME_DEFAULT_AID_ROUTE);
+ } else {
+ mDefaultIso7816SeID = 0xFF;
+ }
+
+ if (NfcConfig::hasKey(NAME_DEFAULT_AID_PWR_STATE)) {
+ mDefaultIso7816Powerstate =
+ NfcConfig::getUnsigned(NAME_DEFAULT_AID_PWR_STATE);
} else {
- mFwdFuntnEnable = 0x07;
+ mDefaultIso7816Powerstate = 0xFF;
}
+ LOG(ERROR) << StringPrintf("%s: >>>> mDefaultIso7816SeID=0x%X", fn,
+ mDefaultIso7816SeID);
+ LOG(ERROR) << StringPrintf("%s: >>>> mDefaultIso7816Powerstate=0x%X", fn,
+ mDefaultIso7816Powerstate);
+
if (NfcConfig::hasKey(NAME_NXP_DEFAULT_SE)) {
mDefaultEe = NfcConfig::getUnsigned(NAME_NXP_DEFAULT_SE);
} else {
- mDefaultEe = 0x02;
+ mDefaultEe = 0x01;
}
@@ -262,7 +292,45 @@ bool RoutingManager::initialize(nfc_jni_native_data* native) {
}
}
- getDefaultTechFRouteAndPowerState();
+ mDefaultFelicaRoute =
+ NfcConfig::getUnsigned(NAME_DEFAULT_FELICA_CLT_ROUTE, 0x00);
+
+ if (nfcFL.eseFL._ESE_FELICA_CLT) {
+ if (NfcConfig::hasKey(NAME_DEFAULT_NFCF_ROUTE)) {
+ num = NfcConfig::getUnsigned(NAME_DEFAULT_NFCF_ROUTE);
+ if (nfcFL.nfccFL._NFCC_DYNAMIC_DUAL_UICC &&
+ nfcFL.nfccFL._NFC_NXP_STAT_DUAL_UICC_WO_EXT_SWITCH) {
+ if ((num == 0x02 || num == 0x03) && sCurrentSelectedUICCSlot) {
+ mDefaultTechFSeID = getUiccRoute(sCurrentSelectedUICCSlot);
+ } else {
+ mDefaultTechFSeID =
+ ((num == 0x01)
+ ? ROUTE_LOC_ESE_ID
+ : ((num == 0x02)
+ ? SecureElement::getInstance().EE_HANDLE_0xF4
+ : ROUTE_LOC_UICC2_ID));
+ }
+ } else {
+ mDefaultTechFSeID =
+ ((num == 0x01)
+ ? ROUTE_LOC_ESE_ID
+ : ((num == 0x02) ? SecureElement::getInstance().EE_HANDLE_0xF4
+ : ROUTE_LOC_UICC2_ID));
+ }
+ } else {
+ mDefaultTechFSeID = getUiccRoute(sCurrentSelectedUICCSlot);
+ }
+
+ if (NfcConfig::hasKey(NAME_DEFAULT_FELICA_CLT_PWR_STATE)) {
+ num = NfcConfig::getUnsigned(NAME_DEFAULT_FELICA_CLT_PWR_STATE);
+ mDefaultTechFPowerstate = num;
+ } else {
+ mDefaultTechFPowerstate = 0x3F;
+ }
+ } else {
+ mDefaultTechFSeID = SecureElement::getInstance().EE_HANDLE_0xF4;
+ mDefaultTechFPowerstate = 0x3F;
+ }
if (NfcConfig::hasKey(NAME_NXP_HCEF_CMD_RSP_TIMEOUT_VALUE)) {
num = NfcConfig::getUnsigned(NAME_NXP_HCEF_CMD_RSP_TIMEOUT_VALUE);
@@ -301,7 +369,7 @@ bool RoutingManager::initialize(nfc_jni_native_data* native) {
if (nfaStat != NFA_STATUS_OK)
LOG(ERROR) << StringPrintf("Failed to register wildcard AID for DH");
}
- mRxDataBuffer.clear();
+ // mRxDataBuffer.clear();
#else
// setDefaultRouting();
#endif
@@ -683,80 +751,6 @@ void RoutingManager::setRouting(bool isHCEEnabled) {
if (nfaStat != NFA_STATUS_OK)
LOG(ERROR) << StringPrintf("Failed to commit routing configuration");
}
-/*This function takes the default AID route, protocol(ISO-DEP) route and
- * Tech(A&B) route as arguments in following format
- * -----------------------------------------------------------------------------------------------------------
- * | RFU(TechA/B) | RouteLocBit1 | RouteLocBit0 | ScreenOff | ScreenLock |
- * BatteryOff | SwitchOff | SwitchOn |
- * -----------------------------------------------------------------------------------------------------------
- * Route location is set as below
- * ----------------------------------------------
- * | RouteLocBit1 | RouteLocBit0 | RouteLocation|
- * ----------------------------------------------
- * | 0 | 0 | Host |
- * ----------------------------------------------
- * | 0 | 1 | eSE |
- * ----------------------------------------------
- * | 1 | 0 | Uicc1 |
- * ----------------------------------------------
- * | 1 | 1 | Uicc2 | => Valid if DYNAMIC_DUAL_UICC
- * is enabled
- * ----------------------------------------------
- * Based on these parameters, this function creates the protocol route entries/
- * technology route entries
- * which are required to be pushed to listen mode routing table using
- * NFA_EeSetDefaultProtoRouting/TechRouting
- */
-bool RoutingManager::setDefaultRoute(const int defaultRoute,
- const int protoRoute,
- const int techRoute) {
- static const char fn[] = "RoutingManager::setDefaultRoute";
- tNFA_STATUS nfaStat = NFA_STATUS_FAILED;
-
- DLOG_IF(INFO, nfc_debug_enabled) << StringPrintf(
- "%s: enter; defaultRoute:0x%2X protoRoute:0x%2X TechRoute:0x%2X "
- "HostListenMask:0x%X",
- fn, defaultRoute, protoRoute, techRoute, mHostListnTechMask);
-
- extractRouteLocationAndPowerStates(defaultRoute, protoRoute, techRoute);
-
-#if (NXP_EXTNS == TRUE)
- if (NFA_GetNCIVersion() == NCI_VERSION_2_0) {
- setEmptyAidEntry();
- }
-#endif
-
- if (mHostListnTechMask) {
- nfaStat = NFA_CeSetIsoDepListenTech(mHostListnTechMask & 0xB);
- if (nfaStat != NFA_STATUS_OK)
- LOG(ERROR) << StringPrintf("Failed to configure CE IsoDep technologies");
- nfaStat = NFA_CeRegisterAidOnDH(NULL, 0, stackCallback);
- if (nfaStat != NFA_STATUS_OK)
- LOG(ERROR) << StringPrintf("Failed to register wildcard AID for DH");
- }
-
- checkProtoSeID();
-
- initialiseTableEntries();
-
- compileProtoEntries();
-
- consolidateProtoEntries();
-
- setProtoRouting();
-
- compileTechEntries();
-
- consolidateTechEntries();
-
- setTechRouting();
-
- configureOffHostNfceeTechMask();
-
- DLOG_IF(INFO, nfc_debug_enabled) << StringPrintf("%s: exit", fn);
-
- return true;
-}
void RoutingManager::setCeRouteStrictDisable(uint32_t state) {
DLOG_IF(INFO, nfc_debug_enabled)
@@ -844,57 +838,14 @@ void RoutingManager::printMemberData() {
DLOG_IF(INFO, nfc_debug_enabled)
<< StringPrintf("%s: NXP_WIRED_MODE_RF_FIELD_ENABLE = 0x%0X;", __func__,
gWiredModeRfFieldEnable);
+ DLOG_IF(INFO, nfc_debug_enabled)
+ << StringPrintf("%s: NAME_DEFAULT_FELICA_CLT_ROUTE = 0x%0X;", __func__,
+ mDefaultFelicaRoute);
+ DLOG_IF(INFO, nfc_debug_enabled)
+ << StringPrintf("%s: NAME_DEFAULT_OFFHOST_ROUTE = 0x%0X;", __func__,
+ mDefaultOffHostRoute);
}
-/* extract route location and power states in defaultRoute,protoRoute &
- * techRoute in the following format
- * -----------------------------------------------------------------------------------------------------------
- * | | | ScreenOffLock | ScreenOff | ScreenLock | BatteryOff | SwitchOff |
- * SwitchOn |
- * -----------------------------------------------------------------------------------------------------------
- * *
- * -----------------------------------------------------------------------------------------------------------
- * | | | | | | RFU(TechA/B) | RouteLocBit1 | RouteLocBit0
- * -----------------------------------------------------------------------------------------------------------
- * to mDefaultIso7816SeID & mDefaultIso7816Powerstate
- * mDefaultIsoDepSeID & mDefaultIsoDepPowerstate
- * mDefaultTechASeID & mDefaultTechAPowerstate
- */
-void RoutingManager::extractRouteLocationAndPowerStates(const int defaultRoute,
- const int protoRoute,
- const int techRoute) {
- static const char fn[] = "RoutingManager::extractRouteLocationAndPowerStates";
- DLOG_IF(INFO, nfc_debug_enabled) << StringPrintf(
- "%s:mDefaultIso7816SeID:0x%2X mDefaultIsoDepSeID:0x%X mDefaultTechASeID "
- "0x%X",
- fn, defaultRoute & 0x0300, protoRoute & 0x0300, techRoute & 0x0300);
- mDefaultIso7816SeID = ((((defaultRoute & 0x0300) >> 8) == 0x00)
- ? ROUTE_LOC_HOST_ID
- : ((((defaultRoute & 0x0300) >> 8) == 0x01)
- ? ROUTE_LOC_ESE_ID
- : getUiccRouteLocId(defaultRoute)));
- mDefaultIso7816Powerstate = defaultRoute & 0x3F;
- DLOG_IF(INFO, nfc_debug_enabled) << StringPrintf(
- "%s:mDefaultIso7816SeID:0x%2u mDefaultIso7816Powerstate:0x%u", fn,
- mDefaultIso7816SeID, mDefaultIso7816Powerstate);
- mDefaultIsoDepSeID = ((((protoRoute & 0x0300) >> 8) == 0x00)
- ? ROUTE_LOC_HOST_ID
- : ((((protoRoute & 0x0300) >> 8) == 0x01)
- ? ROUTE_LOC_ESE_ID
- : getUiccRouteLocId(protoRoute)));
- mDefaultIsoDepPowerstate = protoRoute & 0x3F;
- DLOG_IF(INFO, nfc_debug_enabled) << StringPrintf(
- "%s:mDefaultIsoDepSeID:0x%2u mDefaultIsoDepPowerstate:0x%2u", fn,
- mDefaultIsoDepSeID, mDefaultIsoDepPowerstate);
- mDefaultTechASeID = ((((techRoute & 0x0300) >> 8) == 0x00)
- ? ROUTE_LOC_HOST_ID
- : ((((techRoute & 0x0300) >> 8) == 0x01)
- ? ROUTE_LOC_ESE_ID
- : getUiccRouteLocId(techRoute)));
- mDefaultTechAPowerstate = techRoute & 0x3F;
- DLOG_IF(INFO, nfc_debug_enabled) << StringPrintf(
- "%s:mDefaultTechASeID:0x%2u mDefaultTechAPowerstate:0x%2u", fn,
- mDefaultTechASeID, mDefaultTechAPowerstate);
-}
+
/* Based on the features enabled :- NXP_NFCC_DYNAMIC_DUAL_UICC,
* NFC_NXP_STAT_DUAL_UICC_WO_EXT_SWITCH & NFC_NXP_STAT_DUAL_UICC_EXT_SWITCH,
* Calculate the UICC route location ID.
@@ -917,496 +868,8 @@ uint16_t RoutingManager::getUiccRouteLocId(const int route) {
return SecureElement::getInstance().EE_HANDLE_0xF4;
}
-/* To check whether the route location for ISO-DEP protocol defined by user in
- * config file is actually connected or not
- * If not connected then set it to HOST by default*/
-void RoutingManager::checkProtoSeID(void) {
- static const char fn[] = "RoutingManager::checkProtoSeID";
- uint8_t isDefaultIsoDepSeIDPresent = 0;
- uint8_t isDefaultAidRoutePresent = 0;
- tNFA_HANDLE ActDevHandle = NFA_HANDLE_INVALID;
- unsigned long check_default_proto_se_id_req = 0;
- DLOG_IF(INFO, nfc_debug_enabled) << StringPrintf("%s: enter", fn);
- if (NfcConfig::hasKey(NAME_CHECK_DEFAULT_PROTO_SE_ID)) {
- check_default_proto_se_id_req =
- NfcConfig::getUnsigned(NAME_CHECK_DEFAULT_PROTO_SE_ID);
- DLOG_IF(INFO, nfc_debug_enabled)
- << StringPrintf("%s: CHECK_DEFAULT_PROTO_SE_ID - 0x%2lX ", fn,
- check_default_proto_se_id_req);
- } else {
- LOG(ERROR) << StringPrintf(
- "%s: CHECK_DEFAULT_PROTO_SE_ID not defined. Taking default value - "
- "0x%2lX",
- fn, check_default_proto_se_id_req);
- }
-
- if (check_default_proto_se_id_req == 0x01) {
- uint8_t count, seId = 0;
- tNFA_HANDLE ee_handleList[nfcFL.nfccFL._NFA_EE_MAX_EE_SUPPORTED];
- SecureElement::getInstance().getEeHandleList(ee_handleList, &count);
- DLOG_IF(INFO, nfc_debug_enabled)
- << StringPrintf("%s: count : %d", fn, count);
- for (int i = 0; ((count != 0) && (i < count)); i++) {
- seId = SecureElement::getInstance().getGenericEseId(ee_handleList[i]);
- DLOG_IF(INFO, nfc_debug_enabled)
- << StringPrintf("%s: seId : %d", fn, seId);
- ActDevHandle =
- SecureElement::getInstance().getEseHandleFromGenericId(seId);
- DLOG_IF(INFO, nfc_debug_enabled)
- << StringPrintf("%s: ActDevHandle : 0x%X", fn, ActDevHandle);
- if (mDefaultIsoDepSeID == ActDevHandle) {
- isDefaultIsoDepSeIDPresent = 1;
- }
- if (mDefaultIso7816SeID == ActDevHandle) {
- isDefaultAidRoutePresent = 1;
- }
- if (isDefaultIsoDepSeIDPresent && isDefaultAidRoutePresent) {
- break;
- }
- }
-
- DLOG_IF(INFO, nfc_debug_enabled) << StringPrintf(
- "%s:isDefaultIsoDepSeIDPresent:0x%X", fn, isDefaultIsoDepSeIDPresent);
- if (!isDefaultIsoDepSeIDPresent) {
- mDefaultIsoDepSeID = ROUTE_LOC_HOST_ID;
- mDefaultIsoDepPowerstate =
- PWR_SWTCH_ON_SCRN_UNLCK_MASK | PWR_SWTCH_ON_SCRN_LOCK_MASK;
- }
- if (!isDefaultAidRoutePresent) {
- mDefaultIso7816SeID = ROUTE_LOC_HOST_ID;
- mDefaultIso7816Powerstate =
- PWR_SWTCH_ON_SCRN_UNLCK_MASK | PWR_SWTCH_ON_SCRN_LOCK_MASK;
- }
- }
-
- DLOG_IF(INFO, nfc_debug_enabled) << StringPrintf("%s: exit", fn);
-}
-
-void RoutingManager::configureOffHostNfceeTechMask(void) {
- static const char fn[] = "RoutingManager::configureOffHostNfceeTechMask";
- tNFA_STATUS nfaStat = NFA_STATUS_FAILED;
- uint8_t seId = 0x00;
- uint8_t count = 0x00;
- tNFA_HANDLE preferredHandle = SecureElement::getInstance().EE_HANDLE_0xF4;
- tNFA_HANDLE defaultHandle = NFA_HANDLE_INVALID;
- tNFA_HANDLE ee_handleList[nfcFL.nfccFL._NFA_EE_MAX_EE_SUPPORTED];
-
- DLOG_IF(INFO, nfc_debug_enabled) << StringPrintf("%s: enter", fn);
-
- if (mDefaultEe & SecureElement::ESE_ID) // eSE
- {
- preferredHandle = ROUTE_LOC_ESE_ID;
- } else if ((mDefaultEe & SecureElement::UICC_ID) || (mDefaultEe & SecureElement::UICC2_ID)) //UICC
- {
- preferredHandle = ((sCurrentSelectedUICCSlot == 2) ? ROUTE_LOC_UICC2_ID : SecureElement::getInstance().EE_HANDLE_0xF4);
- }
-
- SecureElement::getInstance().getEeHandleList(ee_handleList, &count);
-
- for (uint8_t i = 0; ((count != 0) && (i < count)); i++) {
- seId = SecureElement::getInstance().getGenericEseId(ee_handleList[i]);
- defaultHandle =
- SecureElement::getInstance().getEseHandleFromGenericId(seId);
- DLOG_IF(INFO, nfc_debug_enabled) << StringPrintf(
- "%s: ee_handleList[%d] : 0x%X", fn, i, ee_handleList[i]);
- if (preferredHandle == defaultHandle) {
- break;
- }
- defaultHandle = NFA_HANDLE_INVALID;
- }
-
- if ((defaultHandle != NFA_HANDLE_INVALID) && (0 != mUiccListnTechMask)) {
- if(defaultHandle == SecureElement::EE_HANDLE_0xF3) {
- {
- SyncEventGuard guard(SecureElement::getInstance().mEseListenEvent);
- nfaStat = NFA_CeConfigureEseListenTech(defaultHandle, 0x00);
- if (nfaStat == NFA_STATUS_OK) {
- SecureElement::getInstance().mEseListenEvent.wait();
- } else
- LOG(ERROR) << StringPrintf("fail to start eSE listen");
- }
- {
- SyncEventGuard guard(SecureElement::getInstance().mEseListenEvent);
- nfaStat = NFA_CeConfigureEseListenTech(defaultHandle,
- (mUiccListnTechMask & 0x07));
- if (nfaStat == NFA_STATUS_OK) {
- SecureElement::getInstance().mEseListenEvent.wait();
- } else
- LOG(ERROR) << StringPrintf("fail to start eSE listen");
- }
- } else {
- {
- SyncEventGuard guard(SecureElement::getInstance().mUiccListenEvent);
- nfaStat = NFA_CeConfigureUiccListenTech(defaultHandle, 0x00);
- if (nfaStat == NFA_STATUS_OK) {
- SecureElement::getInstance().mUiccListenEvent.wait();
- } else
- LOG(ERROR) << StringPrintf("fail to start UICC listen");
- }
- {
- SyncEventGuard guard(SecureElement::getInstance().mUiccListenEvent);
- nfaStat = NFA_CeConfigureUiccListenTech(defaultHandle,
- (mUiccListnTechMask & 0x07));
- if (nfaStat == NFA_STATUS_OK) {
- SecureElement::getInstance().mUiccListenEvent.wait();
- } else
- LOG(ERROR) << StringPrintf("fail to start UICC listen");
- }
- }
- }
-
- DLOG_IF(INFO, nfc_debug_enabled) << StringPrintf("%s: exit", fn);
-}
-
-void RoutingManager::initialiseTableEntries(void) {
- static const char fn[] = "RoutingManager::initialiseTableEntries";
-
- DLOG_IF(INFO, nfc_debug_enabled) << StringPrintf("%s: enter", fn);
-
- /* Defined Protocol Masks
- * T1T 0x01
- * T2T 0x02
- * T3T 0x04
- * ISO-DEP 0x08
- * NFC-DEP 0x10
- * ISO-7816 0x20
- */
-
- mProtoTableEntries[PROTO_T3T_IDX].protocol = NFA_PROTOCOL_MASK_T3T;
- mProtoTableEntries[PROTO_ISODEP_IDX].protocol = NFA_PROTOCOL_MASK_ISO_DEP;
- if (NFA_GetNCIVersion() == NCI_VERSION_1_0) {
- mProtoTableEntries[PROTO_ISO7816_IDX].protocol = NFC_PROTOCOL_MASK_ISO7816;
- }
-
- mTechTableEntries[TECH_A_IDX].technology = NFA_TECHNOLOGY_MASK_A;
- mTechTableEntries[TECH_B_IDX].technology = NFA_TECHNOLOGY_MASK_B;
- mTechTableEntries[TECH_F_IDX].technology = NFA_TECHNOLOGY_MASK_F;
-
- for (int xx = 0; xx < AVAILABLE_PROTO_ENTRIES(); xx++) {
- mProtoTableEntries[xx].routeLoc = mTechTableEntries[xx].routeLoc = 0x00;
- mProtoTableEntries[xx].power = mTechTableEntries[xx].power = 0x00;
- mProtoTableEntries[xx].enable = mTechTableEntries[xx].enable = false;
- }
-
- mLmrtEntries[ROUTE_LOC_HOST_ID_IDX].nfceeID = ROUTE_LOC_HOST_ID;
- mLmrtEntries[ROUTE_LOC_ESE_ID_IDX].nfceeID = ROUTE_LOC_ESE_ID;
- mLmrtEntries[ROUTE_LOC_UICC1_ID_IDX].nfceeID =
- SecureElement::getInstance().EE_HANDLE_0xF4;
- mLmrtEntries[ROUTE_LOC_UICC2_ID_IDX].nfceeID = ROUTE_LOC_UICC2_ID;
-
- /*Initialize the table for all route location nfceeID*/
- for (int xx = 0; xx < MAX_ROUTE_LOC_ENTRIES; xx++) {
- mLmrtEntries[xx].proto_switch_on = mLmrtEntries[xx].tech_switch_on = 0x00;
- mLmrtEntries[xx].proto_switch_off = mLmrtEntries[xx].tech_switch_off = 0x00;
- mLmrtEntries[xx].proto_battery_off = mLmrtEntries[xx].tech_battery_off =
- 0x00;
- mLmrtEntries[xx].proto_screen_lock = mLmrtEntries[xx].tech_screen_lock =
- 0x00;
- mLmrtEntries[xx].proto_screen_off = mLmrtEntries[xx].tech_screen_off = 0x00;
- mLmrtEntries[xx].proto_screen_off_lock =
- mLmrtEntries[xx].tech_screen_off_lock = 0x00;
- }
- /*Get all the technologies supported by all the execution environments*/
- mTechSupportedByEse =
- SecureElement::getInstance().getSETechnology(ROUTE_LOC_ESE_ID);
- mTechSupportedByUicc1 = SecureElement::getInstance().getSETechnology(
- SecureElement::getInstance().EE_HANDLE_0xF4);
- mTechSupportedByUicc2 =
- SecureElement::getInstance().getSETechnology(ROUTE_LOC_UICC2_ID);
- DLOG_IF(INFO, nfc_debug_enabled) << StringPrintf(
- "%s: exit; mTechSupportedByEse:0x%0u mTechSupportedByUicc1:0x%0u "
- "mTechSupportedByUicc2:0x%0u",
- fn, mTechSupportedByEse, mTechSupportedByUicc1, mTechSupportedByUicc2);
-}
-
-bool RoutingManager::isDefaultIsoDepSupported() {
- unsigned long num = 0;
- bool status = false;
-
- if (NfcConfig::hasKey(NAME_DEFAULT_ROUTE))
- num = NfcConfig::getUnsigned(NAME_DEFAULT_ROUTE);
-
- switch (num) {
- case ROUTE_LOC_HOST_ID_IDX:
- status = ((mHostListnTechMask & 0x03) != 0x00) ? true : false;
- break;
- case ROUTE_LOC_ESE_ID_IDX:
- status = ((mEseListnTechMask & 0x03) != 0x00) ? true : false;
- break;
- case ROUTE_LOC_UICC1_ID_IDX:
- status = ((mUiccListnTechMask & 0x03) != 0x00) ? true : false;
- break;
- }
- return status;
-}
-/* Compilation of Proto Table entries strictly based on config file parameters
- * Each entry in proto table consistes of route location, protocol and power
- * state
- * */
-void RoutingManager::compileProtoEntries(void) {
- static const char fn[] = "RoutingManager::compileProtoEntries";
-
- DLOG_IF(INFO, nfc_debug_enabled) << StringPrintf("%s: enter", fn);
-
- /*Populate the entries on protocol table*/
- mProtoTableEntries[PROTO_T3T_IDX].routeLoc =
- ROUTE_LOC_HOST_ID; // T3T Proto always to HOST. For other EE used Tech F
- // routing
- mProtoTableEntries[PROTO_T3T_IDX].power =
- PWR_SWTCH_ON_SCRN_UNLCK_MASK; // Only Screen ON UNLOCK allowed
- /*Enable T3T only in case of NCI_VERSION_1_0 and is set in
- * HOST_LISTEN_TECH_MASK*/
- mProtoTableEntries[PROTO_T3T_IDX].enable =
- ((NFA_GetNCIVersion() == NCI_VERSION_1_0) &&
- ((mHostListnTechMask & 0x04) != 0x00))
- ? true
- : false;
-
- mProtoTableEntries[PROTO_ISODEP_IDX].routeLoc = mDefaultIsoDepSeID;
- mProtoTableEntries[PROTO_ISODEP_IDX].power =
- mCeRouteStrictDisable ? mDefaultIsoDepPowerstate
- : (mDefaultIsoDepPowerstate & POWER_STATE_MASK);
-
- mProtoTableEntries[PROTO_ISODEP_IDX].enable =
- (isDefaultIsoDepSupported() == true) ? true : false;
-
- if (NFA_GetNCIVersion() == NCI_VERSION_1_0) {
- mProtoTableEntries[PROTO_ISO7816_IDX].routeLoc = mDefaultIso7816SeID;
- mProtoTableEntries[PROTO_ISO7816_IDX].power =
- mCeRouteStrictDisable ? mDefaultIso7816Powerstate
- : (mDefaultIso7816Powerstate & POWER_STATE_MASK);
- mProtoTableEntries[PROTO_ISO7816_IDX].enable =
- (mDefaultIso7816SeID == ROUTE_LOC_HOST_ID)
- ? (((mHostListnTechMask & 0x03) != 0x00) ? true : false)
- : (true);
- }
- dumpTables(1);
-
- DLOG_IF(INFO, nfc_debug_enabled) << StringPrintf("%s: exit", fn);
-}
-
-/* libnfc-nci takes protocols for each power-state for single route location
- * The previous protocols set will be overwritten by new protocols set by
- * NFA_EeSetDefaultProtoRouting
- * So consolidate all the protocols/power state for a given NFCEE ID's
- * For example:
- * When PROTOCOL(ISO-DEP) and AID default route(ISO7816) set to same EE then
- * set (ISO-DEP | ISO-7816) to that EE.
- */
-void RoutingManager::consolidateProtoEntries(void) {
- static const char fn[] = "RoutingManager::consolidateProtoEntries";
-
- DLOG_IF(INFO, nfc_debug_enabled) << StringPrintf("%s: enter", fn);
-
- int index = -1;
-
- for (int xx = 0; xx < AVAILABLE_PROTO_ENTRIES(); xx++) {
- if (mProtoTableEntries[xx].enable) {
- switch (mProtoTableEntries[xx].routeLoc) {
- case ROUTE_LOC_HOST_ID:
- index = ROUTE_LOC_HOST_ID_IDX;
- break;
- case ROUTE_LOC_ESE_ID:
- index = ROUTE_LOC_ESE_ID_IDX;
- break;
- case ROUTE_LOC_UICC1_ID:
- case ROUTE_LOC_UICC1_ID_NCI2_0:
- index = ROUTE_LOC_UICC1_ID_IDX;
- break;
- case ROUTE_LOC_UICC2_ID:
- index = ROUTE_LOC_UICC2_ID_IDX;
- break;
- }
- if (index != -1) {
- mLmrtEntries[index].proto_switch_on =
- (mLmrtEntries[index].proto_switch_on) |
- ((mProtoTableEntries[xx].power & PWR_SWTCH_ON_SCRN_UNLCK_MASK)
- ? mProtoTableEntries[xx].protocol
- : 0);
- mLmrtEntries[index].proto_switch_off =
- (mLmrtEntries[index].proto_switch_off) |
- ((mProtoTableEntries[xx].power & PWR_SWTCH_OFF_MASK)
- ? mProtoTableEntries[xx].protocol
- : 0);
- mLmrtEntries[index].proto_battery_off =
- (mLmrtEntries[index].proto_battery_off) |
- ((mProtoTableEntries[xx].power & PWR_BATT_OFF_MASK)
- ? mProtoTableEntries[xx].protocol
- : 0);
- mLmrtEntries[index].proto_screen_lock =
- (mLmrtEntries[index].proto_screen_lock) |
- ((mProtoTableEntries[xx].power & PWR_SWTCH_ON_SCRN_LOCK_MASK)
- ? mProtoTableEntries[xx].protocol
- : 0);
- mLmrtEntries[index].proto_screen_off =
- (mLmrtEntries[index].proto_screen_off) |
- ((mProtoTableEntries[xx].power & PWR_SWTCH_ON_SCRN_OFF_MASK)
- ? mProtoTableEntries[xx].protocol
- : 0);
- mLmrtEntries[index].proto_screen_off_lock =
- (mLmrtEntries[index].proto_screen_off_lock) |
- ((mProtoTableEntries[xx].power & PWR_SWTCH_ON_SCRN_OFF_LOCK_MASK)
- ? mProtoTableEntries[xx].protocol
- : 0);
- }
- }
- }
-
- dumpTables(2);
-
- DLOG_IF(INFO, nfc_debug_enabled) << StringPrintf("%s: exit", fn);
-}
-
-void RoutingManager::setProtoRouting() {
- static const char fn[] = "RoutingManager::setProtoRouting";
- tNFA_STATUS nfaStat = NFA_STATUS_FAILED;
-
- DLOG_IF(INFO, nfc_debug_enabled) << StringPrintf("%s: enter", fn);
- SyncEventGuard guard(mRoutingEvent);
-
- for (int xx = 0; xx < MAX_ROUTE_LOC_ENTRIES; xx++) {
- if (mLmrtEntries[xx].nfceeID) {
- /*Clear protocols for NFCEE ID control block */
- DLOG_IF(INFO, nfc_debug_enabled)
- << StringPrintf("%s: Clear Proto Routing Entries for nfceeID:0x%X",
- fn, mLmrtEntries[xx].nfceeID);
- nfaStat = NFA_EeSetDefaultProtoRouting(mLmrtEntries[xx].nfceeID, 0, 0, 0,
- 0, 0, 0);
- if (nfaStat == NFA_STATUS_OK) {
- mRoutingEvent.wait();
- } else {
- LOG(ERROR) << StringPrintf("Fail to clear proto routing to 0x%X",
- mLmrtEntries[xx].nfceeID);
- }
- }
- }
-
- for (int xx = 0; xx < MAX_ROUTE_LOC_ENTRIES; xx++) {
- if (mLmrtEntries[xx].nfceeID && (mLmrtEntries[xx].proto_switch_on ||
- mLmrtEntries[xx].proto_switch_off ||
- mLmrtEntries[xx].proto_battery_off ||
- mLmrtEntries[xx].proto_screen_lock ||
- mLmrtEntries[xx].proto_screen_off ||
- mLmrtEntries[xx].proto_screen_off_lock)) {
- DLOG_IF(INFO, nfc_debug_enabled)
- << StringPrintf("%s: Set Proto Routing Entries for nfceeID:0x%X", fn,
- mLmrtEntries[xx].nfceeID);
- /*Set Required protocols for NFCEE ID control block in libnfc-nci*/
- nfaStat = NFA_EeSetDefaultProtoRouting(
- mLmrtEntries[xx].nfceeID, mLmrtEntries[xx].proto_switch_on,
- mLmrtEntries[xx].proto_switch_off, mLmrtEntries[xx].proto_battery_off,
- mLmrtEntries[xx].proto_screen_lock, mLmrtEntries[xx].proto_screen_off,
- mLmrtEntries[xx].proto_screen_off_lock);
- if (nfaStat == NFA_STATUS_OK) {
- mRoutingEvent.wait();
- } else {
- LOG(ERROR) << StringPrintf("Fail to set proto routing to 0x%X",
- mLmrtEntries[xx].nfceeID);
- }
- }
- }
- DLOG_IF(INFO, nfc_debug_enabled) << StringPrintf("%s: exit", fn);
-}
-#if (NXP_EXTNS == TRUE)
-/*
- * In NCI2.0 Protocol 7816 routing is replaced with empty AID
- * Routing entry Format :
- * Type = [0x12]
- * Length = 2 [0x02]
- * Value = [Route_loc, Power_state]
- * */
-void RoutingManager::setEmptyAidEntry() {
- DLOG_IF(INFO, nfc_debug_enabled) << StringPrintf("%s: enter, ", __func__);
-
- uint16_t routeLoc;
- uint8_t power;
-
- routeLoc = mDefaultIso7816SeID;
- power = mCeRouteStrictDisable
- ? mDefaultIso7816Powerstate
- : (mDefaultIso7816Powerstate & POWER_STATE_MASK);
-
- DLOG_IF(INFO, nfc_debug_enabled)
- << StringPrintf("%s: routeLoc 0x%x", __func__, routeLoc);
- if (routeLoc == NFA_HANDLE_INVALID) {
- DLOG_IF(INFO, nfc_debug_enabled)
- << StringPrintf("%s: Invalid routeLoc. Return.", __func__);
- return;
- }
-
- tNFA_STATUS nfaStat = NFA_EeAddAidRouting(routeLoc, 0, NULL, power, 0x10);
- DLOG_IF(INFO, nfc_debug_enabled)
- << StringPrintf("%s: Status :0x%2x", __func__, nfaStat);
-}
-#endif
-
-/* Compilation of Tech Table entries strictly based on config file parameters
- * Each entry in tech table consistes of route location, technology and power
- * state
- * */
-void RoutingManager::compileTechEntries(void) {
- static const char fn[] = "RoutingManager::compileTechEntries";
- uint32_t techSupportedBySelectedEE = 0;
- DLOG_IF(INFO, nfc_debug_enabled) << StringPrintf("%s: enter", fn);
-
- /*Check technologies supported by EE selected in conf file*/
- if (mDefaultTechASeID == SecureElement::getInstance().EE_HANDLE_0xF4)
- techSupportedBySelectedEE = mTechSupportedByUicc1;
- else if (mDefaultTechASeID == ROUTE_LOC_UICC2_ID)
- techSupportedBySelectedEE = mTechSupportedByUicc2;
- else if (mDefaultTechASeID == ROUTE_LOC_ESE_ID)
- techSupportedBySelectedEE = mTechSupportedByEse;
- else
- techSupportedBySelectedEE =
- 0; /*For Host, no tech based route supported as Host always reads
- protocol data*/
-
- /*Populate the entries on tech route table*/
- mTechTableEntries[TECH_A_IDX].routeLoc = mDefaultTechASeID;
- mTechTableEntries[TECH_A_IDX].power =
- mCeRouteStrictDisable ? mDefaultTechAPowerstate
- : (mDefaultTechAPowerstate & POWER_STATE_MASK);
- mTechTableEntries[TECH_A_IDX].enable =
- (techSupportedBySelectedEE & NFA_TECHNOLOGY_MASK_A) ? true : false;
-
- /*Reuse the same power state and route location used for A*/
- mTechTableEntries[TECH_B_IDX].routeLoc = mDefaultTechASeID;
- mTechTableEntries[TECH_B_IDX].power =
- mCeRouteStrictDisable ? mDefaultTechAPowerstate
- : (mDefaultTechAPowerstate & POWER_STATE_MASK);
- mTechTableEntries[TECH_B_IDX].enable =
- (techSupportedBySelectedEE & NFA_TECHNOLOGY_MASK_B) ? true : false;
-
- getDefaultTechFRouteAndPowerState();
-
- /*Check technologies supported by EE selected in conf file - For TypeF*/
- if (mDefaultTechFSeID == SecureElement::getInstance().EE_HANDLE_0xF4)
- techSupportedBySelectedEE = mTechSupportedByUicc1;
- else if (mDefaultTechFSeID == ROUTE_LOC_UICC2_ID)
- techSupportedBySelectedEE = mTechSupportedByUicc2;
- else if (mDefaultTechFSeID == ROUTE_LOC_ESE_ID)
- techSupportedBySelectedEE = mTechSupportedByEse;
- else
- techSupportedBySelectedEE =
- 0; /*For Host, no tech based route supported as Host always reads
- protocol data*/
-
- mTechTableEntries[TECH_F_IDX].routeLoc = mDefaultTechFSeID;
- mTechTableEntries[TECH_F_IDX].power =
- mCeRouteStrictDisable ? mDefaultTechFPowerstate
- : (mDefaultTechFPowerstate & POWER_STATE_MASK);
- mTechTableEntries[TECH_F_IDX].enable =
- (techSupportedBySelectedEE & NFA_TECHNOLOGY_MASK_F) ? true : false;
-
- dumpTables(3);
- if (((mHostListnTechMask) && (mHostListnTechMask != 0X04)) &&
- (mFwdFuntnEnable == true)) {
- processTechEntriesForFwdfunctionality();
- }
- DLOG_IF(INFO, nfc_debug_enabled) << StringPrintf("%s: exit", fn);
-}
/* Forward Functionality is to handle either technology which is supported by
* UICC
@@ -1554,118 +1017,6 @@ void RoutingManager::processTechEntriesForFwdfunctionality(void) {
DLOG_IF(INFO, nfc_debug_enabled) << StringPrintf("%s: exit", fn);
}
-/* libnfc-nci takes technologies for each power-state for single route location
- * The previous technologies set will be overwritten by new technologies set by
- * NFA_EeSetDefaultTechRouting
- * So consolidate all the techs/power state for a given NFCEE ID's
- * For example:
- * When Tech A and Tech F set to same EE then set (TechA | Tech F) to that EE.
- */
-void RoutingManager::consolidateTechEntries(void) {
- static const char fn[] = "RoutingManager::consolidateTechEntries";
- DLOG_IF(INFO, nfc_debug_enabled) << StringPrintf("%s: enter", fn);
- int index = -1;
- for (int xx = 0; xx < MAX_TECH_ENTRIES; xx++) {
- if (mTechTableEntries[xx].enable) {
- switch (mTechTableEntries[xx].routeLoc) {
- case ROUTE_LOC_HOST_ID:
- index = ROUTE_LOC_HOST_ID_IDX;
- break;
- case ROUTE_LOC_ESE_ID:
- index = ROUTE_LOC_ESE_ID_IDX;
- break;
- case ROUTE_LOC_UICC1_ID:
- case ROUTE_LOC_UICC1_ID_NCI2_0:
- index = ROUTE_LOC_UICC1_ID_IDX;
- break;
- case ROUTE_LOC_UICC2_ID:
- index = ROUTE_LOC_UICC2_ID_IDX;
- break;
- }
- if (index != -1) {
- mLmrtEntries[index].tech_switch_on =
- mLmrtEntries[index].tech_switch_on |
- ((mTechTableEntries[xx].power & PWR_SWTCH_ON_SCRN_UNLCK_MASK)
- ? mTechTableEntries[xx].technology
- : 0);
- mLmrtEntries[index].tech_switch_off =
- mLmrtEntries[index].tech_switch_off |
- ((mTechTableEntries[xx].power & PWR_SWTCH_OFF_MASK)
- ? mTechTableEntries[xx].technology
- : 0);
- mLmrtEntries[index].tech_battery_off =
- mLmrtEntries[index].tech_battery_off |
- ((mTechTableEntries[xx].power & PWR_BATT_OFF_MASK)
- ? mTechTableEntries[xx].technology
- : 0);
- mLmrtEntries[index].tech_screen_lock =
- mLmrtEntries[index].tech_screen_lock |
- ((mTechTableEntries[xx].power & PWR_SWTCH_ON_SCRN_LOCK_MASK)
- ? mTechTableEntries[xx].technology
- : 0);
- mLmrtEntries[index].tech_screen_off =
- mLmrtEntries[index].tech_screen_off |
- ((mTechTableEntries[xx].power & PWR_SWTCH_ON_SCRN_OFF_MASK)
- ? mTechTableEntries[xx].technology
- : 0);
- mLmrtEntries[index].tech_screen_off_lock =
- mLmrtEntries[index].tech_screen_off_lock |
- ((mTechTableEntries[xx].power & PWR_SWTCH_ON_SCRN_OFF_LOCK_MASK)
- ? mTechTableEntries[xx].technology
- : 0);
- }
- }
- }
- dumpTables(4);
- DLOG_IF(INFO, nfc_debug_enabled) << StringPrintf("%s: exit", fn);
-}
-
-void RoutingManager::setTechRouting(void) {
- static const char fn[] = "RoutingManager::setTechRouting";
- tNFA_STATUS nfaStat = NFA_STATUS_FAILED;
- DLOG_IF(INFO, nfc_debug_enabled) << StringPrintf("%s: enter", fn);
- SyncEventGuard guard(mRoutingEvent);
- for (int xx = 0; xx < MAX_ROUTE_LOC_ENTRIES; xx++) {
- /*Clear technologies for NFCEE ID control block */
- DLOG_IF(INFO, nfc_debug_enabled)
- << StringPrintf("%s: Clear Routing Entries for nfceeID:0x%X", fn,
- mLmrtEntries[xx].nfceeID);
- nfaStat = NFA_EeSetDefaultTechRouting(mLmrtEntries[xx].nfceeID, 0, 0, 0,
- 0, 0, 0);
- if (nfaStat == NFA_STATUS_OK) {
- mRoutingEvent.wait();
- } else {
- LOG(ERROR) << StringPrintf("Fail to clear tech routing to 0x%x",
- mLmrtEntries[xx].nfceeID);
- }
- }
- for (int xx = 0; xx < MAX_ROUTE_LOC_ENTRIES; xx++) {
- if (mLmrtEntries[xx].nfceeID &&
- (mLmrtEntries[xx].tech_switch_on || mLmrtEntries[xx].tech_switch_off ||
- mLmrtEntries[xx].tech_battery_off ||
- mLmrtEntries[xx].tech_screen_lock ||
- mLmrtEntries[xx].tech_screen_off ||
- mLmrtEntries[xx].tech_screen_off_lock)) {
- /*Set Required technologies for NFCEE ID control block */
- DLOG_IF(INFO, nfc_debug_enabled)
- << StringPrintf("%s: Set Routing Entries for nfceeID:0x%X", fn,
- mLmrtEntries[xx].nfceeID);
- nfaStat = NFA_EeSetDefaultTechRouting(
- mLmrtEntries[xx].nfceeID, mLmrtEntries[xx].tech_switch_on,
- mLmrtEntries[xx].tech_switch_off, mLmrtEntries[xx].tech_battery_off,
- mLmrtEntries[xx].tech_screen_lock, mLmrtEntries[xx].tech_screen_off,
- mLmrtEntries[xx].tech_screen_off_lock);
- if (nfaStat == NFA_STATUS_OK) {
- mRoutingEvent.wait();
- } else {
- LOG(ERROR) << StringPrintf("Fail to set tech routing to 0x%x",
- mLmrtEntries[xx].nfceeID);
- }
- }
- }
- DLOG_IF(INFO, nfc_debug_enabled) << StringPrintf("%s: exit", fn);
-}
-
void RoutingManager::dumpTables(int xx) {
switch (xx) {
case 1: // print only proto table
@@ -1736,167 +1087,6 @@ void RoutingManager::dumpTables(int xx) {
#endif
#if (NXP_EXTNS == TRUE)
-bool RoutingManager::setRoutingEntry(int type, int value, int route,
- int power) {
- static const char fn[] = "RoutingManager::setRoutingEntry";
- DLOG_IF(INFO, nfc_debug_enabled)
- << StringPrintf("%s: enter, type:0x%x value =0x%x route:%x power:0x%x",
- fn, type, value, route, power);
- unsigned long max_tech_mask = 0x03;
- unsigned long uiccListenTech = 0;
- SecureElement& se = SecureElement::getInstance();
- max_tech_mask =
- SecureElement::getInstance().getSETechnology(se.EE_HANDLE_0xF4);
- DLOG_IF(INFO, nfc_debug_enabled)
- << StringPrintf("%s: enter,max_tech_mask :%lx", fn, max_tech_mask);
-
- tNFA_STATUS nfaStat = NFA_STATUS_FAILED;
- tNFA_HANDLE ee_handle = NFA_HANDLE_INVALID;
- SyncEventGuard guard(mRoutingEvent);
- uint8_t switch_on_mask = 0x00;
- uint8_t switch_off_mask = 0x00;
- uint8_t battery_off_mask = 0x00;
- uint8_t screen_lock_mask = 0x00;
- uint8_t screen_off_mask = 0x00;
- uint8_t protocol_mask = 0x00;
- uint8_t screen_off_lock_mask = 0x00;
-
- ee_handle = ((route == 0x01) ? SecureElement::EE_HANDLE_0xF3
- : ((route == 0x02) ? se.EE_HANDLE_0xF4
- : NFA_HANDLE_INVALID));
- if (0x00 == route) {
- ee_handle = 0x400;
- }
- if (ee_handle == NFA_HANDLE_INVALID) {
- DLOG_IF(INFO, nfc_debug_enabled)
- << StringPrintf("%s: enter, handle:%x invalid", fn, ee_handle);
- return nfaStat;
- }
-
- tNFA_HANDLE ActDevHandle = NFA_HANDLE_INVALID;
- uint8_t count, seId = 0;
- uint8_t isSeIDPresent = 0;
- tNFA_HANDLE ee_handleList[nfcFL.nfccFL._NFA_EE_MAX_EE_SUPPORTED];
- SecureElement::getInstance().getEeHandleList(ee_handleList, &count);
-
- for (int i = 0; ((count != 0) && (i < count)); i++) {
- seId = SecureElement::getInstance().getGenericEseId(ee_handleList[i]);
- ActDevHandle = SecureElement::getInstance().getEseHandleFromGenericId(seId);
- DLOG_IF(INFO, nfc_debug_enabled) << StringPrintf(
- "%s: enter, ee_handleList[%d]:%x", fn, i, ee_handleList[i]);
- if ((ee_handle != 0x400) && (ee_handle == ActDevHandle)) {
- isSeIDPresent = 1;
- break;
- }
- }
-
- if (!isSeIDPresent) {
- ee_handle = 0x400;
- }
-
- if (NFA_SET_TECHNOLOGY_ROUTING == type) {
- switch_on_mask = (power & 0x01) ? value : 0;
- switch_off_mask = (power & 0x02) ? value : 0;
- battery_off_mask = (power & 0x04) ? value : 0;
- screen_off_mask = (power & 0x08) ? value : 0;
- screen_lock_mask = (power & 0x10) ? value : 0;
- screen_off_lock_mask = (power & 0x20) ? value : 0;
-
- if (mHostListnTechMask > 0 && mFwdFuntnEnable == true) {
- if ((max_tech_mask != 0x01) && (max_tech_mask == 0x02)) {
- switch_on_mask &= ~NFA_TECHNOLOGY_MASK_A;
- switch_off_mask &= ~NFA_TECHNOLOGY_MASK_A;
- battery_off_mask &= ~NFA_TECHNOLOGY_MASK_A;
- screen_off_mask &= ~NFA_TECHNOLOGY_MASK_A;
- screen_lock_mask &= ~NFA_TECHNOLOGY_MASK_A;
-
- if (mCeRouteStrictDisable == 0x01) {
- nfaStat = NFA_EeSetDefaultTechRouting(0x400, NFA_TECHNOLOGY_MASK_A, 0,
- 0, NFA_TECHNOLOGY_MASK_A, 0, 0);
- } else {
- nfaStat = NFA_EeSetDefaultTechRouting(0x400, NFA_TECHNOLOGY_MASK_A, 0,
- 0, 0, 0, 0);
- }
- if (nfaStat == NFA_STATUS_OK)
- mRoutingEvent.wait();
- else {
- LOG(ERROR) << StringPrintf("Fail to set tech routing");
- }
- } else if ((max_tech_mask == 0x01) && (max_tech_mask != 0x02)) {
- switch_on_mask &= ~NFA_TECHNOLOGY_MASK_B;
- switch_off_mask &= ~NFA_TECHNOLOGY_MASK_B;
- battery_off_mask &= ~NFA_TECHNOLOGY_MASK_B;
- screen_off_mask &= ~NFA_TECHNOLOGY_MASK_B;
- screen_lock_mask &= ~NFA_TECHNOLOGY_MASK_B;
-
- if (mCeRouteStrictDisable == 0x01) {
- nfaStat = NFA_EeSetDefaultTechRouting(0x400, NFA_TECHNOLOGY_MASK_B, 0,
- 0, NFA_TECHNOLOGY_MASK_B, 0, 0);
- } else {
- nfaStat = NFA_EeSetDefaultTechRouting(0x400, NFA_TECHNOLOGY_MASK_B, 0,
- 0, 0, 0, 0);
- }
- if (nfaStat == NFA_STATUS_OK)
- mRoutingEvent.wait();
- else {
- LOG(ERROR) << StringPrintf("Fail to set tech routing");
- }
- }
- }
-
- nfaStat = NFA_EeSetDefaultTechRouting(
- ee_handle, switch_on_mask, switch_off_mask, battery_off_mask,
- screen_lock_mask, screen_off_mask, screen_off_lock_mask);
- if (nfaStat == NFA_STATUS_OK) {
- mRoutingEvent.wait();
- DLOG_IF(INFO, nfc_debug_enabled) << StringPrintf("tech routing SUCCESS");
- } else {
- LOG(ERROR) << StringPrintf("Fail to set default tech routing");
- }
- } else if (NFA_SET_PROTOCOL_ROUTING == type) {
- if (value == 0x01) protocol_mask = NFA_PROTOCOL_MASK_ISO_DEP;
- if (value == 0x02) protocol_mask = NFA_PROTOCOL_MASK_NFC_DEP;
- if (value == 0x04) protocol_mask = NFA_PROTOCOL_MASK_T3T;
-
- switch_on_mask = (power & 0x01) ? protocol_mask : 0;
- switch_off_mask = (power & 0x02) ? protocol_mask : 0;
- battery_off_mask = (power & 0x04) ? protocol_mask : 0;
- screen_lock_mask = (power & 0x10) ? protocol_mask : 0;
- screen_off_mask = (power & 0x08) ? protocol_mask : 0;
- screen_off_lock_mask = (power & 0x20) ? protocol_mask : 0;
- registerProtoRouteEntry(ee_handle, switch_on_mask, switch_off_mask,
- battery_off_mask, screen_lock_mask, screen_off_mask,
- screen_off_lock_mask);
- }
-
- if (NfcConfig::hasKey(NAME_UICC_LISTEN_TECH_MASK)) {
- uiccListenTech = NfcConfig::getUnsigned(NAME_UICC_LISTEN_TECH_MASK);
- DLOG_IF(INFO, nfc_debug_enabled)
- << StringPrintf("%s:UICC_TECH_MASK=0x0%lu;", __func__, uiccListenTech);
- }
-
- if ((ActDevHandle != NFA_HANDLE_INVALID) && (0 != uiccListenTech)) {
- {
- SyncEventGuard guard(SecureElement::getInstance().mUiccListenEvent);
- nfaStat = NFA_CeConfigureUiccListenTech(ActDevHandle, 0x00);
- if (nfaStat == NFA_STATUS_OK) {
- SecureElement::getInstance().mUiccListenEvent.wait();
- } else
- LOG(ERROR) << StringPrintf("fail to start UICC listen");
- }
- {
- SyncEventGuard guard(SecureElement::getInstance().mUiccListenEvent);
- nfaStat =
- NFA_CeConfigureUiccListenTech(ActDevHandle, (uiccListenTech & 0x07));
- if (nfaStat == NFA_STATUS_OK) {
- SecureElement::getInstance().mUiccListenEvent.wait();
- } else
- LOG(ERROR) << StringPrintf("fail to start UICC listen");
- }
- }
- return nfaStat;
-}
-
bool RoutingManager::clearRoutingEntry(int type) {
static const char fn[] = "RoutingManager::clearRoutingEntry";
DLOG_IF(INFO, nfc_debug_enabled)
@@ -1992,8 +1182,37 @@ bool RoutingManager::clearRoutingEntry(int type) {
}
return nfaStat;
}
-#endif
-#if (NXP_EXTNS == TRUE)
+
+/*
+ * In NCI2.0 Protocol 7816 routing is replaced with empty AID
+ * Routing entry Format :
+ * Type = [0x12]
+ * Length = 2 [0x02]
+ * Value = [Route_loc, Power_state]
+ * */
+void RoutingManager::setEmptyAidEntry() {
+ DLOG_IF(INFO, nfc_debug_enabled) << StringPrintf("%s: enter", __func__);
+ uint16_t routeLoc;
+ uint8_t power;
+
+ routeLoc = mDefaultIso7816SeID;
+
+ power = mCeRouteStrictDisable
+ ? mDefaultIso7816Powerstate
+ : (mDefaultIso7816Powerstate & POWER_STATE_MASK);
+ DLOG_IF(INFO, nfc_debug_enabled)
+ << StringPrintf("%s: route %x", __func__, routeLoc);
+ if (routeLoc == 0x400) power &= 0x11;
+ if (routeLoc == NFA_HANDLE_INVALID) {
+ LOG(ERROR) << StringPrintf("%s: Invalid routeLoc. Return.", __func__);
+ return;
+ }
+
+ tNFA_STATUS nfaStat = NFA_EeAddAidRouting(routeLoc, 0, NULL, power, 0x10);
+ DLOG_IF(INFO, nfc_debug_enabled)
+ << StringPrintf("%s: Status :0x%2x", __func__, nfaStat);
+}
+
bool RoutingManager::addAidRouting(const uint8_t* aid, uint8_t aidLen,
int route, int power, int aidInfo)
#else
@@ -2220,6 +1439,268 @@ void RoutingManager::setDefaultProtoRouting(int seId, int proto_switchon,
// }
}
+bool RoutingManager::setRoutingEntry(int type, int value, int route,
+ int power) {
+ static const char fn[] = "RoutingManager::setRoutingEntry";
+ DLOG_IF(INFO, nfc_debug_enabled) << StringPrintf(
+ "%s: enter, >>>>>>>> type:0x%x value =0x%x route:%x power:0x%x", fn, type,
+ value, route, power);
+ unsigned long max_tech_mask = 0x03;
+ unsigned long uiccListenTech = 0;
+
+ if (!nfcFL.nfccFL._NFCC_DYNAMIC_DUAL_UICC) {
+ if (nfcManager_getUiccRoute(sCurrentSelectedUICCSlot) != 0xFF) {
+ max_tech_mask = SecureElement::getInstance().getSETechnology(
+ nfcManager_getUiccRoute(sCurrentSelectedUICCSlot));
+ } else {
+ max_tech_mask = SecureElement::getInstance().getSETechnology(
+ SecureElement::getInstance().EE_HANDLE_0xF4);
+ }
+ } else {
+ max_tech_mask = SecureElement::getInstance().getSETechnology(
+ SecureElement::getInstance().EE_HANDLE_0xF4);
+ }
+
+ DLOG_IF(INFO, nfc_debug_enabled)
+ << StringPrintf("%s: enter,max_tech_mask :%lx", fn, max_tech_mask);
+
+ tNFA_STATUS nfaStat = NFA_STATUS_FAILED;
+ tNFA_HANDLE ee_handle = NFA_HANDLE_INVALID;
+ uint8_t switch_on_mask = 0x00;
+ uint8_t switch_off_mask = 0x00;
+ uint8_t battery_off_mask = 0x00;
+ uint8_t screen_lock_mask = 0x00;
+ uint8_t screen_off_mask = 0x00;
+ uint8_t screen_off_lock_mask = 0x00;
+ uint8_t protocol_mask = 0x00;
+
+ if (!nfcFL.nfccFL._NFCC_DYNAMIC_DUAL_UICC) {
+ if (nfcManager_getUiccRoute(sCurrentSelectedUICCSlot) != 0xFF) {
+ ee_handle =
+ ((route == 0x01)
+ ? 0x4C0
+ : ((route == 0x02)
+ ? nfcManager_getUiccRoute(sCurrentSelectedUICCSlot)
+ : NFA_HANDLE_INVALID));
+ } else {
+ ee_handle =
+ ((route == 0x01)
+ ? 0x4C0
+ : ((route == 0x02) ? SecureElement::getInstance().EE_HANDLE_0xF4
+ : NFA_HANDLE_INVALID));
+ }
+ } else {
+ ee_handle =
+ ((route == 0x01)
+ ? 0x4C0
+ : ((route == 0x02) ? SecureElement::getInstance().EE_HANDLE_0xF4
+ : NFA_HANDLE_INVALID));
+ }
+
+ if (0x00 == route) {
+ ee_handle = 0x400;
+ }
+ if (ee_handle == NFA_HANDLE_INVALID) {
+ DLOG_IF(INFO, nfc_debug_enabled)
+ << StringPrintf("%s: enter, handle:%x invalid", fn, ee_handle);
+ return nfaStat;
+ }
+
+ tNFA_HANDLE ActDevHandle = NFA_HANDLE_INVALID;
+ uint8_t count, seId = 0;
+ uint8_t isSeIDPresent = 0;
+ tNFA_HANDLE ee_handleList[SecureElement::MAX_NUM_EE];
+ SecureElement::getInstance().getEeHandleList(ee_handleList, &count);
+
+ for (int i = 0; ((count != 0) && (i < count)); i++) {
+ seId = SecureElement::getInstance().getGenericEseId(ee_handleList[i]);
+ ActDevHandle = SecureElement::getInstance().getEseHandleFromGenericId(seId);
+ DLOG_IF(INFO, nfc_debug_enabled) << StringPrintf(
+ "%s: enter, ee_handleList[%d]:%x", fn, i, ee_handleList[i]);
+ if ((ee_handle != 0x400) && (ee_handle == ActDevHandle)) {
+ isSeIDPresent = 1;
+ break;
+ }
+ }
+
+ if (((ee_handle == SecureElement::getInstance().EE_HANDLE_0xF4) ||
+ (ee_handle == 0x481)) &&
+ (isSeIDPresent != 1)) {
+ // check if eSE is exist
+ for (int i = 0; ((count != 0) && (i < count)); i++) {
+ seId = SecureElement::getInstance().getGenericEseId(ee_handleList[i]);
+ ActDevHandle =
+ SecureElement::getInstance().getEseHandleFromGenericId(seId);
+ if (ActDevHandle == 0x4C0) {
+ DLOG_IF(INFO, nfc_debug_enabled) << StringPrintf(
+ "%s: enter, UICC is not activated, so Routing is changed UICC to "
+ "eSE",
+ fn);
+ isSeIDPresent = 1;
+ ee_handle = ActDevHandle;
+ break;
+ }
+ }
+ }
+
+ if ((ee_handle != 0x400) &&
+ ((NFA_SET_PROTOCOL_ROUTING == type) && (isSeIDPresent != 1))) {
+ DLOG_IF(INFO, nfc_debug_enabled)
+ << StringPrintf("%s: changing the destination to DH", fn);
+ ee_handle = 0x400;
+ power &= 0x31;
+ }
+
+ max_tech_mask = SecureElement::getInstance().getSETechnology(ee_handle);
+ DLOG_IF(INFO, nfc_debug_enabled)
+ << StringPrintf("%s: enter,max_tech_mask :%lx", fn, max_tech_mask);
+ if (NFA_SET_TECHNOLOGY_ROUTING == type) {
+ /* Masking with available SE Technologies */
+ value &= max_tech_mask;
+ DLOG_IF(INFO, nfc_debug_enabled)
+ << StringPrintf("%s: enter >>>> max_tech_mask :%lx value :0x%x", fn,
+ max_tech_mask, value);
+ switch_on_mask = (power & 0x01) ? value : 0;
+ switch_off_mask = (power & 0x02) ? value : 0;
+ battery_off_mask = (power & 0x04) ? value : 0;
+ screen_off_mask = (power & 0x10) ? value : 0;
+ screen_lock_mask = (power & 0x08) ? value : 0;
+ screen_off_lock_mask = (power & 0x20) ? value : 0;
+
+ if ((max_tech_mask != 0x01) && (max_tech_mask == 0x02)) // type B only
+ {
+ switch_on_mask &= ~NFA_TECHNOLOGY_MASK_A;
+ switch_off_mask &= ~NFA_TECHNOLOGY_MASK_A;
+ battery_off_mask &= ~NFA_TECHNOLOGY_MASK_A;
+ screen_off_mask &= ~NFA_TECHNOLOGY_MASK_A;
+ screen_lock_mask &= ~NFA_TECHNOLOGY_MASK_A;
+ screen_off_lock_mask &= ~NFA_TECHNOLOGY_MASK_A;
+ } else if ((max_tech_mask == 0x01) &&
+ (max_tech_mask != 0x02)) // type A only
+ {
+ switch_on_mask &= ~NFA_TECHNOLOGY_MASK_B;
+ switch_off_mask &= ~NFA_TECHNOLOGY_MASK_B;
+ battery_off_mask &= ~NFA_TECHNOLOGY_MASK_B;
+ screen_off_mask &= ~NFA_TECHNOLOGY_MASK_B;
+ screen_lock_mask &= ~NFA_TECHNOLOGY_MASK_B;
+ screen_off_lock_mask &= ~NFA_TECHNOLOGY_MASK_B;
+ }
+
+ if ((mHostListnTechMask) && (mFwdFuntnEnable == true)) {
+ if ((max_tech_mask != 0x01) && (max_tech_mask == 0x02)) {
+ {
+ SyncEventGuard guard(mRoutingEvent);
+ if (mCeRouteStrictDisable == 0x01) {
+ nfaStat =
+ NFA_EeSetDefaultTechRouting(0x400, NFA_TECHNOLOGY_MASK_A, 0, 0,
+ NFA_TECHNOLOGY_MASK_A, 0, 0);
+ } else {
+ nfaStat = NFA_EeSetDefaultTechRouting(0x400, NFA_TECHNOLOGY_MASK_A,
+ 0, 0, 0, 0, 0);
+ }
+ if (nfaStat == NFA_STATUS_OK)
+ mRoutingEvent.wait();
+ else {
+ DLOG_IF(ERROR, nfc_debug_enabled)
+ << StringPrintf("Fail to set tech routing");
+ }
+ }
+ } else if ((max_tech_mask == 0x01) && (max_tech_mask != 0x02)) {
+ {
+ SyncEventGuard guard(mRoutingEvent);
+ if (mCeRouteStrictDisable == 0x01) {
+ nfaStat =
+ NFA_EeSetDefaultTechRouting(0x400, NFA_TECHNOLOGY_MASK_B, 0, 0,
+ NFA_TECHNOLOGY_MASK_B, 0, 0);
+ } else {
+ nfaStat = NFA_EeSetDefaultTechRouting(0x400, NFA_TECHNOLOGY_MASK_B,
+ 0, 0, 0, 0, 0);
+ }
+ if (nfaStat == NFA_STATUS_OK)
+ mRoutingEvent.wait();
+ else {
+ DLOG_IF(ERROR, nfc_debug_enabled)
+ << StringPrintf("Fail to set tech routing");
+ }
+ }
+ }
+ }
+ {
+ SyncEventGuard guard(mRoutingEvent);
+ nfaStat = NFA_EeSetDefaultTechRouting(
+ ee_handle, switch_on_mask, switch_off_mask, battery_off_mask,
+ screen_lock_mask, screen_off_mask, screen_off_lock_mask);
+ if (nfaStat == NFA_STATUS_OK) {
+ mRoutingEvent.wait();
+ DLOG_IF(INFO, nfc_debug_enabled)
+ << StringPrintf("tech routing SUCCESS");
+ } else {
+ DLOG_IF(ERROR, nfc_debug_enabled)
+ << StringPrintf("Fail to set default tech routing");
+ }
+ }
+ } else if (NFA_SET_PROTOCOL_ROUTING == type) {
+ value &= ~(0xF0);
+ while (value) {
+ if (value & 0x01) {
+ protocol_mask = NFA_PROTOCOL_MASK_ISO_DEP;
+ value &= ~(0x01);
+ } else if (value & 0x02) {
+ protocol_mask = NFA_PROTOCOL_MASK_NFC_DEP;
+ value &= ~(0x02);
+ } else if (value & 0x04) {
+ protocol_mask = NFA_PROTOCOL_MASK_T3T;
+ value &= ~(0x04);
+ } else if (value & 0x08) {
+ protocol_mask = NFC_PROTOCOL_MASK_ISO7816;
+ value &= ~(0x08);
+ }
+
+ if (protocol_mask) {
+ switch_on_mask = (power & 0x01) ? protocol_mask : 0;
+ switch_off_mask = (power & 0x02) ? protocol_mask : 0;
+ battery_off_mask = (power & 0x04) ? protocol_mask : 0;
+ screen_lock_mask = (power & 0x08) ? protocol_mask : 0;
+ screen_off_mask = (power & 0x10) ? protocol_mask : 0;
+ screen_off_lock_mask = (power & 0x20) ? protocol_mask : 0;
+ DLOG_IF(INFO, nfc_debug_enabled) << StringPrintf(
+ "%s: enter >>>> ee_handle:%x %x %x %x %x %x %x", fn, ee_handle,
+ switch_on_mask, switch_off_mask, battery_off_mask, screen_lock_mask,
+ screen_off_mask, screen_off_lock_mask);
+
+ registerProtoRouteEnrty(ee_handle, switch_on_mask, switch_off_mask,
+ battery_off_mask, screen_lock_mask,
+ screen_off_mask, screen_off_lock_mask);
+ protocol_mask = 0;
+ }
+ }
+ }
+
+ uiccListenTech = NfcConfig::getUnsigned("NAME_UICC_LISTEN_TECH_MASK", 0x07);
+ if ((ActDevHandle != NFA_HANDLE_INVALID) && (0 != uiccListenTech)) {
+ {
+ SyncEventGuard guard (SecureElement::getInstance().mUiccListenEvent);
+ nfaStat = NFA_CeConfigureUiccListenTech(ActDevHandle, 0x00);
+ if (nfaStat == NFA_STATUS_OK) {
+ SecureElement::getInstance().mUiccListenEvent.wait ();
+ } else
+ DLOG_IF(ERROR, nfc_debug_enabled)
+ << StringPrintf("fail to start UICC listen");
+ }
+ {
+ SyncEventGuard guard (SecureElement::getInstance().mUiccListenEvent);
+ nfaStat =
+ NFA_CeConfigureUiccListenTech(ActDevHandle, (uiccListenTech & 0x07));
+ if (nfaStat == NFA_STATUS_OK) {
+ SecureElement::getInstance().mUiccListenEvent.wait ();
+ } else
+ DLOG_IF(ERROR, nfc_debug_enabled)
+ << StringPrintf("fail to start UICC listen");
+ }
+ }
+ return nfaStat;
+}
+
bool RoutingManager::clearAidTable() {
static const char fn[] = "RoutingManager::clearAidTable";
DLOG_IF(INFO, nfc_debug_enabled) << StringPrintf("%s: enter", fn);
@@ -3013,6 +2494,17 @@ void RoutingManager::nfcFCeCallback(uint8_t event,
}
}
+bool RoutingManager::setNfcSecure(bool enable) {
+ mSecureNfcEnabled = enable;
+ DLOG_IF(INFO, true) << "chi setNfcSecure NfcService " << enable;
+ return true;
+}
+
+void RoutingManager::deinitialize() {
+ onNfccShutdown();
+ NFA_EeDeregister(nfaEeCallback);
+}
+
int RoutingManager::registerJniFunctions(JNIEnv* e) {
static const char fn[] = "RoutingManager::registerJniFunctions";
DLOG_IF(INFO, nfc_debug_enabled) << StringPrintf("%s", fn);
@@ -3021,6 +2513,33 @@ int RoutingManager::registerJniFunctions(JNIEnv* e) {
NELEM(sMethods));
}
+jbyteArray
+RoutingManager::com_android_nfc_cardemulation_doGetOffHostUiccDestination(
+ JNIEnv* e) {
+ std::vector<uint8_t> uicc = getInstance().mOffHostRouteUicc;
+ if (uicc.size() == 0) {
+ return NULL;
+ }
+ CHECK(e);
+ jbyteArray uiccJavaArray = e->NewByteArray(uicc.size());
+ CHECK(uiccJavaArray);
+ e->SetByteArrayRegion(uiccJavaArray, 0, uicc.size(), (jbyte*)&uicc[0]);
+ return uiccJavaArray;
+}
+
+jbyteArray
+RoutingManager::com_android_nfc_cardemulation_doGetOffHostEseDestination(
+ JNIEnv* e) {
+ std::vector<uint8_t> ese = getInstance().mOffHostRouteEse;
+ if (ese.size() == 0) {
+ return NULL;
+ }
+ CHECK(e);
+ jbyteArray eseJavaArray = e->NewByteArray(ese.size());
+ CHECK(eseJavaArray);
+ e->SetByteArrayRegion(eseJavaArray, 0, ese.size(), (jbyte*)&ese[0]);
+ return eseJavaArray;
+}
int RoutingManager::com_android_nfc_cardemulation_doGetDefaultRouteDestination(
JNIEnv*) {
return getInstance().mDefaultEe;
@@ -3036,7 +2555,13 @@ int RoutingManager::com_android_nfc_cardemulation_doGetAidMatchingMode(
return getInstance().mAidMatchingMode;
}
-int RoutingManager::com_android_nfc_cardemulation_doGetAidMatchingPlatform(
+int RoutingManager::
+ com_android_nfc_cardemulation_doGetDefaultIsoDepRouteDestination(JNIEnv*) {
+ return RoutingManager::getInstance().mDefaultIsoDepRoute;
+}
+
+__attribute__((unused)) int
+RoutingManager::com_android_nfc_cardemulation_doGetAidMatchingPlatform(
JNIEnv*) {
return getInstance().mAidMatchingPlatform;
}
@@ -3178,6 +2703,10 @@ void RoutingManager::ee_removed_disc_ntf_handler(tNFA_HANDLE handle,
pthread_attr_destroy(&attr);
}
+void RoutingManager::updateRoutingTable() {
+ // TODO : Need to check whether its required or not. Added for compilation
+ // purpose
+}
#if (NXP_EXTNS == TRUE)
bool RoutingManager::is_ee_recovery_ongoing() {
static const char fn[] = "RoutingManager::is_ee_recovery_ongoing";
@@ -3204,23 +2733,6 @@ void RoutingManager::setEERecovery(bool value) {
/*******************************************************************************
**
-** Function: getRouting
-**
-** Description: Send GET_LISTEN_MODE_ROUTING command
-**
-** Returns: None
-**
-*******************************************************************************/
-void RoutingManager::getRouting() {
- tNFA_STATUS nfcStat;
- nfcStat = NFC_GetRouting();
- if (nfcStat == NFA_STATUS_OK) {
- LOG(ERROR) << StringPrintf("getRouting failed. status=0x0%x", nfcStat);
- }
-}
-
-/*******************************************************************************
-**
** Function: processGetRouting
**
** Description: Process the eventData(current routing info) received during
@@ -3342,49 +2854,91 @@ static jint getUiccRoute(jint uicc_slot) {
}
}
-/*******************************************************************************
-**
-** Function: getDefaultTechFRouteAndPowerState
-**
-** Description: Retrieve default TechF Route location and correponding
-** Power state from config file. Assign default value incase
-** there are no entries
-**
-*******************************************************************************/
-void RoutingManager::getDefaultTechFRouteAndPowerState() {
- unsigned long num = 0;
+void RoutingManager::registerProtoRouteEnrty(
+ tNFA_HANDLE ee_handle, tNFA_PROTOCOL_MASK protocols_switch_on,
+ tNFA_PROTOCOL_MASK protocols_switch_off,
+ tNFA_PROTOCOL_MASK protocols_battery_off,
+ tNFA_PROTOCOL_MASK protocols_screen_lock,
+ tNFA_PROTOCOL_MASK protocols_screen_off,
+ tNFA_PROTOCOL_MASK protocols_screen_off_lock) {
+ static const char fn[] = "RoutingManager::registerProtoRouteEnrty";
+ bool new_entry = true;
+ uint8_t i = 0;
+ tNFA_STATUS nfaStat = NFA_STATUS_FAILED;
- if (nfcFL.eseFL._ESE_FELICA_CLT) {
- if (NfcConfig::hasKey(NAME_DEFAULT_NFCF_ROUTE)) {
- num = NfcConfig::getUnsigned(NAME_DEFAULT_NFCF_ROUTE);
- switch (num) {
- case 0x00:
- mDefaultTechFSeID = ROUTE_LOC_HOST_ID;
- break;
- case 0x01:
- mDefaultTechFSeID = ROUTE_LOC_ESE_ID;
- break;
- case 0x02:
- case 0x03:
- if (nfcFL.nfccFL._NFCC_DYNAMIC_DUAL_UICC &&
- nfcFL.nfccFL._NFC_NXP_STAT_DUAL_UICC_WO_EXT_SWITCH) {
- mDefaultTechFSeID = getUiccRoute(sCurrentSelectedUICCSlot);
- } else {
- mDefaultTechFSeID = SecureElement::getInstance().EE_HANDLE_0xF4;
- }
+ if (gRouteInfo.num_entries == 0) {
+ DLOG_IF(INFO, nfc_debug_enabled)
+ << StringPrintf("%s: enter, first entry :%x", fn, ee_handle);
+ gRouteInfo.protoInfo[0].ee_handle = ee_handle;
+ gRouteInfo.protoInfo[0].protocols_switch_on = protocols_switch_on;
+ gRouteInfo.protoInfo[0].protocols_switch_off = protocols_switch_off;
+ gRouteInfo.protoInfo[0].protocols_battery_off = protocols_battery_off;
+ gRouteInfo.protoInfo[0].protocols_screen_lock = protocols_screen_lock;
+ gRouteInfo.protoInfo[0].protocols_screen_off = protocols_screen_off;
+ gRouteInfo.protoInfo[0].protocols_screen_off_lock =
+ protocols_screen_off_lock;
+ gRouteInfo.num_entries = 1;
+ } else {
+ for (i = 0; i < gRouteInfo.num_entries; i++) {
+ if (gRouteInfo.protoInfo[i].ee_handle == ee_handle) {
+ DLOG_IF(INFO, nfc_debug_enabled) << StringPrintf(
+ "%s: enter, proto handle match found :%x", fn, ee_handle);
+ gRouteInfo.protoInfo[i].protocols_switch_on |= protocols_switch_on;
+ gRouteInfo.protoInfo[i].protocols_switch_off |= protocols_switch_off;
+ gRouteInfo.protoInfo[i].protocols_battery_off |= protocols_battery_off;
+ gRouteInfo.protoInfo[i].protocols_screen_lock |= protocols_screen_lock;
+ gRouteInfo.protoInfo[i].protocols_screen_off |= protocols_screen_off;
+ gRouteInfo.protoInfo[i].protocols_screen_off_lock |=
+ protocols_screen_off_lock;
+ new_entry = false;
+ break;
}
}
+ if (new_entry) {
+ DLOG_IF(INFO, nfc_debug_enabled) << StringPrintf(
+ "%s: enter,new proto handle entry :%x", fn, ee_handle);
+ i = gRouteInfo.num_entries;
+ gRouteInfo.protoInfo[i].ee_handle = ee_handle;
+ gRouteInfo.protoInfo[i].protocols_switch_on = protocols_switch_on;
+ gRouteInfo.protoInfo[i].protocols_switch_off = protocols_switch_off;
+ gRouteInfo.protoInfo[i].protocols_battery_off = protocols_battery_off;
+ gRouteInfo.protoInfo[i].protocols_screen_lock = protocols_screen_lock;
+ gRouteInfo.protoInfo[i].protocols_screen_off = protocols_screen_off;
+ gRouteInfo.protoInfo[i].protocols_screen_off_lock =
+ protocols_screen_off_lock;
+ gRouteInfo.num_entries++;
+ }
+ }
+ for (i = 0; i < gRouteInfo.num_entries; i++) {
+ {
+ SyncEventGuard guard(mRoutingEvent);
+ DLOG_IF(INFO, nfc_debug_enabled)
+ << StringPrintf("%s: enter >>>> ee_handle:%x %x %x %x %x %x %x", fn,
+ gRouteInfo.protoInfo[i].ee_handle,
+ gRouteInfo.protoInfo[i].protocols_switch_on,
+ gRouteInfo.protoInfo[i].protocols_switch_off,
+ gRouteInfo.protoInfo[i].protocols_battery_off,
+ gRouteInfo.protoInfo[i].protocols_screen_lock,
+ gRouteInfo.protoInfo[i].protocols_screen_off,
+ gRouteInfo.protoInfo[i].protocols_screen_off_lock);
- if (NfcConfig::hasKey(NAME_DEFAULT_FELICA_CLT_PWR_STATE)) {
- num = NfcConfig::getUnsigned(NAME_DEFAULT_FELICA_CLT_PWR_STATE);
- mDefaultTechFPowerstate = num;
- } else {
- mDefaultTechFPowerstate = 0x3F;
+ nfaStat = NFA_EeSetDefaultProtoRouting(
+ gRouteInfo.protoInfo[i].ee_handle,
+ gRouteInfo.protoInfo[i].protocols_switch_on,
+ gRouteInfo.protoInfo[i].protocols_switch_off,
+ gRouteInfo.protoInfo[i].protocols_battery_off,
+ gRouteInfo.protoInfo[i].protocols_screen_lock,
+ gRouteInfo.protoInfo[i].protocols_screen_off,
+ gRouteInfo.protoInfo[i].protocols_screen_off_lock);
+ if (nfaStat == NFA_STATUS_OK) {
+ mRoutingEvent.wait();
+ DLOG_IF(INFO, nfc_debug_enabled)
+ << StringPrintf("tech routing SUCCESS");
+ } else {
+ DLOG_IF(ERROR, nfc_debug_enabled)
+ << StringPrintf("Fail to set default tech routing");
+ }
}
- } else {
- mDefaultTechFSeID = SecureElement::getInstance().EE_HANDLE_0xF4;
- mDefaultTechFPowerstate = 0x3F;
}
}
-
#endif
diff --git a/nci/jni/RoutingManager.h b/nci/jni/RoutingManager.h
index 4761b078..81909bb4 100755
--- a/nci/jni/RoutingManager.h
+++ b/nci/jni/RoutingManager.h
@@ -149,6 +149,7 @@ class RoutingManager {
static RoutingManager& getInstance();
bool initialize(nfc_jni_native_data* native);
+ void deinitialize();
#if (NXP_EXTNS == TRUE)
void setRouting(bool);
void getRouting();
@@ -171,11 +172,6 @@ class RoutingManager {
void nfaEEConnect();
void nfaEEDisconnect();
SyncEvent mEEDisconnectEvt;
- bool setRoutingEntry(int type, int value, int route, int power);
- bool clearRoutingEntry(int type);
- bool setDefaultRoute(const int defaultRoute, const int protoRoute,
- const int techRoute);
- bool clearAidTable();
bool removeNfcid2Routing(uint8_t* nfcID2);
bool addAidRouting(const uint8_t* aid, uint8_t aidLen, int route, int power,
int aidInfo);
@@ -184,7 +180,7 @@ class RoutingManager {
int optparamlen);
void handleSERemovedNtf();
bool is_ee_recovery_ongoing();
- void getDefaultTechFRouteAndPowerState();
+ void setEmptyAidEntry(void);
#if (NXP_NFCC_HCE_F == TRUE)
void notifyT3tConfigure();
#endif
@@ -206,7 +202,19 @@ class RoutingManager {
void deregisterT3tIdentifier(int handle);
void onNfccShutdown();
int registerJniFunctions(JNIEnv* e);
+ bool setNfcSecure(bool enable);
+ void updateRoutingTable();
void ee_removed_disc_ntf_handler(tNFA_HANDLE handle, tNFA_EE_STATUS status);
+ bool setRoutingEntry(int type, int value, int route, int power);
+ bool clearRoutingEntry(int type);
+ bool clearAidTable();
+ void registerProtoRouteEnrty(tNFA_HANDLE ee_handle,
+ tNFA_PROTOCOL_MASK protocols_switch_on,
+ tNFA_PROTOCOL_MASK protocols_switch_off,
+ tNFA_PROTOCOL_MASK protocols_battery_off,
+ tNFA_PROTOCOL_MASK protocols_screen_lock,
+ tNFA_PROTOCOL_MASK protocols_screen_off,
+ tNFA_PROTOCOL_MASK protocols_screen_off_lock);
SyncEvent mLmrtEvent;
SyncEvent mEeSetModeEvent;
SyncEvent mCeRegisterEvent; // FelicaOnHost
@@ -226,23 +234,15 @@ class RoutingManager {
tNFA_STATUS status);
void notifyActivated(uint8_t technology);
void notifyDeactivated(uint8_t technology);
+ tNFA_TECHNOLOGY_MASK updateEeTechRouteSetting();
+ void updateDefaultProtocolRoute();
+ void updateDefaultRoute();
void notifyLmrtFull();
void printMemberData(void);
void extractRouteLocationAndPowerStates(const int defaultRoute,
const int protoRoute,
const int techRoute);
uint16_t getUiccRouteLocId(const int route);
- bool isDefaultIsoDepSupported();
- void initialiseTableEntries(void);
- void compileProtoEntries(void);
- void compileTechEntries(void);
- void consolidateProtoEntries(void);
- void consolidateTechEntries(void);
- void setProtoRouting(void);
-#if (NXP_EXTNS == TRUE)
- void setEmptyAidEntry(void);
-#endif
- void setTechRouting(void);
void processTechEntriesForFwdfunctionality(void);
void configureOffHostNfceeTechMask(void);
void checkProtoSeID(void);
@@ -304,18 +304,28 @@ class RoutingManager {
JNIEnv* e);
static int com_android_nfc_cardemulation_doGetDefaultOffHostRouteDestination(
JNIEnv* e);
-
+ static jbyteArray com_android_nfc_cardemulation_doGetOffHostUiccDestination(
+ JNIEnv* e);
+ static jbyteArray com_android_nfc_cardemulation_doGetOffHostEseDestination(
+ JNIEnv* e);
static int com_android_nfc_cardemulation_doGetAidMatchingMode(JNIEnv* e);
static int com_android_nfc_cardemulation_doGetAidMatchingPlatform(JNIEnv* e);
+ static int com_android_nfc_cardemulation_doGetDefaultIsoDepRouteDestination(
+ JNIEnv* e);
std::vector<uint8_t> mRxDataBuffer;
map<int, uint16_t> mMapScbrHandle;
+ bool mSecureNfcEnabled;
// Fields below are final after initialize()
+ vector<uint8_t> mOffHostRouteUicc;
+ vector<uint8_t> mOffHostRouteEse;
+ int mDefaultFelicaRoute;
int mDefaultOffHostRoute;
int mAidMatchingMode;
int mNfcFOnDhHandle;
bool mIsScbrSupported;
+ int mDefaultIsoDepRoute;
uint16_t mDefaultSysCode;
uint16_t mDefaultSysCodeRoute;
uint8_t mDefaultSysCodePowerstate;
@@ -327,9 +337,9 @@ class RoutingManager {
int mDefaultEe; // since this variable is used in both cases moved out of
// compiler switch
int mHostListnTechMask;
- int mEseListnTechMask;
int mUiccListnTechMask;
int mFwdFuntnEnable;
+ int mHostListnEnable;
static int mChipId;
SyncEvent mEeRegisterEvent;
SyncEvent mRoutingEvent;
diff --git a/nci/jni/SecureElement.cpp b/nci/jni/SecureElement.cpp
index 53ed569c..77dee10a 100755
--- a/nci/jni/SecureElement.cpp
+++ b/nci/jni/SecureElement.cpp
@@ -1202,42 +1202,6 @@ TheEnd:
/*******************************************************************************
**
-** Function: notifyConnectivityListeners
-**
-** Description: Notify the NFC service about a connectivity event from
-*secure element.
-** evtSrc: source of event UICC/eSE.
-**
-** Returns: None
-**
-*******************************************************************************/
-void SecureElement::notifyConnectivityListeners(uint8_t evtSrc) {
- static const char fn[] = "SecureElement::notifyConnectivityListeners";
- DLOG_IF(INFO, nfc_debug_enabled)
- << StringPrintf("%s: enter; evtSrc =%u", fn, evtSrc);
-
- JNIEnv* e = NULL;
- ScopedAttach attach(mNativeData->vm, &e);
- if (e == NULL) {
- LOG(ERROR) << StringPrintf("%s: jni env is null", fn);
- return;
- }
-
- e->CallVoidMethod(mNativeData->manager,
- android::gCachedNfcManagerNotifyConnectivityListeners,
- evtSrc);
- if (e->ExceptionCheck()) {
- e->ExceptionClear();
- LOG(ERROR) << StringPrintf("%s: fail notify", fn);
- goto TheEnd;
- }
-
-TheEnd:
- DLOG_IF(INFO, nfc_debug_enabled) << StringPrintf("%s: exit", fn);
-}
-
-/*******************************************************************************
-**
** Function: notifyEmvcoMultiCardDetectedListeners
**
** Description: Notify the NFC service about a multiple card presented to
@@ -2573,7 +2537,6 @@ void SecureElement::nfaHciCallback(tNFA_HCI_EVT event,
}
// int pipe = (eventData->rcvd_evt.pipe);
// /*commented to eliminate unused variable warning*/
- sSecElem.notifyConnectivityListeners(evtSrc);
} else {
DLOG_IF(INFO, nfc_debug_enabled) << StringPrintf(
"%s: NFA_HCI_EVENT_RCVD_EVT; ################################### "
diff --git a/nci/jni/SecureElement.h b/nci/jni/SecureElement.h
index 903a7be3..c8800c3d 100644
--- a/nci/jni/SecureElement.h
+++ b/nci/jni/SecureElement.h
@@ -425,19 +425,6 @@ class SecureElement {
/*******************************************************************************
**
- ** Function: notifyConnectivityListeners
- **
- ** Description: Notify the NFC service about a connectivity event from
- *secure element.
- ** evtSrc: source of event UICC/eSE.
- **
- ** Returns: None
- **
- *******************************************************************************/
- void notifyConnectivityListeners(uint8_t evtSrc);
-
- /*******************************************************************************
- **
** Function: notifyEmvcoMultiCardDetectedListeners
**
** Description: Notify the NFC service about a multiple card presented to
diff --git a/nci/jni/TransactionController.h b/nci/jni/TransactionController.h
index a3210d88..06a9c0fa 100644..100755
--- a/nci/jni/TransactionController.h
+++ b/nci/jni/TransactionController.h
@@ -40,7 +40,6 @@ typedef enum transactionId {
NFA_EE_ACTION_EVENT,
NFA_TRANS_CE_ACTIVATED_EVENT,
etsiReader,
- jcosDownload,
setScreenState,
staticDualUicc,
getTransanctionRequest,
diff --git a/nci/src/com/android/nfc/dhimpl/NativeNfcManager.java b/nci/src/com/android/nfc/dhimpl/NativeNfcManager.java
index 84b2a2b1..f3b3399a 100755
--- a/nci/src/com/android/nfc/dhimpl/NativeNfcManager.java
+++ b/nci/src/com/android/nfc/dhimpl/NativeNfcManager.java
@@ -14,38 +14,32 @@
* limitations under the License.
*/
/******************************************************************************
- *
- * The original Work has been changed by NXP Semiconductors.
- *
- * Copyright (C) 2015-2018 NXP Semiconductors
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- ******************************************************************************/
+*
+* The original Work has been changed by NXP.
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*
+* Copyright 2018-2019 NXP
+*
+******************************************************************************/
package com.android.nfc.dhimpl;
-import android.annotation.SdkConstant;
-import android.annotation.SdkConstant.SdkConstantType;
import android.content.Context;
-import android.content.SharedPreferences;
import android.nfc.ErrorCodes;
import android.nfc.tech.Ndef;
import android.nfc.tech.TagTechnology;
import android.util.Log;
-import java.io.File;
-import java.util.HashMap;
-import java.util.Map;
import com.android.nfc.DeviceHost;
import com.android.nfc.LlcpException;
import com.android.nfc.NfcDiscoveryParameters;
@@ -55,37 +49,22 @@ import java.util.Arrays;
import java.util.Iterator;
import java.util.HashMap;
-
/**
* Native interface to the NFC Manager functions
*/
public class NativeNfcManager implements DeviceHost {
private static final String TAG = "NativeNfcManager";
- private static final long FIRMWARE_MODTIME_DEFAULT = -1;
static final String PREF = "NciDeviceHost";
static final int DEFAULT_LLCP_MIU = 1980;
static final int DEFAULT_LLCP_RWSIZE = 2;
- static final int PN547C2_ID = 1;
- static final int PN65T_ID = 2;
- static final int PN548C2_ID = 3;
- static final int PN66T_ID = 4;
- static final int PN551_ID = 5;
- static final int PN67T_ID = 6;
- static final int PN553_ID = 7;
- static final int PN80T_ID = 8;
static final String DRIVER_NAME = "android-nci";
- private static final byte[][] EE_WIPE_APDUS = {};
-
static {
System.loadLibrary("nfc_nci_jni");
}
- @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
- public static final String INTERNAL_TARGET_DESELECTED_ACTION = "com.android.nfc.action.INTERNAL_TARGET_DESELECTED";
-
/* Native structure */
private long mNative;
@@ -93,35 +72,32 @@ public class NativeNfcManager implements DeviceHost {
private final DeviceHostListener mListener;
private final NativeNfcMposManager mMposMgr;
private final Context mContext;
- private Map<String, Integer> mNfcid2ToHandle;
+
private final Object mLock = new Object();
private final HashMap<Integer, byte[]> mT3tIdentifiers = new HashMap<Integer, byte[]>();
+
public NativeNfcManager(Context context, DeviceHostListener listener) {
mListener = listener;
initializeNativeStructure();
mContext = context;
- mNfcid2ToHandle = new HashMap<String, Integer>();
mMposMgr = new NativeNfcMposManager();
}
public native boolean initializeNativeStructure();
private native boolean doDownload();
+
+ public native int doGetLastError();
+
@Override
- public boolean download() {
+ public boolean checkFirmware() {
return doDownload();
}
-
- public native int doGetLastError();
+ public native int doaccessControlForCOSU (int mode);
@Override
- public void checkFirmware() {
- if(doDownload()) {
- Log.d(TAG,"FW Download Success");
- }
- else {
- Log.d(TAG,"FW Download Failed");
- }
+ public int accessControlForCOSU (int mode) {
+ return doaccessControlForCOSU (mode);
}
private native boolean doInitialize();
@@ -130,17 +106,6 @@ public class NativeNfcManager implements DeviceHost {
@Override
public boolean initialize() {
- SharedPreferences prefs = mContext.getSharedPreferences(PREF, Context.MODE_PRIVATE);
- SharedPreferences.Editor editor = prefs.edit();
-
- if (prefs.getBoolean(NativeNfcSecureElement.PREF_SE_WIRED, false)) {
- try {
- Thread.sleep (12000);
- editor.putBoolean(NativeNfcSecureElement.PREF_SE_WIRED, false);
- editor.apply();
- } catch (InterruptedException e) { }
- }
-
boolean ret = doInitialize();
mIsoDepMaxTransceiveLength = getIsoDepMaxTransceiveLength();
return ret;
@@ -150,7 +115,6 @@ public class NativeNfcManager implements DeviceHost {
@Override
public void enableDtaMode() {
- Log.d(TAG,"enableDtaMode : entry");
doEnableDtaMode();
}
@@ -180,12 +144,6 @@ public class NativeNfcManager implements DeviceHost {
@Override
public boolean deinitialize() {
- SharedPreferences prefs = mContext.getSharedPreferences(PREF, Context.MODE_PRIVATE);
- SharedPreferences.Editor editor = prefs.edit();
-
- editor.putBoolean(NativeNfcSecureElement.PREF_SE_WIRED, false);
- editor.apply();
-
return doDeinitialize();
}
@@ -197,49 +155,28 @@ public class NativeNfcManager implements DeviceHost {
@Override
public native boolean sendRawFrame(byte[] data);
- @Override
- public boolean routeAid(byte[] aid, int route, int powerState, int aidInfo) {
-
- boolean status = true;
- //if(mIsAidFilterSupported) {
- //Prepare a cache of AIDs, and only send when vzwSetFilterList is called.
- // mAidFilter.addAppAidToCache(aid, route, powerState);
- // } else {
-
- status = doRouteAid(aid, route, powerState, aidInfo);
-
- //}
-
- return status;
- }
-
- public native boolean doRouteAid(byte[] aid, int route, int powerState, int aidInfo);
-
- @Override
- public native boolean routeApduPattern(int route, int powerState, byte[] apduData, byte[] apduMask);
+ public native boolean doClearRoutingEntry(int type );
@Override
- public native boolean setDefaultRoute(int defaultRouteEntry, int defaultProtoRouteEntry, int defaultTechRouteEntry);
+ public boolean clearRoutingEntry( int type ) {
+ return(doClearRoutingEntry( type ));
+ }
+ public native boolean doSetRoutingEntry(int type, int value, int route, int power);
@Override
- public boolean unrouteAid(byte[] aid) {
- // if(mIsAidFilterSupported) {
- //Remove AID entry from cache.
- // mAidFilter.removeAppAidToCache(aid);
- // }
-
- return doUnrouteAid(aid);
+ public boolean setRoutingEntry(int type, int value, int route, int power) {
+ return(doSetRoutingEntry(type, value, route, power));
}
- public native boolean doUnrouteAid(byte[] aid);
+ @Override
+ public native boolean routeAid(byte[] aid, int route, int aidInfo, int powerState);
- public native boolean clearAidTable();
@Override
- public native void doSetProvisionMode(boolean provisionMode);
+ public native boolean unrouteAid(byte[] aid);
@Override
- public native int getRemainingAidTableSize();
+ public native boolean routeApduPattern(int route, int powerState, byte[] apduData, byte[] apduMask);
@Override
public native int getAidTableSize();
@@ -254,10 +191,10 @@ public class NativeNfcManager implements DeviceHost {
public native int getDefaultMifareCLTRoute();
@Override
- public native int getDefaultAidPowerState();
+ public native int getDefaultFelicaCLTRoute();
@Override
- public native int doNfcSelfTest(int type);
+ public native int getDefaultAidPowerState();
@Override
public native int getDefaultDesfirePowerState();
@@ -266,97 +203,89 @@ public class NativeNfcManager implements DeviceHost {
public native int getDefaultMifareCLTPowerState();
@Override
- public native boolean unrouteApduPattern(byte[] apduData);
+ public native int getDefaultFelicaCLTPowerState();
@Override
- public native void doSetScreenOrPowerState(int state);
+ public native int getGsmaPwrState();
@Override
- public native void doSetScreenState(int screen_state_mask);
+ public native boolean commitRouting();
@Override
- public native void doEnablep2p(boolean p2pFlag);
+ public native void doChangeDiscoveryTech(int pollTech, int listenTech);
- public native boolean doSetRoutingEntry(int type, int value, int route, int power);
@Override
- public boolean setRoutingEntry(int type, int value, int route, int power) {
- return(doSetRoutingEntry(type, value, route, power));
- }
- public native boolean doClearRoutingEntry(int type );
+ public native void setEmptyAidRoute(int deafultAidroute);
@Override
- public boolean clearRoutingEntry( int type ) {
- return(doClearRoutingEntry( type ));
- }
-
- @Override
- public native void doSetSecureElementListenTechMask(int tech_mask);
+ public native boolean unrouteApduPattern(byte[] apduData);
@Override
- public native int getNciVersion();
+ public native int[] doGetActiveSecureElementList();
- private native void doEnableDiscovery(int techMask,
- boolean enableLowPowerPolling,
- boolean enableReaderMode,
- boolean enableP2p,
- boolean restart);
+ public native int doRegisterT3tIdentifier(byte[] t3tIdentifier);
@Override
- public void enableDiscovery(NfcDiscoveryParameters params, boolean restart) {
- doEnableDiscovery(params.getTechMask(), params.shouldEnableLowPowerDiscovery(),
- params.shouldEnableReaderMode(), params.shouldEnableP2p(), restart);
+ public void registerT3tIdentifier(byte[] t3tIdentifier) {
+ synchronized (mLock) {
+ int handle = doRegisterT3tIdentifier(t3tIdentifier);
+ if (handle != 0xffff) {
+ mT3tIdentifiers.put(Integer.valueOf(handle), t3tIdentifier);
+ }
+ }
}
- @Override
- public native void disableDiscovery();
-
- @Override
- public native int[] doGetSecureElementList();
-
- @Override
- public native void doSelectSecureElement(int seID);
-
- @Override
- public native void doActivateSecureElement(int seID);
-
- @Override
- public native void doDeselectSecureElement(int seID);
-
- @Override
- public native void doSetSEPowerOffState(int seID, boolean enable);
-
- @Override
- public native void setDefaultTechRoute(int seID, int tech_switchon, int tech_switchoff);
-
- @Override
- public native void setDefaultProtoRoute(int seID, int proto_switchon, int proto_switchoff);
-
- @Override
- public native int getChipVer();
+ public native void doDeregisterT3tIdentifier(int handle);
@Override
- public native int setTransitConfig(String configs);
-
+ public void deregisterT3tIdentifier(byte[] t3tIdentifier) {
+ synchronized (mLock) {
+ Iterator<Integer> it = mT3tIdentifiers.keySet().iterator();
+ while (it.hasNext()) {
+ int handle = it.next().intValue();
+ byte[] value = mT3tIdentifiers.get(handle);
+ if (Arrays.equals(value, t3tIdentifier)) {
+ doDeregisterT3tIdentifier(handle);
+ mT3tIdentifiers.remove(handle);
+ break;
+ }
+ }
+ }
+ }
@Override
- public native int getNfcInitTimeout();
+ public void clearT3tIdentifiersCache() {
+ synchronized (mLock) {
+ mT3tIdentifiers.clear();
+ }
+ }
@Override
- public native int JCOSDownload();
+ public native int getLfT3tMax();
@Override
- public native void doSetNfcMode(int nfcMode);
+ public native void doSetScreenState(int screen_state_mask);
@Override
- public native int GetDefaultSE();
+ public native int getNciVersion();
+ private native void doEnableDiscovery(int techMask,
+ boolean enableLowPowerPolling,
+ boolean enableReaderMode,
+ boolean enableHostRouting,
+ boolean enableP2p,
+ boolean restart);
@Override
- public native boolean isVzwFeatureEnabled();
+ public void enableDiscovery(NfcDiscoveryParameters params, boolean restart) {
+ doEnableDiscovery(params.getTechMask(), params.shouldEnableLowPowerDiscovery(),
+ params.shouldEnableReaderMode(), params.shouldEnableHostRouting(),
+ params.shouldEnableP2p(), restart);
+ }
@Override
- public native boolean isNfccBusy();
+ public native void disableDiscovery();
- @Override
+ @Override
public void setEtsiReaederState(int newState) {
mMposMgr.doSetEtsiReaederState(newState);
}
@@ -408,9 +337,6 @@ public class NativeNfcManager implements DeviceHost {
return mMposMgr.doMposGetReaderMode();
}
- @Override
- public native void updateScreenState();
-
private native NativeLlcpConnectionlessSocket doCreateLlcpConnectionlessSocket(int nSap,
String sn);
@@ -488,9 +414,6 @@ public class NativeNfcManager implements DeviceHost {
public native boolean doCheckLlcp();
@Override
- public native boolean doCheckJcopDlAtBoot();
-
- @Override
public native boolean doActivateLlcp();
private native void doResetTimeouts();
@@ -518,8 +441,7 @@ public class NativeNfcManager implements DeviceHost {
@Override
public boolean canMakeReadOnly(int ndefType) {
- return (ndefType == Ndef.TYPE_1 || ndefType == Ndef.TYPE_2 ||
- ndefType == Ndef.TYPE_MIFARE_CLASSIC);
+ return (ndefType == Ndef.TYPE_1 || ndefType == Ndef.TYPE_2);
}
@Override
@@ -546,9 +468,6 @@ public class NativeNfcManager implements DeviceHost {
}
- @Override
- public native int setEmvCoPollProfile(boolean enable, int route);
-
private native void doSetP2pInitiatorModes(int modes);
@Override
public void setP2pInitiatorModes(int modes) {
@@ -564,16 +483,9 @@ public class NativeNfcManager implements DeviceHost {
@Override
public boolean getExtendedLengthApdusSupported() {
/* 261 is the default size if extended length frames aren't supported */
- if (getMaxTransceiveLength(TagTechnology.ISO_DEP) > 261) {
+ if (getMaxTransceiveLength(TagTechnology.ISO_DEP) > 261)
return true;
- } else {
- return false;
- }
- }
-
- @Override
- public byte[][] getWipeApdus() {
- return EE_WIPE_APDUS;
+ return false;
}
@Override
@@ -606,131 +518,11 @@ public class NativeNfcManager implements DeviceHost {
return true;
}
- //private native void doEnableReaderMode(int technologies);
- //@Override
- //public boolean enableScreenOffSuspend() {
- // doEnableScreenOffSuspend();
- //return true;
- //}
-
- //private native void doDisableScreenOffSuspend();
- //@Override
- //public boolean disableScreenOffSuspend() {
- // doDisableScreenOffSuspend();
- // return true;
- //}
-
-
- private native void doCommitRouting();
-
- @Override
- public native int doGetSecureElementTechList();
-
- public native int doRegisterT3tIdentifier(byte[] t3tIdentifier);
-
- @Override
- public void registerT3tIdentifier(byte[] t3tIdentifier) {
- Log.d(TAG, " registerT3tIdentifier entry");
- synchronized (mLock) {
- int handle = doRegisterT3tIdentifier(t3tIdentifier);
- if (handle != 0xffff) {
- mT3tIdentifiers.put(Integer.valueOf(handle), t3tIdentifier);
- }
- }
- Log.d(TAG, "registerT3tIdentifier exit");
- }
-
- public native void doDeregisterT3tIdentifier(int handle);
-
- @Override
- public void deregisterT3tIdentifier(byte[] t3tIdentifier) {
- Log.d(TAG, "deregisterT3tIdentifier entry");
- synchronized (mLock) {
- Iterator<Integer> it = mT3tIdentifiers.keySet().iterator();
- while (it.hasNext()) {
- int handle = it.next().intValue();
- byte[] value = mT3tIdentifiers.get(handle);
- if (Arrays.equals(value, t3tIdentifier)) {
- doDeregisterT3tIdentifier(handle);
- mT3tIdentifiers.remove(handle);
- break;
- }
- }
- }
- Log.d(TAG, "deregisterT3tIdentifier exit");
- }
-
- @Override
- public void clearT3tIdentifiersCache() {
- Log.d(TAG, "clearT3tIdentifiersCache entry");
- synchronized (mLock) {
- mT3tIdentifiers.clear();
- }
- Log.d(TAG, "clearT3tIdentifiersCache exit");
- }
-
- @Override
- public native int getLfT3tMax();
-
-
- @Override
- public native int[] doGetActiveSecureElementList();
-
-
- public native byte[] doGetSecureElementUid();
-
+ private native boolean doSetNfcSecure(boolean enable);
@Override
- public byte[] getSecureElementUid()
- {
- byte[] buff;
- buff = doGetSecureElementUid();
- if(buff==null)
- {
- //Avoiding Null pointer Exception creating new byte array
- buff = new byte[0];
- Log.d(TAG,"buff : " + buff);
- }
- return buff;
+ public boolean setNfcSecure(boolean enable) {
+ return doSetNfcSecure(enable);
}
- @Override
- public void commitRouting() {
- doCommitRouting();
- }
-
- @Override
- public native void doPrbsOn(int prbs, int hw_prbs, int tech, int rate);
-
- @Override
- public native void doPrbsOff();
-
- @Override
- public native int SWPSelfTest(int ch);
-
- @Override
- public native int getFWVersion();
-
- @Override
- public native void doSetEEPROM(byte[] val);
-
- @Override
- public native byte[] doGetRouting();
-
- @Override
- public native int doselectUicc(int uiccSlot);
-
- @Override
- public native int doGetSelectedUicc();
-
- /**
- * This api internally used to set preferred sim slot to select UICC
- */
- @Override
- public native int setPreferredSimSlot(int uiccSlot);
-
- @Override
- public native byte[] readerPassThruMode(byte status, byte modulationTyp);
-
- @Override public native byte[] transceiveAppData(byte[] data);
/**
* Notifies Ndef Message (TODO: rename into notifyTargetDiscovered)
@@ -738,28 +530,17 @@ public class NativeNfcManager implements DeviceHost {
private void notifyNdefMessageListeners(NativeNfcTag tag) {
mListener.onRemoteEndpointDiscovered(tag);
}
-
- /**
- * Notifies transaction
- */
- private void notifyTargetDeselected() {
- mListener.onCardEmulationDeselected();
+ private void notifySeListenActivated() {
+ mListener.onSeListenActivated();
}
- /**
- * Notifies transaction
- */
- private void notifyConnectivityListeners(int evtSrc) {
- mListener.onConnectivityEvent(evtSrc);
+ private void notifySeListenDeactivated() {
+ mListener.onSeListenDeactivated();
}
- /**
- * Notifies transaction
- */
- private void notifyEmvcoMultiCardDetectedListeners() {
- mListener.onEmvcoMultiCardDetectedEvent();
+ private void notifySeInitialized() {
+ mListener.onSeInitialized();
}
-
/**
* Notifies P2P Device detected, to activate LLCP link
*/
@@ -781,22 +562,6 @@ public class NativeNfcManager implements DeviceHost {
mListener.onLlcpFirstPacketReceived(device);
}
- private void notifySeFieldActivated() {
- mListener.onRemoteFieldActivated();
- }
-
- private void notifySeFieldDeactivated() {
- mListener.onRemoteFieldDeactivated();
- }
-
- private void notifyJcosDownloadInProgress(int enable) {
- mListener.onRestartWatchDog(enable);
- }
-
- private void notifyFwDwnldRequested() {
- mListener.onFwDwnldReqRestartNfc();
- }
-
/* Reader over SWP listeners*/
private void notifyETSIReaderRequested(boolean istechA, boolean istechB) {
mListener.onETSIReaderRequestedEvent(istechA, istechB);
@@ -814,44 +579,16 @@ public class NativeNfcManager implements DeviceHost {
mListener.onETSIReaderModeStopConfig(disc_ntf_timeout);
}
- private void notifyonETSIReaderModeSwpTimeout(int disc_ntf_timeout) {
- mListener.onETSIReaderModeSwpTimeout(disc_ntf_timeout);
- }
-
- private void notifyonETSIReaderModeRestart() {
- mListener.onETSIReaderModeRestart();
- }
-
- private void notifySeListenActivated() {
- mListener.onSeListenActivated();
- }
-
- private void notifySeListenDeactivated() {
- mListener.onSeListenDeactivated();
- }
-
- private void notifySeApduReceived(byte[] apdu) {
- mListener.onSeApduReceived(apdu);
- }
-
- private void notifySeEmvCardRemoval() {
- mListener.onSeEmvCardRemoval();
- }
-
- private void notifySeMifareAccess(byte[] block) {
- mListener.onSeMifareAccess(block);
- }
-
private void notifyHostEmuActivated(int technology) {
mListener.onHostCardEmulationActivated(technology);
}
- private void notifyT3tConfigure() {
- mListener.onNotifyT3tConfigure();
+ private void notifyonETSIReaderModeSwpTimeout(int disc_ntf_timeout) {
+ mListener.onETSIReaderModeSwpTimeout(disc_ntf_timeout);
}
- private void notifyReRoutingEntry() {
- mListener.onNotifyReRoutingEntry();
+ private void notifyonETSIReaderModeRestart() {
+ mListener.onETSIReaderModeRestart();
}
private void notifyHostEmuData(int technology, byte[] data) {
@@ -862,10 +599,6 @@ public class NativeNfcManager implements DeviceHost {
mListener.onHostCardEmulationDeactivated(technology);
}
- private void notifyAidRoutingTableFull() {
- mListener.onAidRoutingTableFull();
- }
-
private void notifyRfFieldActivated() {
mListener.onRemoteFieldActivated();
}
@@ -874,22 +607,26 @@ public class NativeNfcManager implements DeviceHost {
mListener.onRemoteFieldDeactivated();
}
- private void notifyUiccStatusEvent(int uiccStat) {
- mListener.onUiccStatusEvent(uiccStat);
- }
-
private void notifyTransactionListeners(byte[] aid, byte[] data, String evtSrc) {
mListener.onNfcTransactionEvent(aid, data, evtSrc);
}
-
- static String toHexString(byte[] buffer, int offset, int length) {
- final char[] HEX_CHARS = "0123456789abcdef".toCharArray();
- char[] chars = new char[2 * length];
- for (int j = offset; j < offset + length; ++j) {
- chars[2 * (j - offset)] = HEX_CHARS[(buffer[j] & 0xF0) >>> 4];
- chars[2 * (j - offset) + 1] = HEX_CHARS[buffer[j] & 0x0F];
- }
- return new String(chars);
- }
-
+/* NXP extension are here */
+ @Override
+ public native int getFWVersion();
+ @Override
+ public native byte[] readerPassThruMode(byte status, byte modulationTyp);
+ @Override
+ public native byte[] transceiveAppData(byte[] data);
+ @Override
+ public native boolean isNfccBusy();
+ @Override
+ public native int setTransitConfig(String configs);
+ @Override
+ public native int getRemainingAidTableSize();
+ @Override
+ public native int doselectUicc(int uiccSlot);
+ @Override
+ public native int doGetSelectedUicc();
+ @Override
+ public native int setPreferredSimSlot(int uiccSlot);
}
diff --git a/nci/src/com/android/nfc/dhimpl/NativeNfcSecureElement.java b/nci/src/com/android/nfc/dhimpl/NativeNfcSecureElement.java
index 69b550c7..d27aaec2 100755
--- a/nci/src/com/android/nfc/dhimpl/NativeNfcSecureElement.java
+++ b/nci/src/com/android/nfc/dhimpl/NativeNfcSecureElement.java
@@ -1,43 +1,26 @@
-/*
- * Copyright (C) 2010 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
/******************************************************************************
- *
- * The original Work has been changed by NXP Semiconductors.
- *
- * Copyright (C) 2015 NXP Semiconductors
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- ******************************************************************************/
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*
+* Copyright 2018 NXP
+*
+******************************************************************************/
package com.android.nfc.dhimpl;
import android.content.Context;
import android.content.SharedPreferences;
-
+import android.util.Log;
/**
* Native interface to the NFC Secure Element functions
@@ -47,7 +30,6 @@ import android.content.SharedPreferences;
public class NativeNfcSecureElement {
static final String PREF_SE_WIRED = "se_wired";
-
private final Context mContext;
SharedPreferences mPrefs;
@@ -60,13 +42,13 @@ public class NativeNfcSecureElement {
mPrefsEditor = mPrefs.edit();
}
- private native int doNativeOpenSecureElementConnection(int seId);
+ private native int doNativeOpenSecureElementConnection();
- public int doOpenSecureElementConnection(int seId) {
+ public int doOpenSecureElementConnection() {
mPrefsEditor.putBoolean(PREF_SE_WIRED, true);
mPrefsEditor.apply();
- return doNativeOpenSecureElementConnection(seId);
+ return doNativeOpenSecureElementConnection();
}
private native boolean doNativeDisconnectSecureElementConnection(int handle);
@@ -80,19 +62,12 @@ public class NativeNfcSecureElement {
//TODO: Just stub for compilation
public boolean doReset(int handle) {
- //return false;
return doNativeResetSecureElement(handle);
}
- //TODO: Just stub for compilation
- public boolean doeSEChipReset() {
- //return false;
- return doNativeeSEChipResetSecureElement();
- }
//TODO: Just stub for compilation
public byte[] doGetAtr (int handle) {
-
return doNativeGetAtr(handle);
}
@@ -100,9 +75,4 @@ public class NativeNfcSecureElement {
private native boolean doNativeResetSecureElement(int handle);
public native byte[] doTransceive(int handle, byte[] data);
- public native int[] doGetTechList(int handle);
-
- public native byte [] doGetUid(int handle);
- private native boolean doNativeeSEChipResetSecureElement();
-
}
diff --git a/nci/src/com/android/nfc/dhimpl/NativeNfcTag.java b/nci/src/com/android/nfc/dhimpl/NativeNfcTag.java
index 7c66f33f..afe54221 100755
--- a/nci/src/com/android/nfc/dhimpl/NativeNfcTag.java
+++ b/nci/src/com/android/nfc/dhimpl/NativeNfcTag.java
@@ -13,25 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-/******************************************************************************
- *
- * The original Work has been changed by NXP Semiconductors.
- *
- * Copyright (C) 2015 NXP Semiconductors
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- ******************************************************************************/
+
package com.android.nfc.dhimpl;
import android.annotation.Nullable;
@@ -153,9 +135,9 @@ public class NativeNfcTag implements TagEndpoint {
}
}
- //synchronized (NativeNfcTag.this) {
+ synchronized (NativeNfcTag.this) {
mIsPresent = false;
- //}
+ }
// Restart the polling loop
Log.d(TAG, "Tag lost, restarting polling loop");
@@ -174,7 +156,6 @@ public class NativeNfcTag implements TagEndpoint {
}
int status = -1;
for (int i = 0; i < mTechList.length; i++) {
- Log.d(TAG,"connectWithStatus- technology ="+technology);
if (mTechList[i] == technology) {
// Get the handle and connect, if not already connected
if (mConnectedHandle != mTechHandles[i]) {
@@ -842,7 +823,6 @@ public class NativeNfcTag implements TagEndpoint {
getConnectedLibNfcType(),
getConnectedTechnology(),
supportedNdefLength, cardState);
- foundFormattable = false;
reconnect();
} catch (FormatException e) {
// Create an intent anyway, without NDEF messages
diff --git a/nci/src/com/gsma/nfc/internal/NxpNfcController.java b/nci/src/com/gsma/nfc/internal/NxpNfcController.java
deleted file mode 100644
index d7dc1c2b..00000000
--- a/nci/src/com/gsma/nfc/internal/NxpNfcController.java
+++ /dev/null
@@ -1,428 +0,0 @@
-/*
-* Copyright (C) 2015 NXP Semiconductors
-*
-* Licensed under the Apache License, Version 2.0 (the "License");
-* you may not use this file except in compliance with the License.
-* You may obtain a copy of the License at
-*
-* http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS,
-* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-* See the License for the specific language governing permissions and
-* limitations under the License.
-*/
-package com.gsma.nfc.internal;
-
-import android.content.Context;
-import android.content.Intent;
-
-import java.util.List;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.Map;
-import android.content.BroadcastReceiver;
-import android.content.pm.ResolveInfo;
-import android.content.pm.PackageInfo;
-
-import android.util.Log;
-import com.nxp.nfc.gsma.internal.INxpNfcController;
-import com.android.nfc.cardemulation.CardEmulationManager;
-import com.android.nfc.cardemulation.RegisteredAidCache;
-import android.nfc.cardemulation.NxpApduServiceInfo;
-import android.os.Binder;
-import android.content.ComponentName;
-import android.content.pm.PackageManager;
-import android.content.pm.PackageManager.NameNotFoundException;
-import com.android.nfc.NfcPermissions;
-import com.android.nfc.NfcService;
-import com.nxp.nfc.NxpConstants;
-import android.nfc.NfcAdapter;
-
-public class NxpNfcController {
-
- private static int ROUTING_TABLE_EE_MAX_AID_CFG_LEN = 580;
- public static final int PN65T_ID = 2;
- public static final int PN66T_ID = 4;
-
-
- private Context mContext;
- final NxpNfcControllerInterface mNxpNfcControllerInterface;
- final RegisteredNxpServicesCache mServiceCache;
- private RegisteredAidCache mRegisteredAidCache;
- private CardEmulationManager mCardEmulationManager;
- private boolean mGsmaCommitOffhostService = false;
- static final String TAG = "NxpNfcController";
- boolean DBG = true;
-
- public ArrayList<String> mEnabledMultiEvts = new ArrayList<String>();
- public final HashMap<String, Boolean> mMultiReceptionMap = new HashMap<String, Boolean>();
- //private NfcService mService;
- private Object mWaitCheckCert = null;
- private boolean mHasCert = false;
- private Object mWaitOMACheckCert = null;
- private boolean mHasOMACert = false;
- private ComponentName unicastPkg = null;
-
- public NxpNfcController(Context context, CardEmulationManager cardEmulationManager) {
- mContext = context;
- mCardEmulationManager = cardEmulationManager;
- mServiceCache = cardEmulationManager.getRegisteredNxpServicesCache();
- mRegisteredAidCache = cardEmulationManager.getRegisteredAidCache();
- mNxpNfcControllerInterface = new NxpNfcControllerInterface();
- }
-
- public INxpNfcController getNxpNfcControllerInterface() {
- if(mNxpNfcControllerInterface != null) {
- Log.d("NxpNfcController", "GSMA: mNxpNfcControllerInterface is not Null");
- return mNxpNfcControllerInterface;
- }
- return null;
- }
-
- public ArrayList<String> getEnabledMultiEvtsPackageList() {
- if(mEnabledMultiEvts.size() == 0x00) {
- Log.d(TAG, " check for unicast mode service resolution");
- getPackageListUnicastMode();
- }
- return mEnabledMultiEvts;
- }
-
- public void setResultForCertificates(boolean result) {
- Log.d(TAG, "setResultForCertificates() Start");
- if (mWaitCheckCert != null) {
- synchronized (mWaitCheckCert) {
- if (result) {
- mHasCert = true;
- } else {
- mHasCert = false;
- }
- mWaitCheckCert.notify();
- }
- }
- Log.d(TAG, "setResultForCertificates() End");
- }
-
- private boolean checkCertificatesFromUICC(String pkg, String seName) {
- Log.d(TAG, "checkCertificatesFromUICC() " + pkg + ", " + seName);
- Intent CertificateIntent = new Intent();
- CertificateIntent.setAction(NxpConstants.ACTION_CHECK_X509);
- CertificateIntent.setPackage(NxpConstants.SET_PACKAGE_NAME);
- CertificateIntent.putExtra(NfcAdapter.EXTRA_SECURE_ELEMENT_NAME, seName);
- CertificateIntent.putExtra(NxpConstants.EXTRA_PKG, pkg);
- mContext.sendBroadcast(CertificateIntent);
-
- mWaitCheckCert = new Object();
- mHasCert = false;
- try {
- synchronized (mWaitCheckCert) {
- mWaitCheckCert.wait(1000); // timeout ms
- }
- } catch (InterruptedException e) {
- Log.w(TAG, "interruped exception .");
- }
- mWaitCheckCert = null;
-
- if (mHasCert) {
- return true;
- } else {
- return false;
- }
- }
-
- private boolean checkX509CertificatesFromSim (String pkg, String seName) {
- if (DBG) Log.d(TAG, "checkX509CertificatesFromSim() " + pkg + ", " + seName);
-
- Intent checkCertificateIntent = new Intent();
- checkCertificateIntent.setAction("org.simalliance.openmobileapi.service.ACTION_CHECK_X509");
- checkCertificateIntent.setPackage("org.simalliance.openmobileapi.service");
- checkCertificateIntent.putExtra("org.simalliance.openmobileapi.service.EXTRA_SE_NAME", seName);
- checkCertificateIntent.putExtra("org.simalliance.openmobileapi.service.EXTRA_PKG", pkg);
- mContext.sendBroadcast(checkCertificateIntent);
-
- mWaitOMACheckCert = new Object();
- mHasOMACert = false;
- try {
- synchronized (mWaitOMACheckCert) {
- mWaitOMACheckCert.wait(1000); //add timeout ms
- }
- } catch (InterruptedException e) {
- // Should not happen; fall-through to abort.
- Log.w(TAG, "interruped.");
- }
- mWaitOMACheckCert = null;
-
- if (mHasOMACert) {
- return true;
- } else {
- return false;
- }
- }
-
- public void setResultForX509Certificates(boolean result) {
- Log.d(TAG, "setResultForX509Certificates() Start");
- if (mWaitOMACheckCert != null) {
- synchronized (mWaitOMACheckCert) {
- if (result) {
- mHasOMACert = true;
- } else {
- mHasOMACert = false;
- }
- mWaitOMACheckCert.notify();
- }
- }
- Log.d(TAG, "setResultForX509Certificates() End");
- }
-
- public boolean isGsmaCommitOffhostService() {
- return mGsmaCommitOffhostService;
- }
-
- static byte[] hexStringToBytes(String s) {
- if (s == null || s.length() == 0) return null;
- int len = s.length();
- if (len % 2 != 0) {
- s = '0' + s;
- len++;
- }
- byte[] data = new byte[len / 2];
- for (int i = 0; i < len; i += 2) {
- data[i / 2] = (byte) ((Character.digit(s.charAt(i), 16) << 4)
- + Character.digit(s.charAt(i + 1), 16));
- }
- return data;
- }
-
- private long getApplicationInstallTime(String packageName) {
- PackageManager pm = mContext.getPackageManager();
- try {
- PackageInfo pInfo = pm.getPackageInfo(packageName ,0);
- return pInfo.firstInstallTime;
- }catch(NameNotFoundException exception) {
- Log.e(TAG, "Application install time not retrieved");
- return 0;
- }
- }
-
- private void getPackageListUnicastMode () {
- unicastPkg = null;
- List<NxpApduServiceInfo> regServices = mCardEmulationManager.getAllServices();
- PackageManager pm = mContext.getPackageManager();
- List<ResolveInfo> intentServices = pm.queryIntentActivities(
- new Intent(NxpConstants.ACTION_MULTI_EVT_TRANSACTION),
- PackageManager.GET_INTENT_FILTERS| PackageManager.GET_RESOLVED_FILTER);
- ArrayList<String> apduResolvedServices = new ArrayList<String>();
- String packageName = null;
- String resolvedApduService = null;
- int highestPriority = -1000;
- long minInstallTime;
- ResolveInfo resolveInfoService = null;
-
- for(NxpApduServiceInfo service : regServices) {
- packageName = service.getComponent().getPackageName();
- for(ResolveInfo resInfo : intentServices){
- resolveInfoService = null;
- Log.e(TAG, " Registered Service in resolved cache"+resInfo.activityInfo.packageName);
- if(resInfo.activityInfo.packageName.equals(packageName)) {
- resolveInfoService = resInfo;
- break;
- }
- }
- if(resolveInfoService == null) {
- Log.e(TAG, " Registered Service is not found in cache");
- continue;
- }
- int priority = resolveInfoService.priority;
- if((pm.checkPermission(NxpConstants.PERMISSIONS_TRANSACTION_EVENT , packageName) == PackageManager.PERMISSION_GRANTED) &&
- (pm.checkPermission(NxpConstants.PERMISSIONS_NFC , packageName) == PackageManager.PERMISSION_GRANTED))
- {
- if((checkCertificatesFromUICC(packageName, "SIM") == true) ||
- (checkCertificatesFromUICC(packageName, "SIM1") == true))
- {
- if(priority == highestPriority) {
- apduResolvedServices.add(packageName);
- } else if(highestPriority < priority) {
- highestPriority = priority;
- apduResolvedServices.clear();
- apduResolvedServices.add(packageName);
- }
- }
- }
- }
- if(apduResolvedServices.size() == 0x00) {
- Log.e(TAG, "No services to resolve, not starting the activity");
- return;
- }else if(apduResolvedServices.size() > 0x01) {
- Log.e(TAG, " resolved"+apduResolvedServices.size());
- minInstallTime = getApplicationInstallTime(apduResolvedServices.get(0));
- for(String resolvedService : apduResolvedServices) {
- if(getApplicationInstallTime(resolvedService) <= minInstallTime ) {
- minInstallTime = getApplicationInstallTime(resolvedService);
- resolvedApduService = resolvedService;
- }
- Log.e(TAG, " Install time of application"+ minInstallTime);
- }
-
- } else resolvedApduService = apduResolvedServices.get(0);
-
- Log.e(TAG, " Final Resolved Service"+resolvedApduService);
- if(resolvedApduService != null) {
- for(ResolveInfo resolve : intentServices) {
- if(resolve.activityInfo.packageName.equals(resolvedApduService)) {
- unicastPkg = new ComponentName(resolvedApduService ,resolve.activityInfo.name);
- break;
- }
- }
- }
- }
-
- public ComponentName getUnicastPackage() {
- return unicastPkg;
- }
-
- final class NxpNfcControllerInterface extends INxpNfcController.Stub {
-
- @Override
- public boolean deleteOffHostService(int userId, String packageName, NxpApduServiceInfo service) {
- return mServiceCache.deleteApduService(userId, Binder.getCallingUid(), packageName, service);
- }
-
- @Override
- public ArrayList<NxpApduServiceInfo> getOffHostServices(int userId, String packageName) {
- return mServiceCache.getApduServices(userId, Binder.getCallingUid(), packageName);
- }
-
- @Override
- public NxpApduServiceInfo getDefaultOffHostService(int userId, String packageName) {
- HashMap<ComponentName, NxpApduServiceInfo> mapServices = mServiceCache.getApduservicesMaps();
- ComponentName preferredPaymentService = mRegisteredAidCache.getPreferredPaymentService();
- if(preferredPaymentService != null) {
- if(preferredPaymentService.getPackageName() != null &&
- !preferredPaymentService.getPackageName().equals(packageName)) {
- Log.d(TAG, "getDefaultOffHostService unregistered package Name");
- return null;
- }
- String defaultservice = preferredPaymentService.getClassName();
-
- //If Default is Dynamic Service
- for (Map.Entry<ComponentName, NxpApduServiceInfo> entry : mapServices.entrySet())
- {
- if(defaultservice.equals(entry.getKey().getClassName())) {
- Log.d(TAG, "getDefaultOffHostService: Dynamic: "+ entry.getValue().getAids().size());
- return entry.getValue();
- }
- }
-
- //If Default is Static Service
- HashMap<ComponentName, NxpApduServiceInfo> staticServices = mServiceCache.getInstalledStaticServices();
- for (Map.Entry<ComponentName, NxpApduServiceInfo> entry : staticServices.entrySet()) {
- if(defaultservice.equals(entry.getKey().getClassName())) {
- Log.d(TAG, "getDefaultOffHostService: Static: "+ entry.getValue().getAids().size());
- return entry.getValue();
- }
- }
- }
- return null;
- }
-
- @Override
- public boolean commitOffHostService(int userId, String packageName, String serviceName, NxpApduServiceInfo service) {
- int aidLength = 0;
- boolean is_table_size_required = true;
- List<String> newAidList = new ArrayList<String>();
- List<String> oldAidList = new ArrayList<String>();
-
- for (int i=0; i<service.getAids().size(); i++){ // Convering String AIDs to Aids Length
- aidLength = aidLength + hexStringToBytes(service.getAids().get(i)).length;
- }
- Log.d(TAG, "Total commiting aids Length: "+ aidLength);
-
- ArrayList<NxpApduServiceInfo> serviceList = mServiceCache.getApduServices(userId, Binder.getCallingUid(), packageName);
- for(int i=0; i< serviceList.size(); i++) {
- Log.d(TAG, "All Service Names["+i +"] "+ serviceList.get(i).getComponent().getClassName());
- if(serviceName.equalsIgnoreCase(serviceList.get(i).getComponent().getClassName())) {
- oldAidList = serviceList.get(i).getAids();
- newAidList = service.getAids();
- Log.d(TAG, "Commiting Existing Service: "+ serviceName);
- break;
- }
- }
-
- int newAidListSize;
- for(newAidListSize = 0; newAidListSize < newAidList.size(); newAidListSize++) {
- if(!oldAidList.contains(newAidList.get(newAidListSize))) {
- is_table_size_required = true; // Need to calculate Roting table Size, if New Aids Added
- Log.d(TAG, "New Aids Added ");
- break;
- }
- }
-
- if((newAidList.size() != 0) && (newAidListSize == newAidList.size())) {
- is_table_size_required = false; // No Need to calculate Routing size
- }
-
- Log.d(TAG, "is routing Table size calcution required : "+ is_table_size_required);
- /* Checking for table size availability is not required here as the default AID route may be changed by routing manager
- * to accomodate more AID's.
- * if((is_table_size_required == true) && NfcService.getInstance().getRemainingAidTableSize() < aidLength) {
- return false;
- }*/
-
- Log.d(TAG, "Commiting : ");
- mGsmaCommitOffhostService = true;
- mServiceCache.registerApduService(userId, Binder.getCallingUid(), packageName, serviceName, service);
- /*After commitRouting is done, status shall be updated by AidRoutingManager.
- * if there is any overflow of RoutingTable, status shall be false & the same is returned to caller*/
- mGsmaCommitOffhostService = false;
- boolean isCommitSuccess = NfcService.getInstance().getLastCommitRoutingStatus();
- Log.d(TAG, "CommitStatus : "+isCommitSuccess);
- return isCommitSuccess;
- }
-
- @Override
- public boolean enableMultiEvt_NxptransactionReception(String packageName, String seName) {
- boolean result = false,resolveStat = false;
- PackageManager pm = mContext.getPackageManager();
- List<ResolveInfo> intentServices = pm.queryIntentActivities(
- new Intent(NxpConstants.ACTION_MULTI_EVT_TRANSACTION),
- PackageManager.GET_INTENT_FILTERS| PackageManager.GET_RESOLVED_FILTER);
-
- for(ResolveInfo resInfo : intentServices){
- Log.e(TAG, " Registered Service in resolved cache"+resInfo.activityInfo.packageName);
- if(resInfo.activityInfo.packageName.equals(packageName)) {
- resolveStat = true;
- break;
- }
- }
-
- if((resolveStat) && (pm.checkPermission(NxpConstants.PERMISSIONS_TRANSACTION_EVENT , packageName) == PackageManager.PERMISSION_GRANTED) &&
- (pm.checkPermission(NxpConstants.PERMISSIONS_NFC , packageName) == PackageManager.PERMISSION_GRANTED) &&
- checkCertificatesFromUICC(packageName, seName) == true) {
- mEnabledMultiEvts.add(packageName);
- result = true;
- } else {
- result = false;
- }
-
- return result;
- }
-
- @Override
- public void enableMultiReception(String pkg, String seName) {
- if (DBG) Log.d(TAG, "enableMultiReception() " + pkg + " " + seName);
-
- if (seName.startsWith("SIM")) {
- if (checkX509CertificatesFromSim (pkg, seName) == false) {
- throw new SecurityException("No cerficates from " + seName);
- }
- } else {
- NfcService.getInstance().enforceNfceeAdminPerm(pkg);
- //NfcPermissions.enforceAdminPermissions(mContext);
- }
-
- mMultiReceptionMap.remove(seName);
- mMultiReceptionMap.put(seName, Boolean.TRUE);
- }
- }
-}
diff --git a/nci/src/com/gsma/nfc/internal/RegisteredNxpServicesCache.java b/nci/src/com/gsma/nfc/internal/RegisteredNxpServicesCache.java
deleted file mode 100644
index 8f65ac29..00000000
--- a/nci/src/com/gsma/nfc/internal/RegisteredNxpServicesCache.java
+++ /dev/null
@@ -1,409 +0,0 @@
-/*
-* Copyright (C) 2015 NXP Semiconductors
-*
-* Licensed under the Apache License, Version 2.0 (the "License");
-* you may not use this file except in compliance with the License.
-* You may obtain a copy of the License at
-*
-* http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS,
-* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-* See the License for the specific language governing permissions and
-* limitations under the License.
-*/
-
-package com.gsma.nfc.internal;
-
-
-
-import android.app.ActivityManager;
-import android.content.BroadcastReceiver;
-import android.content.ComponentName;
-import android.content.Context;
-import android.content.Intent;
-import android.content.IntentFilter;
-import android.content.pm.PackageManager;
-import android.content.pm.ResolveInfo;
-import android.content.pm.ServiceInfo;
-import android.content.pm.PackageItemInfo;
-import android.content.pm.ApplicationInfo;
-import android.content.pm.PackageManager.NameNotFoundException;
-import android.nfc.cardemulation.NxpAidGroup;
-import android.nfc.cardemulation.NxpApduServiceInfo;
-import android.nfc.cardemulation.CardEmulation;
-import android.nfc.cardemulation.HostApduService;
-import android.nfc.cardemulation.OffHostApduService;
-import android.os.UserHandle;
-import android.util.AtomicFile;
-import android.util.Log;
-import android.util.SparseArray;
-import android.graphics.Bitmap;
-import android.graphics.drawable.BitmapDrawable;
-import android.util.Xml;
-import android.graphics.drawable.Drawable;
-import android.graphics.BitmapFactory;
-
-import java.io.ByteArrayOutputStream;
-import org.xmlpull.v1.XmlPullParser;
-import org.xmlpull.v1.XmlPullParserException;
-import org.xmlpull.v1.XmlSerializer;
-
-import com.android.internal.util.FastXmlSerializer;
-import com.google.android.collect.Maps;
-
-import java.io.File;
-import java.io.FileDescriptor;
-import java.io.FileInputStream;
-import java.io.FileOutputStream;
-import java.io.IOException;
-import java.io.PrintWriter;
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-import java.util.concurrent.atomic.AtomicReference;
-import com.android.nfc.cardemulation.RegisteredServicesCache;
-
-public class RegisteredNxpServicesCache {
- static final String TAG = "RegisteredNxpServicesCache";
- static final String XML_INDENT_OUTPUT_FEATURE = "http://xmlpull.org/v1/doc/features.html#indent-output";
- final Context mContext;
- final Object mLock = new Object();
-
- private RegisteredServicesCache mRegisteredServicesCache;
- final HashMap<ComponentName, NxpApduServiceInfo> mApduServices = Maps.newHashMap();
- final HashMap<ComponentName , String> mApduBanner = Maps.newHashMap();
- AtomicFile mDynamicApduServiceFile = null;
- File dataDir = null;
-
- public RegisteredNxpServicesCache(Context context) {
- mContext = context;
- //mDynamicApduServiceFile = new AtomicFile(new File(dataDir, "dynamic_apduservice.xml"));
- }
-
- public RegisteredNxpServicesCache(Context context, RegisteredServicesCache registeredServicesCache) {
- mContext = context;
- mRegisteredServicesCache = registeredServicesCache;
-
- dataDir = mContext.getFilesDir();
- mDynamicApduServiceFile = new AtomicFile(new File(dataDir, "dynamic_apduservice.xml"));
- }
-
-
- private String writeDrawableAsBitMap(Drawable drawable , String path) {
- File file = new File(dataDir, path);
- Log.d(TAG, " input Path "+ path);
- Bitmap bitmap = ((BitmapDrawable)drawable).getBitmap();
- Log.d(TAG, "drawablePath: "+ file.getPath());
- try {
- FileOutputStream outStream = new FileOutputStream(file);
- bitmap.compress(Bitmap.CompressFormat.PNG, 100, outStream);
- outStream.flush();
- outStream.close();
- return file.getPath();
- } catch (IOException e) {
- Log.d(TAG, " input Path Not found"+ e.getMessage());
- return null;
- }
- }
-
- private Drawable readDrawableFromBitMap(String drawablePath) {
- Log.d(TAG, " input Path "+ drawablePath);
- File filePath = new File(drawablePath);
- try {
- FileInputStream fi = new FileInputStream(filePath);
- Bitmap bitmap = BitmapFactory.decodeStream(fi);
- Drawable DrawableResource = new BitmapDrawable(mContext.getResources(),bitmap);
- return DrawableResource;
- } catch (IOException e) {
- Log.d(TAG, " input Path Not found"+ e.getMessage());
- return null;
- }
- }
-
- private boolean deleteBitMapfromFile(String drawablePath) {
- Log.d(TAG, " delete Path "+ drawablePath);
- boolean deleted = false;
- if((drawablePath != null) && (!drawablePath.isEmpty()))
- {
- File file = new File(drawablePath);
- if (file.exists()) {
- Log.d(TAG, " delete Path found"+ drawablePath);
- deleted = file.delete();
- }
- }
- else
- {
- deleted = true;
- }
- Log.d(TAG, "deleted "+deleted);
- return deleted;
- }
- // Register APDU Service
- public boolean registerApduService(int userId, int uid, String packageName, String serviceName, NxpApduServiceInfo apduService) {
- ComponentName componentName = new ComponentName(packageName, serviceName);
- Log.e(TAG,"registerApduService - incoming : " + apduService.toString());
- NxpApduServiceInfo cur = mApduServices.get(componentName);
- if(cur!=null)
- Log.e(TAG,"registerApduService - cur :" + cur.toString());
-
- mApduServices.put(componentName, apduService);
-
- cur = mApduServices.get(componentName);
- if(cur!=null)
- Log.e(TAG,"registerApduService - cur - after update :" + cur.toString());
-
-
- boolean status = writeDynamicApduService();
- if(status){
- mRegisteredServicesCache.invalidateCache(userId);
- return true;
- } else {
- Log.e(TAG,"Commit Failed due to writing failed to write in to the file");
- return false;
- }
- }
-
- // To Get the NxpApduServiceInfo List
- public ArrayList<NxpApduServiceInfo> getApduservicesList() {
- ArrayList<NxpApduServiceInfo> services = new ArrayList<NxpApduServiceInfo>();
- for (NxpApduServiceInfo value : mApduServices.values()) {
- services.add(value);
- }
- return services;
- }
-
- // To get the <ComponentName, NxpApduServiceInfo> HashMap
- public HashMap<ComponentName, NxpApduServiceInfo> getApduservicesMaps() {
- return mApduServices;
- }
-
- public HashMap<ComponentName, NxpApduServiceInfo> getInstalledStaticServices() {
- return mRegisteredServicesCache.getAllStaticHashServices();
- }
-
- // update the Apduservice Info after uninstall the application.
- public void onPackageRemoved(String uninstalledpackageName) {
- if(uninstalledpackageName != null) {
- Log.d(TAG, "uninstall packageName:"+ uninstalledpackageName);
- for(Iterator<Map.Entry<ComponentName, NxpApduServiceInfo>>it=mApduServices.entrySet().iterator(); it.hasNext();){
- Map.Entry<ComponentName, NxpApduServiceInfo> entry = it.next();
- if(uninstalledpackageName.equals(entry.getKey().getPackageName())){
- it.remove();
- Log.d(TAG, "Removed packageName: "+ entry.getKey().getPackageName());
- if(mApduBanner.containsKey(entry.getKey())) {
- deleteBitMapfromFile(mApduBanner.get(entry.getKey()));
- mApduBanner.remove(entry.getKey());
- }
- }
- }
- } else {
- Log.d(TAG, "uninstall packageName is Null");
- }
- }
-
- // To Delete Apdu Service
- public boolean deleteApduService(int userId, int uid, String packageName, NxpApduServiceInfo apduService) {
- synchronized (mLock) {
- mApduServices.values().remove(apduService);
- writeDynamicApduService();
- if(mApduBanner.containsKey(apduService.getComponent())) {
- deleteBitMapfromFile(mApduBanner.get(apduService.getComponent()));
- mApduBanner.remove(apduService.getComponent());
- }
- mRegisteredServicesCache.invalidateCache(userId);
- }
- return true;
- }
-
- // To get Array of NxpApduServiceInfo
- public ArrayList<NxpApduServiceInfo> getApduServices(int userId, int uid, String packageName) {
-
- //ArrayList<NxpApduServiceInfo> apduInfo = new ArrayList<NxpApduServiceInfo>(mApduServices.values());
- ArrayList<NxpApduServiceInfo> apduInfo = new ArrayList<NxpApduServiceInfo>();
- for (Map.Entry<ComponentName, NxpApduServiceInfo> entry : mApduServices.entrySet()) {
- if(packageName.equals(entry.getKey().getPackageName())) {
- apduInfo.add(entry.getValue());
- }
- }
- ArrayList<NxpApduServiceInfo> staticServices = new ArrayList<NxpApduServiceInfo>(mRegisteredServicesCache.getAllServices());
- for(NxpApduServiceInfo service: staticServices ) {
- if(packageName.equals((service.getResolveInfo()).serviceInfo.packageName)) {
- apduInfo.add(service);
- }
- }
- return apduInfo;
- }
-
- public boolean writeDynamicApduService() {
- FileOutputStream fos = null;
- try {
- fos = mDynamicApduServiceFile.startWrite();
- XmlSerializer out = new FastXmlSerializer();
- out.setOutput(fos, "utf-8");
- out.startDocument(null, true);
- out.setFeature(XML_INDENT_OUTPUT_FEATURE, true);
- out.startTag(null, "apduservices");
-
- for(Iterator<Map.Entry<ComponentName, NxpApduServiceInfo>>it=mApduServices.entrySet().iterator(); it.hasNext();){
- Map.Entry<ComponentName, NxpApduServiceInfo> service = it.next();
- if( null != service) {
- out.startTag(null, "service");
- out.attribute(null, "component", service.getKey().flattenToString());
- if(service.getValue().getBannerId() <= 0x00 && null != service.getValue().getBitmapBanner()) {
- Log.e(TAG, "writeDynamicApduService "+service.getValue().getBannerId());
- String path = service.getKey().getPackageName() + "_"+ service.getKey().getClassName()+".png";
- path = writeDrawableAsBitMap(new BitmapDrawable(service.getValue().getBitmapBanner()) ,path);
- if(!mApduBanner.containsKey(service.getKey())) {
- mApduBanner.put(service.getKey(),path);
- }
- out.attribute(null, "drawableResourcepath", path);
- }
- service.getValue().writeToXml(out);
- out.endTag(null, "service");
- }
- }
- out.endTag(null, "apduservices");
- out.endDocument();
- mDynamicApduServiceFile.finishWrite(fos);
- return true;
- } catch (Exception e) {
- Log.e(TAG, "Error writing dynamic APDU Service", e);
- if (fos != null) {
- mDynamicApduServiceFile.failWrite(fos);
- }
- return false;
- }
- }
-
- public void readDynamicApduService() {
- FileInputStream fis = null;
- try {
- if (!mDynamicApduServiceFile.getBaseFile().exists()) {
- Log.d(TAG, "Dynamic APDU Service file does not exist.");
- return;
- }
- fis = mDynamicApduServiceFile.openRead();
- XmlPullParser parser = Xml.newPullParser();
- parser.setInput(fis, null);
- int eventType = parser.getEventType();
-
- while (eventType != XmlPullParser.START_TAG &&
- eventType != XmlPullParser.END_DOCUMENT) {
- eventType = parser.next();
- }
- boolean inService = false;
- ComponentName currentComponent = null;
- String drawbalePath = null;
- String description = null;
- boolean modifiable = false;
- int seId = 0;
- int userId = 0;
- int bannerId = 0;
- NxpAidGroup nxpAidGroup = null;
- Drawable DrawableResource = null;
- NxpApduServiceInfo apduService =null;
- Bitmap bitmap = null;
- byte[] byteArrayBanner = null;
- ArrayList<NxpAidGroup> dynamicNxpAidGroup = new ArrayList<NxpAidGroup>();
-
- String tagName = parser.getName();
- if ("apduservices".equals(tagName)) {
- while (eventType != XmlPullParser.END_DOCUMENT) {
- tagName = parser.getName();
- if (eventType == XmlPullParser.START_TAG) {
- if ("service".equals(tagName) && parser.getDepth() == 2) {
- String compString = parser.getAttributeValue(null, "component");
- userId = Integer.parseInt(parser.getAttributeValue(null, "uid"));
- currentComponent = ComponentName.unflattenFromString(compString);
- description = parser.getAttributeValue(null, "description");
- bannerId = Integer.parseInt(parser.getAttributeValue(null, "bannerId"));
- String isModifiable = parser.getAttributeValue(null, "modifiable");
- drawbalePath = parser.getAttributeValue(null, "drawableResourcepath");
- if(isModifiable.equals("true")) {
- modifiable = true;
- } else {
- modifiable = false;
- }
-
- String seIdString = parser.getAttributeValue(null, "seId");
- seId = Integer.parseInt(seIdString);
- inService = true;
- Log.e(TAG, "readDynamicApduService "+bannerId);
- if(bannerId <= 0x00) {
- bannerId = -1;
- if(drawbalePath != null)
- {
- DrawableResource = readDrawableFromBitMap(drawbalePath);
- bitmap = (Bitmap)((BitmapDrawable) DrawableResource).getBitmap();
- ByteArrayOutputStream stream = new ByteArrayOutputStream();
- bitmap.compress(Bitmap.CompressFormat.PNG, 100, stream);
- byteArrayBanner = stream.toByteArray();
- if(!mApduBanner.containsKey(currentComponent)) {
- mApduBanner.put(currentComponent, drawbalePath);
- }
- }
- }
- }
-
- if ("aid-group".equals(tagName) && parser.getDepth() == 3 && inService) {
- NxpAidGroup group = NxpAidGroup.createFromXml(parser);
- if (group != null) {
- dynamicNxpAidGroup.add(group);
- } else {
- Log.e(TAG, "Could not parse AID group.");
- }
- }
-
- } else if (eventType == XmlPullParser.END_TAG) {
- if ("service".equals(tagName)) {
- int powerstate = -1;
- boolean onHost = false;
- boolean requiresUnlock = false;
- /* creating Resolveinfo object */
- ResolveInfo resolveInfo = new ResolveInfo();
- resolveInfo.serviceInfo = new ServiceInfo();
- resolveInfo.serviceInfo.applicationInfo = new ApplicationInfo();
- resolveInfo.serviceInfo.packageName = currentComponent.getPackageName();
- resolveInfo.serviceInfo.name = currentComponent.getClassName();
- NxpApduServiceInfo.ESeInfo mEseInfo = new NxpApduServiceInfo.ESeInfo(seId,powerstate);
- ArrayList<android.nfc.cardemulation.NxpAidGroup> staticNxpAidGroups = null;
- apduService = new NxpApduServiceInfo(resolveInfo,onHost,description,staticNxpAidGroups, dynamicNxpAidGroup,
- requiresUnlock,bannerId,userId, "Fixme: NXP:<Activity Name>", mEseInfo,null, byteArrayBanner, modifiable);
- mApduServices.put(currentComponent, apduService);
- Log.d(TAG,"mApduServices size= "+ mApduServices.size());
- dynamicNxpAidGroup.clear();
- inService = false;
- currentComponent = null;
- drawbalePath = null;
- description = null;
- modifiable = false;
- seId = 0;
- userId = 0;
- nxpAidGroup = null;
- DrawableResource = null;
- apduService =null;
- }
- }
- eventType = parser.next();
- }
- }
- } catch (Exception e) {
- Log.e(TAG, "Could not parse dynamic APDU Service file, trashing.", e);
- mDynamicApduServiceFile.delete();
- } finally {
- if (fis != null) {
- try {
- fis.close();
- } catch (IOException e) {
- }
- }
- }
- Log.d(TAG,"readDynamicApduService End: "+ mApduServices.size());
- return;
- }
-}