Bug 869768 - Part 3: RIL implementation for roaming preference. r=hsinyi

This commit is contained in:
Edgar Chen 2013-06-10 15:47:03 +08:00
parent e4a7673c36
commit d552adfc5f
5 changed files with 171 additions and 5 deletions

View File

@ -30,7 +30,7 @@ interface nsIMobileConnectionListener : nsISupports
* XPCOM component (in the content process) that provides the mobile
* network information.
*/
[scriptable, uuid(3fea6ca5-c535-4662-9f42-eb2fc2ae9975)]
[scriptable, uuid(12705160-d1b6-11e2-8b8b-0800200c9a66)]
interface nsIMobileConnectionProvider : nsISupports
{
/**
@ -49,6 +49,10 @@ interface nsIMobileConnectionProvider : nsISupports
nsIDOMDOMRequest selectNetwork(in nsIDOMWindow window, in nsIDOMMozMobileNetworkInfo network);
nsIDOMDOMRequest selectNetworkAutomatically(in nsIDOMWindow window);
nsIDOMDOMRequest setRoamingPreference(in nsIDOMWindow window,
in DOMString mode);
nsIDOMDOMRequest getRoamingPreference(in nsIDOMWindow window);
nsIDOMDOMRequest sendMMI(in nsIDOMWindow window, in DOMString mmi);
nsIDOMDOMRequest cancelMMI(in nsIDOMWindow window);

View File

@ -102,7 +102,9 @@ const RIL_IPC_MSG_NAMES = [
"RIL:IccCloseChannel",
"RIL:IccExchangeAPDU",
"RIL:ReadIccContacts",
"RIL:UpdateIccContact"
"RIL:UpdateIccContact",
"RIL:SetRoamingPreference",
"RIL:GetRoamingPreference"
];
XPCOMUtils.defineLazyServiceGetter(this, "cpmm",
@ -624,6 +626,48 @@ RILContentHelper.prototype = {
return request;
},
setRoamingPreference: function setRoamingPreference(window, mode) {
if (window == null) {
throw Components.Exception("Can't get window object",
Cr.NS_ERROR_UNEXPECTED);
}
let request = Services.DOMRequest.createRequest(window);
let requestId = this.getRequestId(request);
if (!mode) {
this.dispatchFireRequestError(requestId, "InvalidParameter");
return request;
}
cpmm.sendAsyncMessage("RIL:SetRoamingPreference", {
clientId: 0,
data: {
requestId: requestId,
mode: mode
}
});
return request;
},
getRoamingPreference: function getRoamingPreference(window) {
if (window == null) {
throw Components.Exception("Can't get window object",
Cr.NS_ERROR_UNEXPECTED);
}
let request = Services.DOMRequest.createRequest(window);
let requestId = this.getRequestId(request);
cpmm.sendAsyncMessage("RIL:GetRoamingPreference", {
clientId: 0,
data: {
requestId: requestId
}
});
return request;
},
getCardLockState: function getCardLockState(window, lockType) {
if (window == null) {
throw Components.Exception("Can't get window object",
@ -1541,6 +1585,12 @@ RILContentHelper.prototype = {
[message]);
break;
}
case "RIL:SetRoamingPreference":
this.handleSetRoamingPreference(msg.json);
break;
case "RIL:GetRoamingPreference":
this.handleGetRoamingPreference(msg.json);
break;
}
},
@ -1876,6 +1926,22 @@ RILContentHelper.prototype = {
return gUUIDGenerator.generateUUID().toString();
},
handleSetRoamingPreference: function handleSetRoamingPreference(message) {
if (message.errorMsg) {
this.fireRequestError(message.requestId, message.errorMsg);
} else {
this.fireRequestSuccess(message.requestId, null);
}
},
handleGetRoamingPreference: function handleGetRoamingPreference(message) {
if (message.errorMsg) {
this.fireRequestError(message.requestId, message.errorMsg);
} else {
this.fireRequestSuccess(message.requestId, message.mode);
}
},
_deliverEvent: function _deliverEvent(listenerType, name, args) {
let thisListeners = this[listenerType];
if (!thisListeners) {

View File

@ -106,7 +106,9 @@ const RIL_IPC_MOBILECONNECTION_MSG_NAMES = [
"RIL:SetCallWaitingOption",
"RIL:GetCallWaitingOption",
"RIL:SetCallingLineIdRestriction",
"RIL:GetCallingLineIdRestriction"
"RIL:GetCallingLineIdRestriction",
"RIL:SetRoamingPreference",
"RIL:GetRoamingPreference"
];
const RIL_IPC_ICCMANAGER_MSG_NAMES = [
@ -876,6 +878,14 @@ RadioInterface.prototype = {
case "RIL:GetVoicemailInfo":
// This message is sync.
return this.voicemailInfo;
case "RIL:SetRoamingPreference":
gMessageManager.saveRequestTarget(msg);
this.setRoamingPreference(msg.json.data);
break;
case "RIL:GetRoamingPreference":
gMessageManager.saveRequestTarget(msg);
this.getRoamingPreference(msg.json.data);
break;
}
},
@ -1072,6 +1082,12 @@ RadioInterface.prototype = {
let lock = gSettingsService.createLock();
lock.set("ril.radio.disabled", !message.on, null, null);
break;
case "setRoamingPreference":
this.handleSetRoamingPreference(message);
break;
case "queryRoamingPreference":
this.handleQueryRoamingPreference(message);
break;
default:
throw new Error("Don't know about this message type: " +
message.rilMessageType);
@ -2268,6 +2284,16 @@ RadioInterface.prototype = {
message);
},
handleSetRoamingPreference: function handleSetRoamingPreference(message) {
if (DEBUG) this.debug("handleSetRoamingPreference: " + JSON.stringify(message));
gMessageManager.sendRequestResults("RIL:SetRoamingPreference", message);
},
handleQueryRoamingPreference: function handleQueryRoamingPreference(message) {
if (DEBUG) this.debug("handleQueryRoamingPreference: " + JSON.stringify(message));
gMessageManager.sendRequestResults("RIL:GetRoamingPreference", message);
},
// nsIObserver
observe: function observe(subject, topic, data) {
@ -2657,6 +2683,18 @@ RadioInterface.prototype = {
this.worker.postMessage(message);
},
getRoamingPreference: function getRoamingPreference(message) {
if (DEBUG) this.debug("getRoamingPreference: " + JSON.stringify(message));
message.rilMessageType = "queryRoamingPreference";
this.worker.postMessage(message);
},
setRoamingPreference: function setRoamingPreference(message) {
if (DEBUG) this.debug("setRoamingPreference: " + JSON.stringify(message));
message.rilMessageType = "setRoamingPreference";
this.worker.postMessage(message);
},
get microphoneMuted() {
return gAudioManager.microphoneMuted;
},

View File

@ -2681,6 +2681,21 @@ this.PDU_CDMA_MSG_CODING_IS_91_TYPE_SMS_FULL = 0x83;
this.PDU_CDMA_MSG_CODING_IS_91_TYPE_CLI = 0x84;
this.PDU_CDMA_MSG_CODING_IS_91_TYPE_SMS = 0x85;
// CDMA roaming preference mode
this.CDMA_ROAMING_PREFERENCE_HOME = 0;
this.CDMA_ROAMING_PREFERENCE_AFFILIATED = 1;
this.CDMA_ROAMING_PREFERENCE_ANY = 2;
this.GECKO_CDMA_ROAMING_PREFERENCE_HOME = "home";
this.GECKO_CDMA_ROAMING_PREFERENCE_AFFILIATED = "affiliated";
this.GECKO_CDMA_ROAMING_PREFERENCE_ANY = "any";
this.CDMA_ROAMING_PREFERENCE_TO_GECKO = [
GECKO_CDMA_ROAMING_PREFERENCE_HOME, // CDMA_ROAMING_PREFERENCE_HOME
GECKO_CDMA_ROAMING_PREFERENCE_AFFILIATED, // CDMA_ROAMING_PREFERENCE_AFFILIATED
GECKO_CDMA_ROAMING_PREFERENCE_ANY // CDMA_ROAMING_PREFERENCE_ANY
];
/**
* The table for MCC which the length of MNC is 3
*

View File

@ -1608,6 +1608,31 @@ let RIL = {
Buf.simpleRequest(REQUEST_SET_NETWORK_SELECTION_AUTOMATIC, options);
},
/**
* Set the roaming preference mode
*/
setRoamingPreference: function setRoamingPreference(options) {
let roamingMode = CDMA_ROAMING_PREFERENCE_TO_GECKO.indexOf(options.mode);
if (roamingMode === -1) {
options.errorMsg = GECKO_ERROR_INVALID_PARAMETER;
this.sendDOMMessage(options);
return;
}
Buf.newParcel(REQUEST_CDMA_SET_ROAMING_PREFERENCE, options);
Buf.writeUint32(1);
Buf.writeUint32(roamingMode);
Buf.sendParcel();
},
/**
* Get the roaming preference mode
*/
queryRoamingPreference: function getRoamingPreference(options) {
Buf.simpleRequest(REQUEST_CDMA_QUERY_ROAMING_PREFERENCE, options);
},
/**
* Open Logical UICC channel (aid) for Secure Element access
*/
@ -5558,8 +5583,26 @@ RIL[REQUEST_GET_PREFERRED_NETWORK_TYPE] = function REQUEST_GET_PREFERRED_NETWORK
RIL[REQUEST_GET_NEIGHBORING_CELL_IDS] = null;
RIL[REQUEST_SET_LOCATION_UPDATES] = null;
RIL[REQUEST_CDMA_SET_SUBSCRIPTION_SOURCE] = null;
RIL[REQUEST_CDMA_SET_ROAMING_PREFERENCE] = null;
RIL[REQUEST_CDMA_QUERY_ROAMING_PREFERENCE] = null;
RIL[REQUEST_CDMA_SET_ROAMING_PREFERENCE] = function REQUEST_CDMA_SET_ROAMING_PREFERENCE(length, options) {
if (options.rilRequestError) {
options.errorMsg = RIL_ERROR_TO_GECKO_ERROR[options.rilRequestError];
this.sendDOMMessage(options);
return;
}
this.sendDOMMessage(options);
};
RIL[REQUEST_CDMA_QUERY_ROAMING_PREFERENCE] = function REQUEST_CDMA_QUERY_ROAMING_PREFERENCE(length, options) {
if (options.rilRequestError) {
options.errorMsg = RIL_ERROR_TO_GECKO_ERROR[options.rilRequestError];
this.sendDOMMessage(options);
return;
}
let mode = Buf.readUint32List();
options.mode = CDMA_ROAMING_PREFERENCE_TO_GECKO[mode[0]];
this.sendDOMMessage(options);
};
RIL[REQUEST_SET_TTY_MODE] = null;
RIL[REQUEST_QUERY_TTY_MODE] = null;
RIL[REQUEST_CDMA_SET_PREFERRED_VOICE_PRIVACY_MODE] = null;