Bug 1055460 - replace config request with power request. r=dimi

From 2860c6c7d3783e0f7cf71bcaacbc324dc288c8af Mon Sep 17 00:00:00 2001
---
 dom/nfc/NfcContentHelper.js        |  4 ++--
 dom/nfc/gonk/Nfc.js                | 18 +++++++-----------
 dom/nfc/gonk/NfcGonkMessage.h      |  6 +++---
 dom/nfc/gonk/NfcMessageHandler.cpp | 20 ++++++++++----------
 dom/nfc/gonk/NfcMessageHandler.h   |  4 ++--
 5 files changed, 24 insertions(+), 28 deletions(-)
This commit is contained in:
Yoshi Huang 2014-11-06 17:57:49 +08:00
parent edbfd50e8a
commit 0742f73807
5 changed files with 24 additions and 28 deletions

View File

@ -59,7 +59,7 @@ const NFC_IPC_MSG_NAMES = [
"NFC:CheckP2PRegistrationResponse",
"NFC:DOMEvent",
"NFC:NotifySendFileStatusResponse",
"NFC:ConfigResponse"
"NFC:PowerResponse"
];
XPCOMUtils.defineLazyServiceGetter(this, "cpmm",
@ -341,7 +341,7 @@ NfcContentHelper.prototype = {
case "NFC:WriteNDEFResponse":
case "NFC:MakeReadOnlyResponse":
case "NFC:NotifySendFileStatusResponse":
case "NFC:ConfigResponse":
case "NFC:PowerResponse":
if (result.errorMsg) {
this.fireRequestError(atob(result.requestId), result.errorMsg);
} else {

View File

@ -555,7 +555,7 @@ Nfc.prototype = {
case "HCIEventTransactionNotification":
this.notifyHCIEventTransaction(message);
break;
case "ConfigResponse":
case "PowerResponse":
if (!message.errorMsg) {
this.powerLevel = message.powerLevel;
}
@ -615,16 +615,16 @@ Nfc.prototype = {
switch (message.name) {
case "NFC:StartPoll":
this.setConfig({powerLevel: NFC.NFC_POWER_LEVEL_ENABLED,
requestId: message.data.requestId});
message.data.powerLevel = NFC.NFC_POWER_LEVEL_ENABLED;
this.sendToNfcService("power", message.data);
break;
case "NFC:StopPoll":
this.setConfig({powerLevel: NFC.NFC_POWER_LEVEL_LOW,
requestId: message.data.requestId});
message.data.powerLevel = NFC.NFC_POWER_LEVEL_LOW;
this.sendToNfcService("power", message.data);
break;
case "NFC:PowerOff":
this.setConfig({powerLevel: NFC.NFC_POWER_LEVEL_DISABLED,
requestId: message.data.requestId});
message.data.powerLevel = NFC.NFC_POWER_LEVEL_DISABLED;
this.sendToNfcService("power", message.data);
break;
case "NFC:ReadNDEF":
this.sendToNfcService("readNDEF", message.data);
@ -691,10 +691,6 @@ Nfc.prototype = {
}
},
setConfig: function setConfig(prop) {
this.sendToNfcService("config", prop);
},
shutdown: function shutdown() {
this.nfcService.shutdown();
this.nfcService = null;

View File

@ -8,10 +8,10 @@
namespace mozilla {
#define NFCD_MAJOR_VERSION 1
#define NFCD_MINOR_VERSION 14
#define NFCD_MINOR_VERSION 15
enum NfcRequest {
ConfigReq = 0,
PowerReq = 0,
ConnectReq,
CloseReq,
ReadNDEFReq,
@ -21,7 +21,7 @@ enum NfcRequest {
enum NfcResponse {
GeneralRsp = 1000,
ConfigRsp,
PowerRsp,
ReadNDEFRsp,
};

View File

@ -16,14 +16,14 @@ using namespace android;
using namespace mozilla;
using namespace mozilla::dom;
static const char* kConfigRequest = "config";
static const char* kPowerRequest = "power";
static const char* kReadNDEFRequest = "readNDEF";
static const char* kWriteNDEFRequest = "writeNDEF";
static const char* kMakeReadOnlyRequest = "makeReadOnly";
static const char* kConnectRequest = "connect";
static const char* kCloseRequest = "close";
static const char* kConfigResponse = "ConfigResponse";
static const char* kPowerResponse = "PowerResponse";
static const char* kReadNDEFResponse = "ReadNDEFResponse";
static const char* kWriteNDEFResponse = "WriteNDEFResponse";
static const char* kMakeReadOnlyResponse = "MakeReadOnlyResponse";
@ -42,8 +42,8 @@ NfcMessageHandler::Marshall(Parcel& aParcel, const CommandOptions& aOptions)
bool result;
const char* type = NS_ConvertUTF16toUTF8(aOptions.mType).get();
if (!strcmp(type, kConfigRequest)) {
result = ConfigRequest(aParcel, aOptions);
if (!strcmp(type, kPowerRequest)) {
result = PowerRequest(aParcel, aOptions);
} else if (!strcmp(type, kReadNDEFRequest)) {
result = ReadNDEFRequest(aParcel, aOptions);
} else if (!strcmp(type, kWriteNDEFRequest)) {
@ -76,8 +76,8 @@ NfcMessageHandler::Unmarshall(const Parcel& aParcel, EventOptions& aOptions)
case NfcResponse::GeneralRsp:
result = GeneralResponse(aParcel, aOptions);
break;
case NfcResponse::ConfigRsp:
result = ConfigResponse(aParcel, aOptions);
case NfcResponse::PowerRsp:
result = PowerResponse(aParcel, aOptions);
break;
case NfcResponse::ReadNDEFRsp:
result = ReadNDEFResponse(aParcel, aOptions);
@ -139,9 +139,9 @@ NfcMessageHandler::GeneralResponse(const Parcel& aParcel, EventOptions& aOptions
}
bool
NfcMessageHandler::ConfigRequest(Parcel& aParcel, const CommandOptions& aOptions)
NfcMessageHandler::PowerRequest(Parcel& aParcel, const CommandOptions& aOptions)
{
aParcel.writeInt32(NfcRequest::ConfigReq);
aParcel.writeInt32(NfcRequest::PowerReq);
aParcel.writeInt32(aOptions.mPowerLevel);
mRequestIdQueue.AppendElement(aOptions.mRequestId);
mPowerLevelQueue.AppendElement(aOptions.mPowerLevel);
@ -149,9 +149,9 @@ NfcMessageHandler::ConfigRequest(Parcel& aParcel, const CommandOptions& aOptions
}
bool
NfcMessageHandler::ConfigResponse(const Parcel& aParcel, EventOptions& aOptions)
NfcMessageHandler::PowerResponse(const Parcel& aParcel, EventOptions& aOptions)
{
aOptions.mType = NS_ConvertUTF8toUTF16(kConfigResponse);
aOptions.mType = NS_ConvertUTF8toUTF16(kPowerResponse);
aOptions.mErrorCode = aParcel.readInt32();
NS_ENSURE_TRUE(!mRequestIdQueue.IsEmpty(), false);
aOptions.mRequestId = mRequestIdQueue[0];

View File

@ -25,8 +25,8 @@ public:
private:
bool GeneralResponse(const android::Parcel& aParcel, EventOptions& aOptions);
bool ConfigRequest(android::Parcel& aParcel, const CommandOptions& options);
bool ConfigResponse(const android::Parcel& aParcel, EventOptions& aOptions);
bool PowerRequest(android::Parcel& aParcel, const CommandOptions& options);
bool PowerResponse(const android::Parcel& aParcel, EventOptions& aOptions);
bool ReadNDEFRequest(android::Parcel& aParcel, const CommandOptions& options);
bool ReadNDEFResponse(const android::Parcel& aParcel, EventOptions& aOptions);
bool WriteNDEFRequest(android::Parcel& aParcel, const CommandOptions& options);