summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEvan Chu <evanchu@broadcom.com>2012-09-25 18:45:46 -0400
committerMartijn Coenen <maco@google.com>2012-09-25 18:34:56 -0700
commit2f9909a2ac0786983f3f564364053c56ef353819 (patch)
treee427830ded376f9f45afaa567021d990d9ff11d6
parentdc8a29dabea23ad526f767c4f6af949d626518d3 (diff)
downloadpackages_apps_nfc-2f9909a2ac0786983f3f564364053c56ef353819.zip
packages_apps_nfc-2f9909a2ac0786983f3f564364053c56ef353819.tar.gz
packages_apps_nfc-2f9909a2ac0786983f3f564364053c56ef353819.tar.bz2
Tell secure element to warm-reset when closing pipe to DH.
Set HCI registry to cause Oberthur secure element to perform warm-reset. We use this to close any applets that the DH may have opened during communication to the SE. This feature is Oberthur-specific. Bug: 7163680 Change-Id: Id0589b5b41bbea1df9b8dbd73abd5a112f773916
-rwxr-xr-xnci/jni/SecureElement.cpp34
-rwxr-xr-xnci/jni/SecureElement.h3
2 files changed, 36 insertions, 1 deletions
diff --git a/nci/jni/SecureElement.cpp b/nci/jni/SecureElement.cpp
index b67ee66..2f94047 100755
--- a/nci/jni/SecureElement.cpp
+++ b/nci/jni/SecureElement.cpp
@@ -70,7 +70,9 @@ SecureElement::SecureElement ()
mCommandStatus (NFA_STATUS_OK),
mIsPiping (false),
mCurrentRouteSelection (NoRoute),
- mActualResponseSize(0)
+ mActualResponseSize(0),
+ mUseOberthurWarmReset (false),
+ mOberthurWarmResetCommand (3)
{
memset (&mEeInfo, 0, sizeof(mEeInfo));
memset (&mUiccInfo, 0, sizeof(mUiccInfo));
@@ -153,6 +155,12 @@ bool SecureElement::initialize (nfc_jni_native_data* native)
mActiveSeOverride = num;
ALOGD ("%s: Active SE override: %d", fn, mActiveSeOverride);
+ if (GetNumValue("OBERTHUR_WARM_RESET_COMMAND", &num, sizeof(num)))
+ {
+ mUseOberthurWarmReset = true;
+ mOberthurWarmResetCommand = (UINT8) num;
+ }
+
mActiveEeHandle = NFA_HANDLE_INVALID;
mNfaHciHandle = NFA_HANDLE_INVALID;
@@ -777,6 +785,21 @@ bool SecureElement::disconnectEE (jint seID)
ALOGD("%s: seID=0x%X; handle=0x%04x", fn, seID, eeHandle);
+ if (mUseOberthurWarmReset)
+ {
+ //send warm-reset command to Oberthur secure element which deselects the applet;
+ //this is an Oberthur-specific command;
+ ALOGD("%s: try warm-reset on pipe id 0x%X; cmd=0x%X", fn, mNewPipeId, mOberthurWarmResetCommand);
+ SyncEventGuard guard (mRegistryEvent);
+ nfaStat = NFA_HciSetRegistry (mNfaHciHandle, mNewPipeId,
+ 1, 1, &mOberthurWarmResetCommand);
+ if (nfaStat == NFA_STATUS_OK)
+ {
+ mRegistryEvent.wait ();
+ ALOGD("%s: completed warm-reset on pipe 0x%X", fn, mNewPipeId);
+ }
+ }
+
if (mNewSourceGate)
{
SyncEventGuard guard (mDeallocateGateEvent);
@@ -1718,6 +1741,15 @@ void SecureElement::nfaHciCallback (tNFA_HCI_EVT event, tNFA_HCI_EVT_DATA* event
}
break;
+ case NFA_HCI_SET_REG_RSP_EVT: //received response to write registry command
+ {
+ tNFA_HCI_REGISTRY& registry = eventData->registry;
+ ALOGD ("%s: NFA_HCI_SET_REG_RSP_EVT; status=0x%X; pipe=0x%X", fn, registry.status, registry.pipe);
+ SyncEventGuard guard (sSecElem.mRegistryEvent);
+ sSecElem.mRegistryEvent.notifyOne ();
+ break;
+ }
+
default:
ALOGE ("%s: unknown event code=0x%X ????", fn, event);
break;
diff --git a/nci/jni/SecureElement.h b/nci/jni/SecureElement.h
index b887513..6a5cebd 100755
--- a/nci/jni/SecureElement.h
+++ b/nci/jni/SecureElement.h
@@ -372,6 +372,8 @@ private:
bool mIsPiping; //is a pipe connected to the controller?
RouteSelection mCurrentRouteSelection;
int mActualResponseSize; //number of bytes in the response received from secure element
+ bool mUseOberthurWarmReset; //whether to use warm-reset command
+ UINT8 mOberthurWarmResetCommand; //warm-reset command byte
tNFA_EE_INFO mEeInfo [MAX_NUM_EE]; //actual size stored in mActualNumEe
tNFA_EE_DISCOVER_REQ mUiccInfo;
tNFA_HCI_GET_GATE_PIPE_LIST mHciCfg;
@@ -389,6 +391,7 @@ private:
SyncEvent mAidAddRemoveEvent;
SyncEvent mTransceiveEvent;
SyncEvent mVerInfoEvent;
+ SyncEvent mRegistryEvent;
UINT8 mVerInfo [3];
UINT8 mResponseData [MAX_RESPONSE_SIZE];
RouteDataSet mRouteDataSet; //routing data