summaryrefslogtreecommitdiff
path: root/nci
diff options
context:
space:
mode:
authorGeorge Chang <georgekgchang@google.com>2021-10-06 23:45:37 +0800
committerGeorge Chang <georgekgchang@google.com>2021-10-12 18:00:17 +0800
commit7b43dc7547d337487c15cb71a4911ac08a0729aa (patch)
tree57d825cf6206e16fc86ac350f3ee5e73c8e40afd /nci
parent534ce28c629b5b089f46d35a564027d6786c8295 (diff)
downloadNfc-7b43dc7547d337487c15cb71a4911ac08a0729aa.tar.gz
Refine setNfcSecure
Remove duplicate routing calculation. Fix crash issue when setNfcSecure was called at NFC off state. Bug: 199804867 Test: atest NfcNciInstrumentationTests Change-Id: Ic7f0c088afa95c9bac84a5836d51671e8853dd77
Diffstat (limited to 'nci')
-rw-r--r--nci/jni/NativeNfcManager.cpp19
1 files changed, 15 insertions, 4 deletions
diff --git a/nci/jni/NativeNfcManager.cpp b/nci/jni/NativeNfcManager.cpp
index 713886bb..962b67b1 100644
--- a/nci/jni/NativeNfcManager.cpp
+++ b/nci/jni/NativeNfcManager.cpp
@@ -1583,6 +1583,7 @@ static jboolean nfcManager_doDeinitialize(JNIEnv*, jobject) {
sAbortConnlessWait = true;
nativeLlcpConnectionlessSocket_abortWait();
sIsNfaEnabled = false;
+ sRoutingInitialized = false;
sDiscoveryEnabled = false;
sPollingEnabled = false;
sIsDisabling = false;
@@ -2109,18 +2110,28 @@ static void nfcManager_doStartStopPolling(JNIEnv* e, jobject o,
startStopPolling(start);
}
+/*******************************************************************************
+**
+** Function: nfcManager_doSetNfcSecure
+**
+** Description: Set NfcSecure enable/disable.
+** e: JVM environment.
+** o: Java object.
+** enable: Sets true/false to enable/disable NfcSecure
+** It only updates the routing table cache without commit to
+** NFCC.
+**
+** Returns: True always
+**
+*******************************************************************************/
static jboolean nfcManager_doSetNfcSecure(JNIEnv* e, jobject o,
jboolean enable) {
RoutingManager& routingManager = RoutingManager::getInstance();
routingManager.setNfcSecure(enable);
- bool rfEnabled = sRfEnabled;
if (sRoutingInitialized) {
routingManager.disableRoutingToHost();
- if (rfEnabled) startRfDiscovery(false);
routingManager.updateRoutingTable();
routingManager.enableRoutingToHost();
- routingManager.commitRouting();
- if (rfEnabled) startRfDiscovery(true);
}
return true;
}