Skip to content
This repository has been archived by the owner on Nov 3, 2021. It is now read-only.

Commit

Permalink
Merge pull request #56 from DimiL/bug_1057960_v2
Browse files Browse the repository at this point in the history
Bug 1057960 - [NFC] nfcd should pass AID origin to gecko. r=allstars.chh
  • Loading branch information
allstarschh committed Aug 29, 2014
2 parents aad3e80 + d4fc4eb commit eb24cac
Show file tree
Hide file tree
Showing 7 changed files with 48 additions and 3 deletions.
5 changes: 4 additions & 1 deletion src/MessageHandler.cpp
Expand Up @@ -25,7 +25,7 @@
#include "NfcDebug.h"

#define MAJOR_VERSION (1)
#define MINOR_VERSION (7)
#define MINOR_VERSION (8)

using android::Parcel;

Expand Down Expand Up @@ -64,6 +64,9 @@ void MessageHandler::notifyTransactionEvent(Parcel& parcel, void* data)
{
TransactionEvent *event = reinterpret_cast<TransactionEvent*>(data);

parcel.writeInt32(NfcUtil::convertOriginType(event->originType));
parcel.writeInt32(event->originIndex);

parcel.writeInt32(event->aidLen);
void* aid = parcel.writeInplace(event->aidLen);
memcpy(aid, event->aid, event->aidLen);
Expand Down
13 changes: 12 additions & 1 deletion src/NfcGonkMessage.h
Expand Up @@ -374,11 +374,22 @@ typedef enum {
*
* To notify a transaction event from secure element.
*
* data is char* [aid length][aid][payload length][payload]
* data is [origin type][origin index][aid length][aid][payload length][payload]
*/
NFC_NOTIFICATION_TRANSACTION_EVENT = 2003,
} NfcNotificationType;

/**
* The origin of the transaction event.
*/
typedef enum {
NFC_EVT_TRANSACTION_SIM = 0,

NFC_EVT_TRANSACTION_ESE = 1,

NFC_EVT_TRANSACTION_ASSD = 2,
} NfcEvtTransactionOrigin;

#ifdef __cplusplus
}
#endif
Expand Down
14 changes: 14 additions & 0 deletions src/NfcUtil.cpp
Expand Up @@ -45,3 +45,17 @@ NfcTechnology NfcUtil::convertTagTechToGonkFormat(TagTechnology tagTech) {
}
return NFC_TECH_NFCA;
}

NfcEvtTransactionOrigin NfcUtil::convertOriginType(TransactionEvent::OriginType type)
{
switch (type) {
case TransactionEvent::SIM:
return NFC_EVT_TRANSACTION_SIM;
case TransactionEvent::ESE:
return NFC_EVT_TRANSACTION_ESE;
case TransactionEvent::ASSD:
return NFC_EVT_TRANSACTION_ASSD;
default:
return NFC_EVT_TRANSACTION_SIM;
}
}
3 changes: 3 additions & 0 deletions src/NfcUtil.h
Expand Up @@ -18,6 +18,7 @@
#define mozilla_nfcd_NfcUtil_h

#include <stdio.h>
#include "DeviceHost.h"
#include "NdefMessage.h"
#include "NfcGonkMessage.h"
#include "TagTechnology.h"
Expand All @@ -27,6 +28,8 @@ class NfcUtil{
public:
static void convertNdefPduToNdefMessage(NdefMessagePdu& ndefPdu, NdefMessage* ndefMessage);
static NfcTechnology convertTagTechToGonkFormat(TagTechnology tagTech);
static NfcEvtTransactionOrigin convertOriginType(TransactionEvent::OriginType type);

private:
NfcUtil();
};
Expand Down
4 changes: 3 additions & 1 deletion src/interface/DeviceHost.cpp
Expand Up @@ -61,7 +61,9 @@ void DeviceHost::notifySeFieldDeactivated()
}

TransactionEvent::TransactionEvent()
: aidLen(0)
: originType(TransactionEvent::SIM)
, originIndex(-1)
, aidLen(0)
, aid(NULL)
, payloadLen(0)
, payload(NULL)
Expand Down
7 changes: 7 additions & 0 deletions src/interface/DeviceHost.h
Expand Up @@ -84,9 +84,16 @@ class NfcDepEndpoint {

class TransactionEvent {
public:
enum OriginType {
SIM, ESE, ASSD
};

TransactionEvent();
~TransactionEvent();

OriginType originType;
uint32_t originIndex;

uint32_t aidLen;
uint8_t* aid;

Expand Down
5 changes: 5 additions & 0 deletions src/nci/SecureElement.cpp
Expand Up @@ -365,6 +365,11 @@ void SecureElement::notifyTransactionEvent(const uint8_t* aid, uint32_t aidLen,

TransactionEvent* pTransaction = new TransactionEvent();

// TODO: For now, we dodn't have a solution to get aid origin from nfcd.
// So use SIM1 as dfault value.
pTransaction->originType = TransactionEvent::SIM;
pTransaction->originIndex = 1;

pTransaction->aidLen = aidLen;
pTransaction->aid = new uint8_t[aidLen];
memcpy(pTransaction->aid, aid, aidLen);
Expand Down

0 comments on commit eb24cac

Please sign in to comment.