mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 744709 - B2G RIL: control radio power via Settings API. r=philikon
This commit is contained in:
parent
efe11bf9eb
commit
5c50e58c2d
@ -65,6 +65,10 @@ XPCOMUtils.defineLazyServiceGetter(this, "ppmm",
|
||||
"@mozilla.org/parentprocessmessagemanager;1",
|
||||
"nsIFrameMessageManager");
|
||||
|
||||
XPCOMUtils.defineLazyServiceGetter(this, "gSettingsService",
|
||||
"@mozilla.org/settingsService;1",
|
||||
"nsISettingsService");
|
||||
|
||||
function convertRILCallState(state) {
|
||||
switch (state) {
|
||||
case RIL.CALL_STATE_ACTIVE:
|
||||
@ -155,6 +159,11 @@ function RadioInterfaceLayer() {
|
||||
signalStrength: null,
|
||||
relSignalStrength: null},
|
||||
};
|
||||
|
||||
// Read the 'ril.radio.disabled' setting in order to start with a known value at
|
||||
// booting time.
|
||||
gSettingsService.getLock().get("ril.radio.disabled", this);
|
||||
|
||||
for each (let msgname in RIL_IPC_MSG_NAMES) {
|
||||
ppmm.addMessageListener(msgname, this);
|
||||
}
|
||||
@ -174,7 +183,8 @@ RadioInterfaceLayer.prototype = {
|
||||
|
||||
QueryInterface: XPCOMUtils.generateQI([Ci.nsIWorkerHolder,
|
||||
Ci.nsIRadioInterfaceLayer,
|
||||
Ci.nsIObserver]),
|
||||
Ci.nsIObserver,
|
||||
Ci.nsISettingsServiceCallback]),
|
||||
|
||||
/**
|
||||
* Process a message from the content process.
|
||||
@ -281,7 +291,7 @@ RadioInterfaceLayer.prototype = {
|
||||
this.handleOperatorChange(message);
|
||||
break;
|
||||
case "radiostatechange":
|
||||
this.radioState.radioState = message.radioState;
|
||||
this.handleRadioStateChange(message);
|
||||
break;
|
||||
case "cardstatechange":
|
||||
this.radioState.cardState = message.cardState;
|
||||
@ -424,6 +434,24 @@ RadioInterfaceLayer.prototype = {
|
||||
}
|
||||
},
|
||||
|
||||
handleRadioStateChange: function handleRadioStateChange(message) {
|
||||
let newState = message.radioState;
|
||||
if (this.radioState.radioState == newState) {
|
||||
return;
|
||||
}
|
||||
this.radioState.radioState = newState;
|
||||
//TODO Should we notify this change as a card state change?
|
||||
|
||||
if (this.radioState.radioState == RIL.GECKO_RADIOSTATE_OFF &&
|
||||
this._radioEnabled) {
|
||||
this.setRadioEnabled(true);
|
||||
}
|
||||
if (this.radioState.radioState == RIL.GECKO_RADIOSTATE_READY &&
|
||||
!this._radioEnabled) {
|
||||
this.setRadioEnabled(false);
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Track the active call and update the audio system as its state changes.
|
||||
*/
|
||||
@ -637,21 +665,26 @@ RadioInterfaceLayer.prototype = {
|
||||
* Handle setting changes.
|
||||
*/
|
||||
handleMozSettingsChanged: function handleMozSettingsChanged(setting) {
|
||||
// We only watch at "ril.data.enabled" flag changes for connecting or
|
||||
// disconnecting the data call. If the value of "ril.data.enabled" is
|
||||
// true and any of the remaining flags change the setting application
|
||||
// should turn this flag to false and then to true in order to reload
|
||||
// the new values and reconnect the data call.
|
||||
if (setting.key != "ril.data.enabled") {
|
||||
return;
|
||||
}
|
||||
if (!setting.value && RILNetworkInterface.connected) {
|
||||
debug("Data call settings: disconnect data call.");
|
||||
RILNetworkInterface.disconnect();
|
||||
}
|
||||
if (setting.value && !RILNetworkInterface.connected) {
|
||||
debug("Data call settings connect data call.");
|
||||
RILNetworkInterface.connect();
|
||||
switch (setting.key) {
|
||||
case "ril.radio.disabled":
|
||||
this._radioEnabled = !setting.value;
|
||||
this.setRadioEnabled(this._radioEnabled);
|
||||
break;
|
||||
case "ril.data.enabled":
|
||||
// We only watch at "ril.data.enabled" flag changes for connecting or
|
||||
// disconnecting the data call. If the value of "ril.data.enabled" is
|
||||
// true and any of the remaining flags change the setting application
|
||||
// should turn this flag to false and then to true in order to reload
|
||||
// the new values and reconnect the data call.
|
||||
if (!setting.value && RILNetworkInterface.connected) {
|
||||
debug("Data call settings: disconnect data call.");
|
||||
RILNetworkInterface.disconnect();
|
||||
}
|
||||
if (setting.value && !RILNetworkInterface.connected) {
|
||||
debug("Data call settings connect data call.");
|
||||
RILNetworkInterface.connect();
|
||||
}
|
||||
break;
|
||||
}
|
||||
},
|
||||
|
||||
@ -686,12 +719,33 @@ RadioInterfaceLayer.prototype = {
|
||||
}
|
||||
},
|
||||
|
||||
// nsISettingsServiceCallback
|
||||
|
||||
// Flag to determine the radio state to start with when we boot up. It
|
||||
// corresponds to the 'ril.radio.disabled' setting from the UI.
|
||||
_radioEnabled: null,
|
||||
|
||||
handle: function handle(aName, aResult) {
|
||||
if (aName == "ril.radio.disabled") {
|
||||
this._radioEnabled = !aResult;
|
||||
}
|
||||
},
|
||||
|
||||
handleError: function handleError(aErrorMessage) {
|
||||
this._radioEnabled = true;
|
||||
},
|
||||
|
||||
// nsIRadioWorker
|
||||
|
||||
worker: null,
|
||||
|
||||
// nsIRadioInterfaceLayer
|
||||
|
||||
setRadioEnabled: function setRadioEnabled(value) {
|
||||
debug("Setting radio power to " + value);
|
||||
this.worker.postMessage({type: "setRadioPower", on: value});
|
||||
},
|
||||
|
||||
radioState: null,
|
||||
|
||||
// Handle phone functions of nsIRILContentHelper
|
||||
|
@ -134,7 +134,7 @@ interface nsIRILContentHelper : nsIMobileConnectionProvider
|
||||
attribute bool speakerEnabled;
|
||||
};
|
||||
|
||||
[scriptable, uuid(d976f4c2-af5b-4fe1-97c2-c9c5d0d1af5c)]
|
||||
[scriptable, uuid(0ffa10cf-9629-42d6-bc48-6d8bea90d1a9)]
|
||||
interface nsIRadioInterfaceLayer : nsISupports
|
||||
{
|
||||
const unsigned short CALL_STATE_UNKNOWN = 0;
|
||||
@ -157,6 +157,11 @@ interface nsIRadioInterfaceLayer : nsISupports
|
||||
const unsigned short DATACALL_STATE_DISCONNECTING = 3;
|
||||
const unsigned short DATACALL_STATE_DISCONNECTED = 4;
|
||||
|
||||
/**
|
||||
* Activates or deactivates radio power.
|
||||
*/
|
||||
void setRadioEnabled(in bool value);
|
||||
|
||||
readonly attribute jsval radioState;
|
||||
|
||||
/**
|
||||
|
@ -1119,10 +1119,10 @@ let RIL = {
|
||||
* @param on
|
||||
* Boolean indicating the desired power state.
|
||||
*/
|
||||
setRadioPower: function setRadioPower(on) {
|
||||
setRadioPower: function setRadioPower(options) {
|
||||
Buf.newParcel(REQUEST_RADIO_POWER);
|
||||
Buf.writeUint32(1);
|
||||
Buf.writeUint32(on ? 1 : 0);
|
||||
Buf.writeUint32(options.on ? 1 : 0);
|
||||
Buf.sendParcel();
|
||||
},
|
||||
|
||||
@ -2877,8 +2877,9 @@ RIL[UNSOLICITED_RESPONSE_RADIO_STATE_CHANGED] = function UNSOLICITED_RESPONSE_RA
|
||||
// TODO hardcoded for now (see bug 726098)
|
||||
let cdma = false;
|
||||
|
||||
if (this.radioState == GECKO_RADIOSTATE_UNAVAILABLE &&
|
||||
newState != GECKO_RADIOSTATE_UNAVAILABLE) {
|
||||
if ((this.radioState == GECKO_RADIOSTATE_UNAVAILABLE ||
|
||||
this.radioState == GECKO_RADIOSTATE_OFF) &&
|
||||
newState == GECKO_RADIOSTATE_READY) {
|
||||
// The radio became available, let's get its info.
|
||||
if (cdma) {
|
||||
this.getDeviceIdentity();
|
||||
@ -2887,13 +2888,6 @@ RIL[UNSOLICITED_RESPONSE_RADIO_STATE_CHANGED] = function UNSOLICITED_RESPONSE_RA
|
||||
this.getIMEISV();
|
||||
}
|
||||
this.getBasebandVersion();
|
||||
|
||||
//XXX TODO For now, just turn the radio on if it's off. for the real
|
||||
// deal we probably want to do the opposite: start with a known state
|
||||
// when we boot up and let the UI layer control the radio power.
|
||||
if (newState == GECKO_RADIOSTATE_OFF) {
|
||||
this.setRadioPower(true);
|
||||
}
|
||||
}
|
||||
|
||||
this.radioState = newState;
|
||||
|
Loading…
Reference in New Issue
Block a user