From 57be47e7e4ff4346593ff7b0dee3b540dd8c2337 Mon Sep 17 00:00:00 2001 From: Ben Hsu Date: Fri, 6 Feb 2015 03:08:00 -0500 Subject: [PATCH] Bug 1067629 - Part 2: Remove some radio state checks(RadioInterfaceLayer.js). r=aknow --- dom/system/gonk/RadioInterfaceLayer.js | 37 +++----------------------- 1 file changed, 4 insertions(+), 33 deletions(-) diff --git a/dom/system/gonk/RadioInterfaceLayer.js b/dom/system/gonk/RadioInterfaceLayer.js index bb6657d546fc..636d9fc37a54 100644 --- a/dom/system/gonk/RadioInterfaceLayer.js +++ b/dom/system/gonk/RadioInterfaceLayer.js @@ -482,18 +482,6 @@ XPCOMUtils.defineLazyGetter(this, "gRadioEnabledController", function() { return false; }, - _isValidStateForSetRadioEnabled: function(radioState) { - return radioState == Ci.nsIMobileConnection.MOBILE_RADIO_STATE_ENABLED || - radioState == Ci.nsIMobileConnection.MOBILE_RADIO_STATE_DISABLED; - }, - - _isDummyForSetRadioEnabled: function(radioState, data) { - return (radioState == Ci.nsIMobileConnection.MOBILE_RADIO_STATE_ENABLED && - data.enabled) || - (radioState == Ci.nsIMobileConnection.MOBILE_RADIO_STATE_DISABLED && - !data.enabled); - }, - _handleMessage: function(message) { if (DEBUG) debug("RadioControl: handleMessage: " + JSON.stringify(message)); let clientId = message.clientId || 0; @@ -501,19 +489,6 @@ XPCOMUtils.defineLazyGetter(this, "gRadioEnabledController", function() { gMobileConnectionService.getItemByServiceId(clientId); let radioState = connection && connection.radioState; - if (!this._isValidStateForSetRadioEnabled(radioState)) { - message.data.errorMsg = "InvalidStateError"; - message.callback(message.data); - this._processNextMessage(); - return; - } - - if (this._isDummyForSetRadioEnabled(radioState, message.data)) { - message.callback(message.data); - this._processNextMessage(); - return; - } - if (message.data.enabled) { if (this._isRadioAbleToEnableAtClient(clientId)) { this._setRadioEnabledInternal(message); @@ -563,19 +538,15 @@ XPCOMUtils.defineLazyGetter(this, "gRadioEnabledController", function() { let enabled = message.data.enabled || false; let radioInterface = _ril.getRadioInterface(clientId); - this.notifyRadioStateChanged(clientId, - enabled ? Ci.nsIMobileConnection.MOBILE_RADIO_STATE_ENABLING - : Ci.nsIMobileConnection.MOBILE_RADIO_STATE_DISABLING); radioInterface.workerMessenger.send("setRadioEnabled", message.data, (function(response) { if (response.errorMsg) { - // Request fails. Rollback to the original radioState. + // If request fails, set current radio state to unknown, since we will + // handle it in |mobileConnectionService|. this.notifyRadioStateChanged(clientId, - enabled ? Ci.nsIMobileConnection.MOBILE_RADIO_STATE_DISABLED - : Ci.nsIMobileConnection.MOBILE_RADIO_STATE_ENABLED); + Ci.nsIMobileConnection.MOBILE_RADIO_STATE_UNKNOWN); } - message.callback(response); - return false; + return message.callback(response); }).bind(this)); },