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_voice_location.js]
[test_mobile_operator_names.js] [test_mobile_operator_names.js]
[test_mobile_preferred_network_type.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_connection.js]
[test_mobile_data_location.js] [test_mobile_data_location.js]
[test_mobile_data_state.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(); 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 // Read the "time.clock.automatic-update.enabled" setting to see if
// we need to adjust the system clock time by NITZ or SNTP. // we need to adjust the system clock time by NITZ or SNTP.
lock.get(kSettingsClockAutoUpdateEnabled, this); lock.get(kSettingsClockAutoUpdateEnabled, this);
@ -2508,16 +2505,10 @@ RadioInterface.prototype = {
connHandler.updateRILNetworkInterface(); connHandler.updateRILNetworkInterface();
}, },
_preferredNetworkType: null,
getPreferredNetworkType: function(target, message) { getPreferredNetworkType: function(target, message) {
this.workerMessenger.send("getPreferredNetworkType", message, (function(response) { this.workerMessenger.send("getPreferredNetworkType", message, (function(response) {
if (response.success) { if (response.success) {
this._preferredNetworkType = response.networkType; response.type = RIL.RIL_PREFERRED_NETWORK_TYPE_TO_GECKO[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]);
}
} }
target.sendAsyncMessage("RIL:GetPreferredNetworkType", { target.sendAsyncMessage("RIL:GetPreferredNetworkType", {
@ -2529,7 +2520,6 @@ RadioInterface.prototype = {
}, },
setPreferredNetworkType: function(target, message) { setPreferredNetworkType: function(target, message) {
if (DEBUG) this.debug("setPreferredNetworkType: " + JSON.stringify(message));
let networkType = RIL.RIL_PREFERRED_NETWORK_TYPE_TO_GECKO.indexOf(message.type); let networkType = RIL.RIL_PREFERRED_NETWORK_TYPE_TO_GECKO.indexOf(message.type);
if (networkType < 0) { if (networkType < 0) {
message.errorMsg = RIL.GECKO_ERROR_INVALID_PARAMETER; message.errorMsg = RIL.GECKO_ERROR_INVALID_PARAMETER;
@ -2542,14 +2532,6 @@ RadioInterface.prototype = {
message.networkType = networkType; message.networkType = networkType;
this.workerMessenger.send("setPreferredNetworkType", message, (function(response) { 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", { target.sendAsyncMessage("RIL:SetPreferredNetworkType", {
clientId: this.clientId, clientId: this.clientId,
data: response data: response
@ -2558,43 +2540,6 @@ RadioInterface.prototype = {
}).bind(this)); }).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) { setCellBroadcastSearchList: function(newSearchListStr) {
if (newSearchListStr == this._cellBroadcastSearchListStr) { if (newSearchListStr == this._cellBroadcastSearchListStr) {
return; return;
@ -3277,12 +3222,6 @@ RadioInterface.prototype = {
// nsISettingsServiceCallback // nsISettingsServiceCallback
handle: function(aName, aResult) { handle: function(aName, aResult) {
switch(aName) { 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: case kSettingsClockAutoUpdateEnabled:
this._clockAutoUpdateEnabled = aResult; this._clockAutoUpdateEnabled = aResult;
if (!this._clockAutoUpdateEnabled) { 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 = "lte/wcdma/gsm";
this.GECKO_PREFERRED_NETWORK_TYPE_LTE_WCDMA_GSM_CDMA_EVDO = "lte/wcdma/gsm/cdma/evdo"; 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_LTE_ONLY = "lte";
this.GECKO_PREFERRED_NETWORK_TYPE_DEFAULT = GECKO_PREFERRED_NETWORK_TYPE_WCDMA_GSM;
this.RIL_PREFERRED_NETWORK_TYPE_TO_GECKO = [ this.RIL_PREFERRED_NETWORK_TYPE_TO_GECKO = [
GECKO_PREFERRED_NETWORK_TYPE_WCDMA_GSM, GECKO_PREFERRED_NETWORK_TYPE_WCDMA_GSM,
GECKO_PREFERRED_NETWORK_TYPE_GSM_ONLY, GECKO_PREFERRED_NETWORK_TYPE_GSM_ONLY,

View File

@ -6136,13 +6136,8 @@ RilObject.prototype[REQUEST_GET_PREFERRED_NETWORK_TYPE] = function REQUEST_GET_P
return; return;
} }
let Buf = this.context.Buf; let results = this.context.Buf.readInt32List();
let networkType = RIL_PREFERRED_NETWORK_TYPE_TO_GECKO.indexOf(GECKO_PREFERRED_NETWORK_TYPE_DEFAULT); options.networkType = this.preferredNetworkType = results[0];
let responseLen = Buf.readInt32(); // Number of INT32 responsed.
if (responseLen) {
this.preferredNetworkType = networkType = Buf.readInt32();
}
options.networkType = networkType;
options.success = true; options.success = true;
this.sendChromeMessage(options); this.sendChromeMessage(options);