Bug 995101 - NFC: Don't use nfc-hardware-state-change event to enable/disable NFC. r=dimi
authorYoshi Huang <allstars.chh@mozilla.com>
Fri, 11 Apr 2014 17:49:21 +0800
changeset 197748 0c1f862f7b447dd5fd334f037d47b5f6232561a6
parent 197747 5c03da8af06574b4bd8cfa15e8fd7c605aad7bb3
child 197749 e138dc649747f171f1098aad851d3baa3dd6f608
push id3624
push userasasaki@mozilla.com
push dateMon, 09 Jun 2014 21:49:01 +0000
treeherdermozilla-beta@b1a5da15899a [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersdimi
bugs995101
milestone31.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 995101 - NFC: Don't use nfc-hardware-state-change event to enable/disable NFC. r=dimi
b2g/chrome/content/shell.js
dom/system/gonk/Nfc.js
dom/system/gonk/nfc_consts.js
--- a/b2g/chrome/content/shell.js
+++ b/b2g/chrome/content/shell.js
@@ -778,20 +778,16 @@ var CustomEventManager = {
           JSON.stringify({ callerID: detail.chromeEventID,
                            keyword: detail.keyword,
                            manifestURL: detail.manifestURL,
                            selectedApps: detail.peers }));
         break;
       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;
     }
   }
 }
 
 var AlertsHelper = {
   _listeners: {},
   _count: 0,
 
--- a/dom/system/gonk/Nfc.js
+++ b/dom/system/gonk/Nfc.js
@@ -411,17 +411,16 @@ XPCOMUtils.defineLazyGetter(this, "gMess
 
 function Nfc() {
   debug("Starting Worker");
   this.worker = new ChromeWorker("resource://gre/modules/nfc_worker.js");
   this.worker.onerror = this.onerror.bind(this);
   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();
   lock.get(NFC.SETTING_NFC_ENABLED, this);
   // Maps sessionId (that are generated from nfcd) with a unique guid : 'SessionToken'
   this.sessionTokenMap = {};
   this.targetsByRequestId = {};
 
@@ -652,36 +651,19 @@ Nfc.prototype = {
     switch (topic) {
       case NFC.TOPIC_MOZSETTINGS_CHANGED:
         let setting = JSON.parse(data);
         if (setting) {
           let setting = JSON.parse(data);
           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;
-    }
   }
 };
 
 if (NFC_ENABLED) {
   this.NSGetFactory = XPCOMUtils.generateNSGetFactory([Nfc]);
 }
--- a/dom/system/gonk/nfc_consts.js
+++ b/dom/system/gonk/nfc_consts.js
@@ -58,16 +58,15 @@ this.GECKO_NFC_ERROR_GENERIC_FAILURE    
 // NFC powerlevels must match config PDUs.
 this.NFC_POWER_LEVEL_UNKNOWN        = -1;
 this.NFC_POWER_LEVEL_DISABLED       = 0;
 this.NFC_POWER_LEVEL_LOW            = 1;
 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;
 this.NFC_PEER_EVENT_LOST  = 0x02;
 
 // Allow this file to be imported via Components.utils.import().
 this.EXPORTED_SYMBOLS = Object.keys(this);