зеркало из https://github.com/mozilla/gecko-dev.git
Bug 903257 - Part 1: Have a consistent information for signal and registration status. r=hsinyi
This commit is contained in:
Родитель
717a99f971
Коммит
675fe6b2aa
|
@ -857,6 +857,27 @@ RadioInterface.prototype = {
|
|||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* A utility function to compare objects. The srcInfo may contain
|
||||
* 'rilMessageType', should ignore it.
|
||||
*/
|
||||
isInfoChanged: function isInfoChanged(srcInfo, destInfo) {
|
||||
if (!destInfo) {
|
||||
return true;
|
||||
}
|
||||
|
||||
for (let key in srcInfo) {
|
||||
if (key === 'rilMessageType') {
|
||||
continue;
|
||||
}
|
||||
if (srcInfo[key] !== destInfo[key]) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
},
|
||||
|
||||
/**
|
||||
* Process a message from the content process.
|
||||
*/
|
||||
|
@ -1128,6 +1149,7 @@ RadioInterface.prototype = {
|
|||
let dataMessage = message[RIL.NETWORK_INFO_DATA_REGISTRATION_STATE];
|
||||
let operatorMessage = message[RIL.NETWORK_INFO_OPERATOR];
|
||||
let selectionMessage = message[RIL.NETWORK_INFO_NETWORK_SELECTION_MODE];
|
||||
let signalMessage = message[RIL.NETWORK_INFO_SIGNAL];
|
||||
|
||||
// Batch the *InfoChanged messages together
|
||||
if (voiceMessage) {
|
||||
|
@ -1142,17 +1164,21 @@ RadioInterface.prototype = {
|
|||
this.handleOperatorChange(operatorMessage, true);
|
||||
}
|
||||
|
||||
if (signalMessage) {
|
||||
this.handleSignalStrengthChange(signalMessage, true);
|
||||
}
|
||||
|
||||
let voice = this.rilContext.voice;
|
||||
let data = this.rilContext.data;
|
||||
|
||||
this.checkRoamingBetweenOperators(voice);
|
||||
this.checkRoamingBetweenOperators(data);
|
||||
|
||||
if (voiceMessage || operatorMessage) {
|
||||
if (voiceMessage || operatorMessage || signalMessage) {
|
||||
gMessageManager.sendMobileConnectionMessage("RIL:VoiceInfoChanged",
|
||||
this.clientId, voice);
|
||||
}
|
||||
if (dataMessage || operatorMessage) {
|
||||
if (dataMessage || operatorMessage || signalMessage) {
|
||||
gMessageManager.sendMobileConnectionMessage("RIL:DataInfoChanged",
|
||||
this.clientId, data);
|
||||
}
|
||||
|
@ -1335,34 +1361,37 @@ RadioInterface.prototype = {
|
|||
}).bind(this));
|
||||
},
|
||||
|
||||
handleSignalStrengthChange: function handleSignalStrengthChange(message) {
|
||||
/**
|
||||
* Handle signal strength changes.
|
||||
*
|
||||
* @param message The new signal strength.
|
||||
* @param batch When batch is true, the RIL:VoiceInfoChanged and
|
||||
* RIL:DataInfoChanged message will not be sent.
|
||||
*/
|
||||
handleSignalStrengthChange: function handleSignalStrengthChange(message, batch) {
|
||||
let voiceInfo = this.rilContext.voice;
|
||||
if (voiceInfo.signalStrength != message.voice.signalStrength ||
|
||||
voiceInfo.relSignalStrength != message.voice.relSignalStrength) {
|
||||
voiceInfo.signalStrength = message.voice.signalStrength;
|
||||
voiceInfo.relSignalStrength = message.voice.relSignalStrength;
|
||||
gMessageManager.sendMobileConnectionMessage("RIL:VoiceInfoChanged",
|
||||
this.clientId, voiceInfo);
|
||||
// If the voice is not registered, need not to update signal information.
|
||||
if (voiceInfo.state === RIL.GECKO_MOBILE_CONNECTION_STATE_REGISTERED &&
|
||||
this.isInfoChanged(message.voice, voiceInfo)) {
|
||||
this.updateInfo(message.voice, voiceInfo);
|
||||
if (!batch) {
|
||||
gMessageManager.sendMobileConnectionMessage("RIL:VoiceInfoChanged",
|
||||
this.clientId, voiceInfo);
|
||||
}
|
||||
}
|
||||
|
||||
let dataInfo = this.rilContext.data;
|
||||
if (dataInfo.signalStrength != message.data.signalStrength ||
|
||||
dataInfo.relSignalStrength != message.data.relSignalStrength) {
|
||||
dataInfo.signalStrength = message.data.signalStrength;
|
||||
dataInfo.relSignalStrength = message.data.relSignalStrength;
|
||||
gMessageManager.sendMobileConnectionMessage("RIL:DataInfoChanged",
|
||||
this.clientId, dataInfo);
|
||||
// If the data is not registered, need not to update signal information.
|
||||
if (dataInfo.state === RIL.GECKO_MOBILE_CONNECTION_STATE_REGISTERED &&
|
||||
this.isInfoChanged(message.data, dataInfo)) {
|
||||
this.updateInfo(message.data, dataInfo);
|
||||
if (!batch) {
|
||||
gMessageManager.sendMobileConnectionMessage("RIL:DataInfoChanged",
|
||||
this.clientId, dataInfo);
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
networkChanged: function networkChanged(srcNetwork, destNetwork) {
|
||||
return !destNetwork ||
|
||||
destNetwork.longName != srcNetwork.longName ||
|
||||
destNetwork.shortName != srcNetwork.shortName ||
|
||||
destNetwork.mnc != srcNetwork.mnc ||
|
||||
destNetwork.mcc != srcNetwork.mcc;
|
||||
},
|
||||
|
||||
/**
|
||||
* Handle operator information changes.
|
||||
*
|
||||
|
@ -1375,7 +1404,7 @@ RadioInterface.prototype = {
|
|||
let voice = this.rilContext.voice;
|
||||
let data = this.rilContext.data;
|
||||
|
||||
if (this.networkChanged(message, operatorInfo)) {
|
||||
if (this.isInfoChanged(message, operatorInfo)) {
|
||||
this.updateInfo(message, operatorInfo);
|
||||
|
||||
// Update lastKnownNetwork
|
||||
|
|
|
@ -382,11 +382,13 @@ this.NETWORK_INFO_VOICE_REGISTRATION_STATE = "voiceRegistrationState";
|
|||
this.NETWORK_INFO_DATA_REGISTRATION_STATE = "dataRegistrationState";
|
||||
this.NETWORK_INFO_OPERATOR = "operator";
|
||||
this.NETWORK_INFO_NETWORK_SELECTION_MODE = "networkSelectionMode";
|
||||
this.NETWORK_INFO_SIGNAL = "signal";
|
||||
this.NETWORK_INFO_MESSAGE_TYPES = [
|
||||
NETWORK_INFO_VOICE_REGISTRATION_STATE,
|
||||
NETWORK_INFO_DATA_REGISTRATION_STATE,
|
||||
NETWORK_INFO_OPERATOR,
|
||||
NETWORK_INFO_NETWORK_SELECTION_MODE
|
||||
NETWORK_INFO_NETWORK_SELECTION_MODE,
|
||||
NETWORK_INFO_SIGNAL
|
||||
];
|
||||
|
||||
this.GECKO_PREFERRED_NETWORK_TYPE_WCDMA_GSM = "wcdma/gsm";
|
||||
|
|
|
@ -1667,6 +1667,7 @@ let RIL = {
|
|||
this.getDataRegistrationState(); //TODO only GSM
|
||||
this.getOperator();
|
||||
this.getNetworkSelectionMode();
|
||||
this.getSignalStrength();
|
||||
},
|
||||
|
||||
/**
|
||||
|
@ -3428,7 +3429,6 @@ let RIL = {
|
|||
|
||||
// This was moved down from CARD_APPSTATE_READY
|
||||
this.requestNetworkInfo();
|
||||
this.getSignalStrength();
|
||||
if (newCardState == GECKO_CARDSTATE_READY) {
|
||||
// For type SIM, we need to check EF_phase first.
|
||||
// Other types of ICC we can send Terminal_Profile immediately.
|
||||
|
@ -3671,7 +3671,7 @@ let RIL = {
|
|||
}
|
||||
|
||||
info.rilMessageType = "signalstrengthchange";
|
||||
this.sendChromeMessage(info);
|
||||
this._sendNetworkInfoMessage(NETWORK_INFO_SIGNAL, info);
|
||||
|
||||
if (this.cachedDialRequest && info.voice.signalStrength) {
|
||||
// Radio is ready for making the cached emergency call.
|
||||
|
@ -5284,6 +5284,8 @@ RIL[REQUEST_LAST_CALL_FAIL_CAUSE] = function REQUEST_LAST_CALL_FAIL_CAUSE(length
|
|||
}
|
||||
};
|
||||
RIL[REQUEST_SIGNAL_STRENGTH] = function REQUEST_SIGNAL_STRENGTH(length, options) {
|
||||
this._receivedNetworkInfo(NETWORK_INFO_SIGNAL);
|
||||
|
||||
if (options.rilRequestError) {
|
||||
return;
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче