From 385cf81f7c20668dd0028a2c8f8bac92338aa9dd Mon Sep 17 00:00:00 2001 From: Edgar Chen Date: Wed, 12 Feb 2014 20:58:11 +0800 Subject: [PATCH] Bug 946589 - Remove 'ril.radio.preferredNetworkType' setting handler. r=hsinyi --- .../tests/marionette/manifest.ini | 2 - ...obile_preferred_network_type_by_setting.js | 65 ------------------- dom/system/gonk/RadioInterfaceLayer.js | 63 +----------------- dom/system/gonk/ril_consts.js | 1 - dom/system/gonk/ril_worker.js | 9 +-- 5 files changed, 3 insertions(+), 137 deletions(-) delete mode 100644 dom/mobileconnection/tests/marionette/test_mobile_preferred_network_type_by_setting.js diff --git a/dom/mobileconnection/tests/marionette/manifest.ini b/dom/mobileconnection/tests/marionette/manifest.ini index 07ad02777d6..6b36dc2f7ea 100644 --- a/dom/mobileconnection/tests/marionette/manifest.ini +++ b/dom/mobileconnection/tests/marionette/manifest.ini @@ -9,8 +9,6 @@ disabled = Bug 808783 [test_mobile_voice_location.js] [test_mobile_operator_names.js] [test_mobile_preferred_network_type.js] -[test_mobile_preferred_network_type_by_setting.js] -disabled = Bug 808783 [test_mobile_data_connection.js] [test_mobile_data_location.js] [test_mobile_data_state.js] diff --git a/dom/mobileconnection/tests/marionette/test_mobile_preferred_network_type_by_setting.js b/dom/mobileconnection/tests/marionette/test_mobile_preferred_network_type_by_setting.js deleted file mode 100644 index 43f4a17d2c6..00000000000 --- a/dom/mobileconnection/tests/marionette/test_mobile_preferred_network_type_by_setting.js +++ /dev/null @@ -1,65 +0,0 @@ -/* Any copyright is dedicated to the Public Domain. - * http://creativecommons.org/publicdomain/zero/1.0/ */ - -MARIONETTE_TIMEOUT = 60000; - -const KEY = "ril.radio.preferredNetworkType"; - -SpecialPowers.addPermission("mobileconnection", true, document); -SpecialPowers.addPermission("settings-read", true, document); -SpecialPowers.addPermission("settings-write", true, document); - -let settings = window.navigator.mozSettings; - -function test_revert_previous_setting_on_invalid_value() { - log("Testing reverting to previous setting on invalid value received"); - - let getLock = settings.createLock(); - let getReq = getLock.get(KEY); - getReq.addEventListener("success", function onGetSuccess() { - let originalValue = getReq.result[KEY] || "wcdma/gsm"; - - let setDone = false; - settings.addObserver(KEY, function observer(setting) { - // Mark if the invalid value has been set in db and wait. - if (setting.settingValue == obj[KEY]) { - setDone = true; - return; - } - - // Skip any change before marking but keep it as original value. - if (!setDone) { - originalValue = setting.settingValue; - return; - } - - settings.removeObserver(KEY, observer); - is(setting.settingValue, originalValue, "Settings reverted"); - window.setTimeout(cleanUp, 0); - }); - - let obj = {}; - obj[KEY] = "AnInvalidValue"; - let setLock = settings.createLock(); - setLock.set(obj); - setLock.addEventListener("error", function onSetError() { - ok(false, "cannot set '" + KEY + "'"); - }); - }); - getReq.addEventListener("error", function onGetError() { - ok(false, "cannot get default value of '" + KEY + "'"); - }); -} - -function cleanUp() { - SpecialPowers.removePermission("mobileconnection", document); - SpecialPowers.removePermission("settings-write", document); - SpecialPowers.removePermission("settings-read", document); - - finish(); -} - -waitFor(test_revert_previous_setting_on_invalid_value, function() { - return navigator.mozMobileConnections[0].voice.connected; -}); - diff --git a/dom/system/gonk/RadioInterfaceLayer.js b/dom/system/gonk/RadioInterfaceLayer.js index c349beea108..e1d69f66d95 100644 --- a/dom/system/gonk/RadioInterfaceLayer.js +++ b/dom/system/gonk/RadioInterfaceLayer.js @@ -1877,9 +1877,6 @@ function RadioInterface(aClientId, aWorkerMessenger) { let lock = gSettingsService.createLock(); - // Read preferred network type from the setting DB. - lock.get("ril.radio.preferredNetworkType", this); - // Read the "time.clock.automatic-update.enabled" setting to see if // we need to adjust the system clock time by NITZ or SNTP. lock.get(kSettingsClockAutoUpdateEnabled, this); @@ -2508,16 +2505,10 @@ RadioInterface.prototype = { connHandler.updateRILNetworkInterface(); }, - _preferredNetworkType: null, getPreferredNetworkType: function(target, message) { this.workerMessenger.send("getPreferredNetworkType", message, (function(response) { if (response.success) { - this._preferredNetworkType = response.networkType; - response.type = RIL.RIL_PREFERRED_NETWORK_TYPE_TO_GECKO[this._preferredNetworkType]; - if (DEBUG) { - this.debug("_preferredNetworkType is now " + - RIL.RIL_PREFERRED_NETWORK_TYPE_TO_GECKO[this._preferredNetworkType]); - } + response.type = RIL.RIL_PREFERRED_NETWORK_TYPE_TO_GECKO[response.networkType]; } target.sendAsyncMessage("RIL:GetPreferredNetworkType", { @@ -2529,7 +2520,6 @@ RadioInterface.prototype = { }, setPreferredNetworkType: function(target, message) { - if (DEBUG) this.debug("setPreferredNetworkType: " + JSON.stringify(message)); let networkType = RIL.RIL_PREFERRED_NETWORK_TYPE_TO_GECKO.indexOf(message.type); if (networkType < 0) { message.errorMsg = RIL.GECKO_ERROR_INVALID_PARAMETER; @@ -2542,14 +2532,6 @@ RadioInterface.prototype = { message.networkType = networkType; this.workerMessenger.send("setPreferredNetworkType", message, (function(response) { - if (response.success) { - this._preferredNetworkType = response.networkType; - if (DEBUG) { - this.debug("_preferredNetworkType is now " + - RIL.RIL_PREFERRED_NETWORK_TYPE_TO_GECKO[this._preferredNetworkType]); - } - } - target.sendAsyncMessage("RIL:SetPreferredNetworkType", { clientId: this.clientId, data: response @@ -2558,43 +2540,6 @@ RadioInterface.prototype = { }).bind(this)); }, - // TODO: Bug 946589 - B2G RIL: follow-up to bug 944225 - remove - // 'ril.radio.preferredNetworkType' setting handler - setPreferredNetworkTypeBySetting: function(value) { - let networkType = RIL.RIL_PREFERRED_NETWORK_TYPE_TO_GECKO.indexOf(value); - if (networkType < 0) { - networkType = (this._preferredNetworkType != null) - ? RIL.RIL_PREFERRED_NETWORK_TYPE_TO_GECKO[this._preferredNetworkType] - : RIL.GECKO_PREFERRED_NETWORK_TYPE_DEFAULT; - gSettingsService.createLock().set("ril.radio.preferredNetworkType", - networkType, null); - return; - } - - if (networkType == this._preferredNetworkType) { - return; - } - - this.workerMessenger.send("setPreferredNetworkType", - { networkType: networkType }, - (function(response) { - if ((this._preferredNetworkType != null) && !response.success) { - gSettingsService.createLock().set("ril.radio.preferredNetworkType", - this._preferredNetworkType, - null); - return false; - } - - this._preferredNetworkType = response.networkType; - if (DEBUG) { - this.debug("_preferredNetworkType is now " + - RIL.RIL_PREFERRED_NETWORK_TYPE_TO_GECKO[this._preferredNetworkType]); - } - - return false; - }).bind(this)); - }, - setCellBroadcastSearchList: function(newSearchListStr) { if (newSearchListStr == this._cellBroadcastSearchListStr) { return; @@ -3277,12 +3222,6 @@ RadioInterface.prototype = { // nsISettingsServiceCallback handle: function(aName, aResult) { switch(aName) { - // TODO: Bug 946589 - B2G RIL: follow-up to bug 944225 - remove - // 'ril.radio.preferredNetworkType' setting handler - case "ril.radio.preferredNetworkType": - if (DEBUG) this.debug("'ril.radio.preferredNetworkType' is now " + aResult); - this.setPreferredNetworkTypeBySetting(aResult); - break; case kSettingsClockAutoUpdateEnabled: this._clockAutoUpdateEnabled = aResult; if (!this._clockAutoUpdateEnabled) { diff --git a/dom/system/gonk/ril_consts.js b/dom/system/gonk/ril_consts.js index f0d070ed2ce..67bb4ff6ea6 100644 --- a/dom/system/gonk/ril_consts.js +++ b/dom/system/gonk/ril_consts.js @@ -415,7 +415,6 @@ this.GECKO_PREFERRED_NETWORK_TYPE_LTE_CDMA_EVDO = "lte/cdma/evdo"; this.GECKO_PREFERRED_NETWORK_TYPE_LTE_WCDMA_GSM = "lte/wcdma/gsm"; this.GECKO_PREFERRED_NETWORK_TYPE_LTE_WCDMA_GSM_CDMA_EVDO = "lte/wcdma/gsm/cdma/evdo"; this.GECKO_PREFERRED_NETWORK_TYPE_LTE_ONLY = "lte"; -this.GECKO_PREFERRED_NETWORK_TYPE_DEFAULT = GECKO_PREFERRED_NETWORK_TYPE_WCDMA_GSM; this.RIL_PREFERRED_NETWORK_TYPE_TO_GECKO = [ GECKO_PREFERRED_NETWORK_TYPE_WCDMA_GSM, GECKO_PREFERRED_NETWORK_TYPE_GSM_ONLY, diff --git a/dom/system/gonk/ril_worker.js b/dom/system/gonk/ril_worker.js index fccb92f3e4f..3041a9eac3b 100644 --- a/dom/system/gonk/ril_worker.js +++ b/dom/system/gonk/ril_worker.js @@ -6136,13 +6136,8 @@ RilObject.prototype[REQUEST_GET_PREFERRED_NETWORK_TYPE] = function REQUEST_GET_P return; } - let Buf = this.context.Buf; - let networkType = RIL_PREFERRED_NETWORK_TYPE_TO_GECKO.indexOf(GECKO_PREFERRED_NETWORK_TYPE_DEFAULT); - let responseLen = Buf.readInt32(); // Number of INT32 responsed. - if (responseLen) { - this.preferredNetworkType = networkType = Buf.readInt32(); - } - options.networkType = networkType; + let results = this.context.Buf.readInt32List(); + options.networkType = this.preferredNetworkType = results[0]; options.success = true; this.sendChromeMessage(options);