Bug 947100 - B2G NFC: enable/disable NFC worker at runtime. r=yoshi

This commit is contained in:
Dimi Lee 2013-12-11 14:04:27 +08:00
parent a8aca26478
commit 1c63e8351f
3 changed files with 18 additions and 4 deletions

View File

@ -138,8 +138,12 @@ MozNFCPeer.prototype = {
*/
function mozNfc() {
debug("In mozNfc Constructor");
this._nfcContentHelper = Cc["@mozilla.org/nfc/content-helper;1"]
.getService(Ci.nsINfcContentHelper);
try {
this._nfcContentHelper = Cc["@mozilla.org/nfc/content-helper;1"]
.getService(Ci.nsINfcContentHelper);
} catch(e) {
debug("No NFC support.")
}
}
mozNfc.prototype = {
_nfcContentHelper: null,

View File

@ -25,6 +25,9 @@ Cu.import("resource://gre/modules/Services.jsm");
let NFC = {};
Cu.import("resource://gre/modules/nfc_consts.js", NFC);
Cu.import("resource://gre/modules/systemlibs.js");
const NFC_ENABLED = libcutils.property_get("ro.moz.nfc.enabled", "false") === "true";
// set to true in nfc_consts.js to see debug messages
let DEBUG = NFC.DEBUG_NFC;
@ -627,4 +630,6 @@ Nfc.prototype = {
}
};
this.NSGetFactory = XPCOMUtils.generateNSGetFactory([Nfc]);
if (NFC_ENABLED) {
this.NSGetFactory = XPCOMUtils.generateNSGetFactory([Nfc]);
}

View File

@ -26,6 +26,9 @@ Cu.import("resource://gre/modules/DOMRequestHelper.jsm");
let NFC = {};
Cu.import("resource://gre/modules/nfc_consts.js", NFC);
Cu.import("resource://gre/modules/systemlibs.js");
const NFC_ENABLED = libcutils.property_get("ro.moz.nfc.enabled", "false") === "true";
// set to true to in nfc_consts.js to see debug messages
let DEBUG = NFC.DEBUG_CONTENT_HELPER;
@ -384,4 +387,6 @@ NfcContentHelper.prototype = {
},
};
this.NSGetFactory = XPCOMUtils.generateNSGetFactory([NfcContentHelper]);
if (NFC_ENABLED) {
this.NSGetFactory = XPCOMUtils.generateNSGetFactory([NfcContentHelper]);
}