Bug 849185 - Disable the airplane mode when an emergency number is dialed (part1). r=allstars.chh

This commit is contained in:
Hsin-Yi Tsai 2013-03-18 17:03:49 +08:00
Родитель d5983a0348
Коммит 46fb501cc0
2 изменённых файлов: 74 добавлений и 21 удалений

Просмотреть файл

@ -715,6 +715,10 @@ RadioInterfaceLayer.prototype = {
case "setCellBroadcastSearchList":
this.handleSetCellBroadcastSearchList(message);
break;
case "setRadioEnabled":
let lock = gSettingsService.createLock();
lock.set("ril.radio.disabled", !message.on, null, null);
break;
default:
throw new Error("Don't know about this message type: " +
message.rilMessageType);

Просмотреть файл

@ -1373,7 +1373,7 @@ let RIL = {
* Boolean indicating the desired power state.
*/
setRadioPower: function setRadioPower(options) {
Buf.newParcel(REQUEST_RADIO_POWER);
Buf.newParcel(REQUEST_RADIO_POWER, options);
Buf.writeUint32(1);
Buf.writeUint32(options.on ? 1 : 0);
Buf.sendParcel();
@ -1602,6 +1602,14 @@ let RIL = {
Buf.simpleRequest(REQUEST_BASEBAND_VERSION);
},
/**
* Cache the request for making an emergency call when radio is off. The
* request shall include two types of callback functions. 'callback' is
* called when radio is ready, and 'onerror' is called when turning radio
* on fails.
*/
cachedDialRequest : null,
/**
* Dial the phone.
*
@ -1613,30 +1621,60 @@ let RIL = {
* Integer doing something XXX TODO
*/
dial: function dial(options) {
let dial_request_type = REQUEST_DIAL;
if (this.voiceRegistrationState.emergencyCallsOnly ||
options.isDialEmergency) {
if (!this._isEmergencyNumber(options.number)) {
// Notify error in establishing the call with an invalid number.
options.callIndex = -1;
options.rilMessageType = "callError";
options.errorMsg =
RIL_CALL_FAILCAUSE_TO_GECKO_CALL_ERROR[CALL_FAIL_UNOBTAINABLE_NUMBER];
this.sendDOMMessage(options);
return;
}
let onerror = (function onerror(errorMsg) {
options.callIndex = -1;
options.rilMessageType = "callError";
options.errorMsg = errorMsg;
this.sendDOMMessage(options);
}).bind(this);
if (RILQUIRKS_REQUEST_USE_DIAL_EMERGENCY_CALL) {
dial_request_type = REQUEST_DIAL_EMERGENCY_CALL;
}
if (this._isEmergencyNumber(options.number)) {
this.dialEmergencyNumber(options, onerror);
} else {
if (this._isEmergencyNumber(options.number) &&
RILQUIRKS_REQUEST_USE_DIAL_EMERGENCY_CALL) {
dial_request_type = REQUEST_DIAL_EMERGENCY_CALL;
}
this.dialNonEmergencyNumber(options, onerror);
}
},
dialNonEmergencyNumber: function dialNonEmergencyNumber(options, onerror) {
if (this.radioState == GECKO_RADIOSTATE_OFF) {
// Notify error in establishing the call without radio.
onerror(GECKO_ERROR_RADIO_NOT_AVAILABLE);
return;
}
let token = Buf.newParcel(dial_request_type);
if (this.voiceRegistrationState.emergencyCallsOnly ||
options.isDialEmergency) {
onerror(RIL_CALL_FAILCAUSE_TO_GECKO_CALL_ERROR[CALL_FAIL_UNOBTAINABLE_NUMBER]);
return;
}
options.request = REQUEST_DIAL;
this.sendDialRequest(options);
},
dialEmergencyNumber: function dialEmergencyNumber(options, onerror) {
options.request = RILQUIRKS_REQUEST_USE_DIAL_EMERGENCY_CALL ?
REQUEST_DIAL_EMERGENCY_CALL : REQUEST_DIAL;
if (this.radioState == GECKO_RADIOSTATE_OFF) {
if (DEBUG) debug("Automatically enable radio for an emergency call.");
if (!this.cachedDialRequest) {
this.cachedDialRequest = {};
}
this.cachedDialRequest.onerror = onerror;
this.cachedDialRequest.callback = this.sendDialRequest.bind(this, options);
// Change radio setting value in settings DB to enable radio.
this.sendDOMMessage({rilMessageType: "setRadioEnabled", on: true});
return;
}
this.sendDialRequest(options);
},
sendDialRequest: function sendDialRequest(options) {
let token = Buf.newParcel(options.request);
Buf.writeString(options.number);
Buf.writeUint32(options.clirMode || 0);
Buf.writeUint32(options.uusInfo || 0);
@ -4513,6 +4551,12 @@ RIL[REQUEST_SIGNAL_STRENGTH] = function REQUEST_SIGNAL_STRENGTH(length, options)
if (DEBUG) debug("Signal strength " + JSON.stringify(obj));
obj.rilMessageType = "signalstrengthchange";
this.sendDOMMessage(obj);
if (this.cachedDialRequest && obj.gsmDBM && obj.gsmRelative) {
// Radio is ready for making the cached emergency call.
this.cachedDialRequest.callback();
this.cachedDialRequest = null;
}
};
RIL[REQUEST_VOICE_REGISTRATION_STATE] = function REQUEST_VOICE_REGISTRATION_STATE(length, options) {
this._receivedNetworkInfo(NETWORK_INFO_VOICE_REGISTRATION_STATE);
@ -4549,6 +4593,11 @@ RIL[REQUEST_OPERATOR] = function REQUEST_OPERATOR(length, options) {
};
RIL[REQUEST_RADIO_POWER] = function REQUEST_RADIO_POWER(length, options) {
if (options.rilRequestError) {
if (this.cachedDialRequest && options.on) {
// Turning on radio fails. Notify the error of making an emergency call.
this.cachedDialRequest.onerror(GECKO_ERROR_RADIO_NOT_AVAILABLE);
this.cachedDialRequest = null;
}
return;
}