mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 1058440 - B2G NFC: enable debug when NFC debug is enabled. r=allstars.chh
This commit is contained in:
parent
9def110412
commit
aaa8026ad0
@ -23,6 +23,10 @@ Cu.import("resource://gre/modules/XPCOMUtils.jsm");
|
|||||||
Cu.import("resource://gre/modules/Services.jsm");
|
Cu.import("resource://gre/modules/Services.jsm");
|
||||||
Cu.import("resource://gre/modules/DOMRequestHelper.jsm");
|
Cu.import("resource://gre/modules/DOMRequestHelper.jsm");
|
||||||
|
|
||||||
|
XPCOMUtils.defineLazyServiceGetter(this, "gSettingsService",
|
||||||
|
"@mozilla.org/settingsService;1",
|
||||||
|
"nsISettingsService");
|
||||||
|
|
||||||
XPCOMUtils.defineLazyGetter(this, "NFC", function () {
|
XPCOMUtils.defineLazyGetter(this, "NFC", function () {
|
||||||
let obj = {};
|
let obj = {};
|
||||||
Cu.import("resource://gre/modules/nfc_consts.js", obj);
|
Cu.import("resource://gre/modules/nfc_consts.js", obj);
|
||||||
@ -36,13 +40,16 @@ const NFC_ENABLED = libcutils.property_get("ro.moz.nfc.enabled", "false") === "t
|
|||||||
let DEBUG = NFC.DEBUG_CONTENT_HELPER;
|
let DEBUG = NFC.DEBUG_CONTENT_HELPER;
|
||||||
|
|
||||||
let debug;
|
let debug;
|
||||||
if (DEBUG) {
|
function updateDebug() {
|
||||||
|
if (DEBUG) {
|
||||||
debug = function (s) {
|
debug = function (s) {
|
||||||
dump("-*- NfcContentHelper: " + s + "\n");
|
dump("-*- NfcContentHelper: " + s + "\n");
|
||||||
};
|
};
|
||||||
} else {
|
} else {
|
||||||
debug = function (s) {};
|
debug = function (s) {};
|
||||||
}
|
}
|
||||||
|
};
|
||||||
|
updateDebug();
|
||||||
|
|
||||||
const NFCCONTENTHELPER_CID =
|
const NFCCONTENTHELPER_CID =
|
||||||
Components.ID("{4d72c120-da5f-11e1-9b23-0800200c9a66}");
|
Components.ID("{4d72c120-da5f-11e1-9b23-0800200c9a66}");
|
||||||
@ -77,6 +84,11 @@ GetDetailsNDEFResponse.prototype = {
|
|||||||
|
|
||||||
function NfcContentHelper() {
|
function NfcContentHelper() {
|
||||||
this.initDOMRequestHelper(/* aWindow */ null, NFC_IPC_MSG_NAMES);
|
this.initDOMRequestHelper(/* aWindow */ null, NFC_IPC_MSG_NAMES);
|
||||||
|
|
||||||
|
let lock = gSettingsService.createLock();
|
||||||
|
lock.get(NFC.SETTING_NFC_DEBUG, this);
|
||||||
|
|
||||||
|
Services.obs.addObserver(this, NFC.TOPIC_MOZSETTINGS_CHANGED, false);
|
||||||
Services.obs.addObserver(this, "xpcom-shutdown", false);
|
Services.obs.addObserver(this, "xpcom-shutdown", false);
|
||||||
|
|
||||||
this._requestMap = [];
|
this._requestMap = [];
|
||||||
@ -355,8 +367,14 @@ NfcContentHelper.prototype = {
|
|||||||
observe: function observe(subject, topic, data) {
|
observe: function observe(subject, topic, data) {
|
||||||
if (topic == "xpcom-shutdown") {
|
if (topic == "xpcom-shutdown") {
|
||||||
this.destroyDOMRequestHelper();
|
this.destroyDOMRequestHelper();
|
||||||
|
Services.obs.removeObserver(this, NFC.TOPIC_MOZSETTINGS_CHANGED);
|
||||||
Services.obs.removeObserver(this, "xpcom-shutdown");
|
Services.obs.removeObserver(this, "xpcom-shutdown");
|
||||||
cpmm = null;
|
cpmm = null;
|
||||||
|
} else if (topic == NFC.TOPIC_MOZSETTINGS_CHANGED) {
|
||||||
|
let setting = JSON.parse(data);
|
||||||
|
if (setting) {
|
||||||
|
this.handle(setting.key, setting.value);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
@ -427,6 +445,15 @@ NfcContentHelper.prototype = {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
handle: function handle(name, result) {
|
||||||
|
switch (name) {
|
||||||
|
case NFC.SETTING_NFC_DEBUG:
|
||||||
|
DEBUG = result;
|
||||||
|
updateDebug();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
handleReadNDEFResponse: function handleReadNDEFResponse(result) {
|
handleReadNDEFResponse: function handleReadNDEFResponse(result) {
|
||||||
let requester = this._requestMap[result.requestId];
|
let requester = this._requestMap[result.requestId];
|
||||||
if (!requester) {
|
if (!requester) {
|
||||||
|
@ -22,6 +22,10 @@ const {classes: Cc, interfaces: Ci, utils: Cu, results: Cr} = Components;
|
|||||||
Cu.import("resource://gre/modules/XPCOMUtils.jsm");
|
Cu.import("resource://gre/modules/XPCOMUtils.jsm");
|
||||||
Cu.import("resource://gre/modules/Services.jsm");
|
Cu.import("resource://gre/modules/Services.jsm");
|
||||||
|
|
||||||
|
XPCOMUtils.defineLazyServiceGetter(this, "gSettingsService",
|
||||||
|
"@mozilla.org/settingsService;1",
|
||||||
|
"nsISettingsService");
|
||||||
|
|
||||||
XPCOMUtils.defineLazyGetter(this, "NFC", function () {
|
XPCOMUtils.defineLazyGetter(this, "NFC", function () {
|
||||||
let obj = {};
|
let obj = {};
|
||||||
Cu.import("resource://gre/modules/nfc_consts.js", obj);
|
Cu.import("resource://gre/modules/nfc_consts.js", obj);
|
||||||
@ -35,13 +39,16 @@ const NFC_ENABLED = libcutils.property_get("ro.moz.nfc.enabled", "false") === "t
|
|||||||
let DEBUG = NFC.DEBUG_NFC;
|
let DEBUG = NFC.DEBUG_NFC;
|
||||||
|
|
||||||
let debug;
|
let debug;
|
||||||
if (DEBUG) {
|
function updateDebug() {
|
||||||
|
if (DEBUG) {
|
||||||
debug = function (s) {
|
debug = function (s) {
|
||||||
dump("-*- Nfc: " + s + "\n");
|
dump("-*- Nfc: " + s + "\n");
|
||||||
};
|
};
|
||||||
} else {
|
} else {
|
||||||
debug = function (s) {};
|
debug = function (s) {};
|
||||||
}
|
}
|
||||||
|
};
|
||||||
|
updateDebug();
|
||||||
|
|
||||||
const NFC_CONTRACTID = "@mozilla.org/nfc;1";
|
const NFC_CONTRACTID = "@mozilla.org/nfc;1";
|
||||||
const NFC_CID =
|
const NFC_CID =
|
||||||
@ -98,6 +105,10 @@ XPCOMUtils.defineLazyGetter(this, "gMessageManager", function () {
|
|||||||
init: function init(nfc) {
|
init: function init(nfc) {
|
||||||
this.nfc = nfc;
|
this.nfc = nfc;
|
||||||
|
|
||||||
|
let lock = gSettingsService.createLock();
|
||||||
|
lock.get(NFC.SETTING_NFC_DEBUG, this.nfc);
|
||||||
|
|
||||||
|
Services.obs.addObserver(this, NFC.TOPIC_MOZSETTINGS_CHANGED, false);
|
||||||
Services.obs.addObserver(this, NFC.TOPIC_XPCOM_SHUTDOWN, false);
|
Services.obs.addObserver(this, NFC.TOPIC_XPCOM_SHUTDOWN, false);
|
||||||
this._registerMessageListeners();
|
this._registerMessageListeners();
|
||||||
},
|
},
|
||||||
@ -106,6 +117,7 @@ XPCOMUtils.defineLazyGetter(this, "gMessageManager", function () {
|
|||||||
this.nfc.shutdown();
|
this.nfc.shutdown();
|
||||||
this.nfc = null;
|
this.nfc = null;
|
||||||
|
|
||||||
|
Services.obs.removeObserver(this, NFC.TOPIC_MOZSETTINGS_CHANGED);
|
||||||
Services.obs.removeObserver(this, NFC.TOPIC_XPCOM_SHUTDOWN);
|
Services.obs.removeObserver(this, NFC.TOPIC_XPCOM_SHUTDOWN);
|
||||||
this._unregisterMessageListeners();
|
this._unregisterMessageListeners();
|
||||||
},
|
},
|
||||||
@ -318,6 +330,12 @@ XPCOMUtils.defineLazyGetter(this, "gMessageManager", function () {
|
|||||||
|
|
||||||
observe: function observe(subject, topic, data) {
|
observe: function observe(subject, topic, data) {
|
||||||
switch (topic) {
|
switch (topic) {
|
||||||
|
case NFC.TOPIC_MOZSETTINGS_CHANGED:
|
||||||
|
let setting = JSON.parse(data);
|
||||||
|
if (setting) {
|
||||||
|
this.nfc.handle(setting.key, setting.value);
|
||||||
|
}
|
||||||
|
break;
|
||||||
case NFC.TOPIC_XPCOM_SHUTDOWN:
|
case NFC.TOPIC_XPCOM_SHUTDOWN:
|
||||||
this._shutdown();
|
this._shutdown();
|
||||||
break;
|
break;
|
||||||
@ -581,6 +599,18 @@ Nfc.prototype = {
|
|||||||
return null;
|
return null;
|
||||||
},
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* nsISettingsServiceCallback
|
||||||
|
*/
|
||||||
|
handle: function handle(name, result) {
|
||||||
|
switch (name) {
|
||||||
|
case NFC.SETTING_NFC_DEBUG:
|
||||||
|
DEBUG = result;
|
||||||
|
updateDebug();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* nsIObserver interface methods.
|
* nsIObserver interface methods.
|
||||||
*/
|
*/
|
||||||
|
@ -105,8 +105,11 @@ this.NFC_POWER_LEVEL_DISABLED = 0;
|
|||||||
this.NFC_POWER_LEVEL_LOW = 1;
|
this.NFC_POWER_LEVEL_LOW = 1;
|
||||||
this.NFC_POWER_LEVEL_ENABLED = 2;
|
this.NFC_POWER_LEVEL_ENABLED = 2;
|
||||||
|
|
||||||
|
this.TOPIC_MOZSETTINGS_CHANGED = "mozsettings-changed";
|
||||||
this.TOPIC_XPCOM_SHUTDOWN = "xpcom-shutdown";
|
this.TOPIC_XPCOM_SHUTDOWN = "xpcom-shutdown";
|
||||||
|
|
||||||
|
this.SETTING_NFC_DEBUG = "nfc.debugging.enabled";
|
||||||
|
|
||||||
this.NFC_PEER_EVENT_READY = 0x01;
|
this.NFC_PEER_EVENT_READY = 0x01;
|
||||||
this.NFC_PEER_EVENT_LOST = 0x02;
|
this.NFC_PEER_EVENT_LOST = 0x02;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user