Bug 946589 - Remove 'ril.radio.preferredNetworkType' setting handler. r=hsinyi

This commit is contained in:
Edgar Chen 2014-02-12 20:58:11 +08:00
parent 0db40c36c7
commit 385cf81f7c
5 changed files with 3 additions and 137 deletions

View File

@ -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]

View File

@ -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;
});

View File

@ -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) {

View File

@ -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,

View File

@ -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);