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 #93 from allstarschh/Bug1127735
Browse files Browse the repository at this point in the history
Bug 1127735 - Update TechDiscoveredNotication. r=dimi
  • Loading branch information
allstarschh committed Apr 7, 2015
2 parents 306b329 + 149b554 commit eb5edeb
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 8 deletions.
15 changes: 14 additions & 1 deletion src/MessageHandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
#include "NfcDebug.h"

#define MAJOR_VERSION (1)
#define MINOR_VERSION (21)
#define MINOR_VERSION (22)

using android::Parcel;

Expand Down Expand Up @@ -81,6 +81,16 @@ void MessageHandler::NotifyTransactionEvent(Parcel& aParcel, void* aData)
delete event;
}

void MessageHandler::NotifyNdefReceived(Parcel& aParcel, void* aData)
{
NdefReceivedEvent *event = reinterpret_cast<NdefReceivedEvent*>(aData);

aParcel.writeInt32(event->sessionId);
aParcel.writeInt32(event->ndefMsgCount);
SendNdefMsg(aParcel, event->ndefMsg);
SendResponse(aParcel);
}

void MessageHandler::ProcessRequest(const uint8_t* aData, size_t aDataLen)
{
Parcel parcel;
Expand Down Expand Up @@ -169,6 +179,9 @@ void MessageHandler::ProcessNotification(NfcNotificationType aNotification, void
case NFC_NOTIFICATION_TRANSACTION_EVENT:
NotifyTransactionEvent(parcel, aData);
break;
case NFC_NOTIFICATION_NDEF_RECEIVED:
NotifyNdefReceived(parcel, aData);
break;
default:
NFCD_ERROR("Not implement");
break;
Expand Down
7 changes: 7 additions & 0 deletions src/MessageHandler.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ class MessageHandler {
void NotifyTechDiscovered(android::Parcel& aParcel, void* aData);
void NotifyTechLost(android::Parcel& aParcel, void* aData);
void NotifyTransactionEvent(android::Parcel& aParcel, void* aData);
void NotifyNdefReceived(android::Parcel& aParcel, void* aData);

bool HandleChangeRFStateRequest(android::Parcel& aParcel);
bool HandleReadNdefRequest(android::Parcel& aParcel);
Expand Down Expand Up @@ -76,4 +77,10 @@ struct TechDiscoveredEvent {
NdefInfo* ndefInfo;
};

struct NdefReceivedEvent {
int sessionId;
uint32_t ndefMsgCount;
NdefMessage* ndefMsg;
};

#endif // mozilla_nfcd_MessageHandler_h
7 changes: 7 additions & 0 deletions src/NfcGonkMessage.h
Original file line number Diff line number Diff line change
Expand Up @@ -332,6 +332,13 @@ typedef enum {
* data is [origin type][origin index][aid length][aid][payload length][payload]
*/
NFC_NOTIFICATION_TRANSACTION_EVENT,

/**
* NFC_NOTIFICATION_NDEF_RECEIVED
*
* To notify when a NDEF message is received from a P2P connection.
*/
NFC_NOTIFICATION_NDEF_RECEIVED,
} NfcNotificationType;

/**
Expand Down
9 changes: 2 additions & 7 deletions src/NfcService.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -453,16 +453,11 @@ void NfcService::HandleReceiveNdefEvent(NfcEvent* aEvent)
{
NdefMessage* ndef = reinterpret_cast<NdefMessage*>(aEvent->obj);

TechDiscoveredEvent* data = new TechDiscoveredEvent();
NdefReceivedEvent* data = new NdefReceivedEvent();
data->sessionId = SessionId::GetCurrentId();
data->isP2P = true;
data->techCount = 0;
data->techList = NULL;
data->tagIdCount = 0;
data->tagId = NULL;
data->ndefMsgCount = ndef ? 1 : 0;
data->ndefMsg = ndef;
mMsgHandler->ProcessNotification(NFC_NOTIFICATION_TECH_DISCOVERED, data);
mMsgHandler->ProcessNotification(NFC_NOTIFICATION_NDEF_RECEIVED, data);

delete data;
delete ndef;
Expand Down

0 comments on commit eb5edeb

Please sign in to comment.