Bug 995101 - NFC: Don't use nfc-hardware-state-change event to enable/disable NFC. r=dimi

This commit is contained in:
Yoshi Huang 2014-04-11 17:49:21 +08:00
parent 31ad618f8c
commit 39d0f2704a
3 changed files with 0 additions and 23 deletions

View File

@ -783,10 +783,6 @@ var CustomEventManager = {
case 'inputmethod-update-layouts':
KeyboardHelper.handleEvent(detail);
break;
case 'nfc-hardware-state-change':
Services.obs.notifyObservers(null, 'nfc-hardware-state-change',
JSON.stringify({ nfcHardwareState: detail.nfcHardwareState }));
break;
}
}
}

View File

@ -416,7 +416,6 @@ function Nfc() {
this.worker.onmessage = this.onmessage.bind(this);
Services.obs.addObserver(this, NFC.TOPIC_MOZSETTINGS_CHANGED, false);
Services.obs.addObserver(this, NFC.TOPIC_HARDWARE_STATE, false);
gMessageManager.init(this);
let lock = gSettingsService.createLock();
@ -657,28 +656,11 @@ Nfc.prototype = {
this.handle(setting.key, setting.value);
}
break;
case NFC.TOPIC_HARDWARE_STATE:
let state = JSON.parse(data);
if (state) {
let level = this.hardwareStateToPowerlevel(state.nfcHardwareState);
this.setConfig({ powerLevel: level });
}
break;
}
},
setConfig: function setConfig(prop) {
this.sendToWorker("config", prop);
},
hardwareStateToPowerlevel: function hardwareStateToPowerlevel(state) {
switch (state) {
case 0: return NFC.NFC_POWER_LEVEL_DISABLED;
case 1: return NFC.NFC_POWER_LEVEL_ENABLED;
case 2: return NFC.NFC_POWER_LEVEL_ENABLED;
case 3: return NFC.NFC_POWER_LEVEL_LOW;
default: return NFC.NFC_POWER_LEVEL_UNKNOWN;
}
}
};

View File

@ -63,7 +63,6 @@ this.NFC_POWER_LEVEL_ENABLED = 2;
this.TOPIC_MOZSETTINGS_CHANGED = "mozsettings-changed";
this.TOPIC_XPCOM_SHUTDOWN = "xpcom-shutdown";
this.TOPIC_HARDWARE_STATE = "nfc-hardware-state-change";
this.SETTING_NFC_ENABLED = "nfc.enabled";
this.NFC_PEER_EVENT_READY = 0x01;