зеркало из https://github.com/mozilla/gecko-dev.git
Bug 849185 - Disable the airplane mode when an emergency number is dialed (part1). r=allstars.chh
This commit is contained in:
Родитель
d5983a0348
Коммит
46fb501cc0
|
@ -715,6 +715,10 @@ RadioInterfaceLayer.prototype = {
|
||||||
case "setCellBroadcastSearchList":
|
case "setCellBroadcastSearchList":
|
||||||
this.handleSetCellBroadcastSearchList(message);
|
this.handleSetCellBroadcastSearchList(message);
|
||||||
break;
|
break;
|
||||||
|
case "setRadioEnabled":
|
||||||
|
let lock = gSettingsService.createLock();
|
||||||
|
lock.set("ril.radio.disabled", !message.on, null, null);
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
throw new Error("Don't know about this message type: " +
|
throw new Error("Don't know about this message type: " +
|
||||||
message.rilMessageType);
|
message.rilMessageType);
|
||||||
|
|
|
@ -1373,7 +1373,7 @@ let RIL = {
|
||||||
* Boolean indicating the desired power state.
|
* Boolean indicating the desired power state.
|
||||||
*/
|
*/
|
||||||
setRadioPower: function setRadioPower(options) {
|
setRadioPower: function setRadioPower(options) {
|
||||||
Buf.newParcel(REQUEST_RADIO_POWER);
|
Buf.newParcel(REQUEST_RADIO_POWER, options);
|
||||||
Buf.writeUint32(1);
|
Buf.writeUint32(1);
|
||||||
Buf.writeUint32(options.on ? 1 : 0);
|
Buf.writeUint32(options.on ? 1 : 0);
|
||||||
Buf.sendParcel();
|
Buf.sendParcel();
|
||||||
|
@ -1602,6 +1602,14 @@ let RIL = {
|
||||||
Buf.simpleRequest(REQUEST_BASEBAND_VERSION);
|
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.
|
* Dial the phone.
|
||||||
*
|
*
|
||||||
|
@ -1613,30 +1621,60 @@ let RIL = {
|
||||||
* Integer doing something XXX TODO
|
* Integer doing something XXX TODO
|
||||||
*/
|
*/
|
||||||
dial: function dial(options) {
|
dial: function dial(options) {
|
||||||
let dial_request_type = REQUEST_DIAL;
|
let onerror = (function onerror(errorMsg) {
|
||||||
if (this.voiceRegistrationState.emergencyCallsOnly ||
|
options.callIndex = -1;
|
||||||
options.isDialEmergency) {
|
options.rilMessageType = "callError";
|
||||||
if (!this._isEmergencyNumber(options.number)) {
|
options.errorMsg = errorMsg;
|
||||||
// Notify error in establishing the call with an invalid number.
|
this.sendDOMMessage(options);
|
||||||
options.callIndex = -1;
|
}).bind(this);
|
||||||
options.rilMessageType = "callError";
|
|
||||||
options.errorMsg =
|
|
||||||
RIL_CALL_FAILCAUSE_TO_GECKO_CALL_ERROR[CALL_FAIL_UNOBTAINABLE_NUMBER];
|
|
||||||
this.sendDOMMessage(options);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (RILQUIRKS_REQUEST_USE_DIAL_EMERGENCY_CALL) {
|
if (this._isEmergencyNumber(options.number)) {
|
||||||
dial_request_type = REQUEST_DIAL_EMERGENCY_CALL;
|
this.dialEmergencyNumber(options, onerror);
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
if (this._isEmergencyNumber(options.number) &&
|
this.dialNonEmergencyNumber(options, onerror);
|
||||||
RILQUIRKS_REQUEST_USE_DIAL_EMERGENCY_CALL) {
|
}
|
||||||
dial_request_type = REQUEST_DIAL_EMERGENCY_CALL;
|
},
|
||||||
}
|
|
||||||
|
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.writeString(options.number);
|
||||||
Buf.writeUint32(options.clirMode || 0);
|
Buf.writeUint32(options.clirMode || 0);
|
||||||
Buf.writeUint32(options.uusInfo || 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));
|
if (DEBUG) debug("Signal strength " + JSON.stringify(obj));
|
||||||
obj.rilMessageType = "signalstrengthchange";
|
obj.rilMessageType = "signalstrengthchange";
|
||||||
this.sendDOMMessage(obj);
|
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) {
|
RIL[REQUEST_VOICE_REGISTRATION_STATE] = function REQUEST_VOICE_REGISTRATION_STATE(length, options) {
|
||||||
this._receivedNetworkInfo(NETWORK_INFO_VOICE_REGISTRATION_STATE);
|
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) {
|
RIL[REQUEST_RADIO_POWER] = function REQUEST_RADIO_POWER(length, options) {
|
||||||
if (options.rilRequestError) {
|
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;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Загрузка…
Ссылка в новой задаче