Bug 1110619 - Part 2: Implementation Changes. r=echen

--HG--
extra : rebase_source : 1b6e744494e8831826d45fef5ec4a48ffdc8841c
This commit is contained in:
Bevis Tseng 2015-11-10 15:30:48 +08:00
Родитель 686572f7d9
Коммит e8573be274
9 изменённых файлов: 96 добавлений и 82 удалений

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

@ -1127,6 +1127,13 @@ MobileConnection::NotifyNetworkSelectionModeChanged()
return NS_OK; return NS_OK;
} }
NS_IMETHODIMP
MobileConnection::NotifyDeviceIdentitiesChanged()
{
// To be supported when bug 1222870 is required in m-c.
return NS_OK;
}
// nsIIccListener // nsIIccListener
NS_IMETHODIMP NS_IMETHODIMP

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

@ -462,6 +462,22 @@ CdmaCellInfo.prototype = {
evdoSnr: UNKNOWN_VALUE evdoSnr: UNKNOWN_VALUE
}; };
function MobileDeviceIdentities(aImei, aImeisv, aEsn, aMeid) {
this.imei = aImei;
this.imeisv = aImeisv;
this.esn = aEsn;
this.meid = aMeid;
}
MobileDeviceIdentities.prototype = {
QueryInterface: XPCOMUtils.generateQI([Ci.nsIMobileDeviceIdentities]),
// nsIMobileDeviceIdentities
imei: null,
imeisv: null,
esn: null,
meid: null
};
function MobileConnectionProvider(aClientId, aRadioInterface) { function MobileConnectionProvider(aClientId, aRadioInterface) {
this._clientId = aClientId; this._clientId = aClientId;
this._radioInterface = aRadioInterface; this._radioInterface = aRadioInterface;
@ -501,6 +517,7 @@ MobileConnectionProvider.prototype = {
lastKnownNetwork: null, lastKnownNetwork: null,
lastKnownHomeNetwork: null, lastKnownHomeNetwork: null,
supportedNetworkTypes: null, supportedNetworkTypes: null,
deviceIdentities: null,
/** /**
* A utility function to dump debug message. * A utility function to dump debug message.
@ -961,6 +978,17 @@ MobileConnectionProvider.prototype = {
aServiceClass]); aServiceClass]);
}, },
notifyDeviceIdentitiesChanged: function(aImei, aImeisv, aEsn, aMeid) {
if (this.deviceIdentities) {
if (DEBUG) this._debug("deviceIdentities shall not be changed once being updated.");
return;
}
this.deviceIdentities =
new MobileDeviceIdentities(aImei, aImeisv, aEsn, aMeid);
this.deliverListenerEvent("notifyDeviceIdentitiesChanged");
},
getSupportedNetworkTypes: function(aTypes) { getSupportedNetworkTypes: function(aTypes) {
aTypes.value = this.supportedNetworkTypes.slice(); aTypes.value = this.supportedNetworkTypes.slice();
return aTypes.value.length; return aTypes.value.length;
@ -1693,6 +1721,12 @@ MobileConnectionService.prototype = {
.notifyCdmaInfoRecAudioControl(aClientId, aUpLink, aDownLink); .notifyCdmaInfoRecAudioControl(aClientId, aUpLink, aDownLink);
}, },
notifyDeviceIdentitiesChanged: function(aClientId, aImei, aImeisv,
aEsn, aMeid) {
this.getItemByServiceId(aClientId)
.notifyDeviceIdentitiesChanged(aImei, aImeisv, aEsn, aMeid);
},
/** /**
* nsIObserver interface. * nsIObserver interface.
*/ */

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

@ -107,6 +107,12 @@ MobileConnectionChild::GetRadioState(int32_t* aRadioState)
return NS_OK; return NS_OK;
} }
NS_IMETHODIMP
MobileConnectionChild::GetDeviceIdentities(nsIMobileDeviceIdentities** aIdentities)
{
return NS_ERROR_NOT_IMPLEMENTED;
}
NS_IMETHODIMP NS_IMETHODIMP
MobileConnectionChild::GetSupportedNetworkTypes(int32_t** aTypes, MobileConnectionChild::GetSupportedNetworkTypes(int32_t** aTypes,
uint32_t* aLength) uint32_t* aLength)

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

@ -288,6 +288,13 @@ MobileConnectionParent::NotifyNetworkSelectionModeChanged()
return SendNotifyNetworkSelectionModeChanged(mode) ? NS_OK : NS_ERROR_FAILURE; return SendNotifyNetworkSelectionModeChanged(mode) ? NS_OK : NS_ERROR_FAILURE;
} }
NS_IMETHODIMP
MobileConnectionParent::NotifyDeviceIdentitiesChanged()
{
// To be supported when bug 1222870 is required in m-c.
return NS_OK;
}
/****************************************************************************** /******************************************************************************
* PMobileConnectionRequestParent * PMobileConnectionRequestParent
******************************************************************************/ ******************************************************************************/

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

@ -1410,7 +1410,9 @@ SmsSendingScheduler.prototype = {
notifyClirModeChanged: function(mode) {}, notifyClirModeChanged: function(mode) {},
notifyLastKnownNetworkChanged: function() {}, notifyLastKnownNetworkChanged: function() {},
notifyLastKnownHomeNetworkChanged: function() {}, notifyLastKnownHomeNetworkChanged: function() {},
notifyNetworkSelectionModeChanged: function() {} notifyNetworkSelectionModeChanged: function() {},
notifyDeviceIdentitiesChanged: function() {}
}; };
this.NSGetFactory = XPCOMUtils.generateNSGetFactory([SmsService]); this.NSGetFactory = XPCOMUtils.generateNSGetFactory([SmsService]);

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

@ -941,7 +941,9 @@ DataCallHandler.prototype = {
notifyLastKnownHomeNetworkChanged: function() {}, notifyLastKnownHomeNetworkChanged: function() {},
notifyNetworkSelectionModeChanged: function() {} notifyNetworkSelectionModeChanged: function() {},
notifyDeviceIdentitiesChanged: function() {}
}; };
function DataCall(aClientId, aApnSetting, aDataCallHandler) { function DataCall(aClientId, aApnSetting, aDataCallHandler) {

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

@ -768,6 +768,13 @@ RadioInterface.prototype = {
case "otastatuschange": case "otastatuschange":
gMobileConnectionService.notifyOtaStatusChanged(this.clientId, message.status); gMobileConnectionService.notifyOtaStatusChanged(this.clientId, message.status);
break; break;
case "deviceidentitieschange":
gMobileConnectionService.notifyDeviceIdentitiesChanged(this.clientId,
message.deviceIdentities.imei,
message.deviceIdentities.imeisv,
message.deviceIdentities.esn,
message.deviceIdentities.meid);
break;
case "radiostatechange": case "radiostatechange":
// gRadioEnabledController should know the radio state for each client, // gRadioEnabledController should know the radio state for each client,
// so notify gRadioEnabledController here. // so notify gRadioEnabledController here.

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

@ -164,12 +164,9 @@ RilObject.prototype = {
this.cardState = GECKO_CARDSTATE_UNINITIALIZED; this.cardState = GECKO_CARDSTATE_UNINITIALIZED;
/** /**
* Strings * Device Identities including IMEI, IMEISV, ESN and MEID.
*/ */
this.IMEI = null; this.deviceIdentities = null;
this.IMEISV = null;
this.ESN = null;
this.MEID = null;
/** /**
* ICC information that is not exposed to Gaia. * ICC information that is not exposed to Gaia.
@ -1166,25 +1163,8 @@ RilObject.prototype = {
this.context.Buf.simpleRequest(REQUEST_SIGNAL_STRENGTH); this.context.Buf.simpleRequest(REQUEST_SIGNAL_STRENGTH);
}, },
getIMEI: function(options) {
// A device's IMEI can't change, so we only need to request it once.
if (this.IMEI) {
if (options && options.rilMessageType) {
options.imei = this.IMEI;
this.sendChromeMessage(options);
}
return;
}
this.context.Buf.simpleRequest(REQUEST_GET_IMEI, options);
},
getIMEISV: function() {
this.context.Buf.simpleRequest(REQUEST_GET_IMEISV);
},
getDeviceIdentity: function() { getDeviceIdentity: function() {
this.context.Buf.simpleRequest(REQUEST_DEVICE_IDENTITY); this.deviceIdentities || this.context.Buf.simpleRequest(REQUEST_DEVICE_IDENTITY);
}, },
getBasebandVersion: function() { getBasebandVersion: function() {
@ -3137,12 +3117,6 @@ RilObject.prototype = {
if (this._waitingRadioTech || isCdma != this._isCdma) { if (this._waitingRadioTech || isCdma != this._isCdma) {
this._isCdma = isCdma; this._isCdma = isCdma;
this._waitingRadioTech = false; this._waitingRadioTech = false;
if (this._isCdma) {
this.getDeviceIdentity();
} else {
this.getIMEI();
this.getIMEISV();
}
this.getICCStatus(); this.getICCStatus();
} }
}, },
@ -4369,28 +4343,8 @@ RilObject.prototype[REQUEST_SET_CALL_WAITING] = function REQUEST_SET_CALL_WAITIN
this.sendChromeMessage(options); this.sendChromeMessage(options);
}; };
RilObject.prototype[REQUEST_SMS_ACKNOWLEDGE] = null; RilObject.prototype[REQUEST_SMS_ACKNOWLEDGE] = null;
RilObject.prototype[REQUEST_GET_IMEI] = function REQUEST_GET_IMEI(length, options) { RilObject.prototype[REQUEST_GET_IMEI] = null;
this.IMEI = this.context.Buf.readString(); RilObject.prototype[REQUEST_GET_IMEISV] = null;
// If the request wasn't made by ril_worker itself, we send the IMEI back to
// chrome.
if (options.rilMessageType) {
if (options.errorMsg) {
this.sendChromeMessage(options);
return;
}
options.imei = this.IMEI;
this.sendChromeMessage(options);
}
};
RilObject.prototype[REQUEST_GET_IMEISV] = function REQUEST_GET_IMEISV(length, options) {
if (options.errorMsg) {
return;
}
this.IMEISV = this.context.Buf.readString();
};
RilObject.prototype[REQUEST_ANSWER] = function REQUEST_ANSWER(length, options) { RilObject.prototype[REQUEST_ANSWER] = function REQUEST_ANSWER(length, options) {
this.sendDefaultResponse(options); this.sendDefaultResponse(options);
}; };
@ -4806,16 +4760,22 @@ RilObject.prototype[REQUEST_CDMA_WRITE_SMS_TO_RUIM] = null;
RilObject.prototype[REQUEST_CDMA_DELETE_SMS_ON_RUIM] = null; RilObject.prototype[REQUEST_CDMA_DELETE_SMS_ON_RUIM] = null;
RilObject.prototype[REQUEST_DEVICE_IDENTITY] = function REQUEST_DEVICE_IDENTITY(length, options) { RilObject.prototype[REQUEST_DEVICE_IDENTITY] = function REQUEST_DEVICE_IDENTITY(length, options) {
if (options.errorMsg) { if (options.errorMsg) {
this.context.debug("Failed to get device identities:" + options.errorMsg);
return; return;
} }
let result = this.context.Buf.readStringList(); let result = this.context.Buf.readStringList();
this.deviceIdentities = {
imei: result[0] || null,
imeisv: result[1] || null,
esn: result[2] || null,
meid: result[3] || null,
};
// The result[0] is for IMEI. (Already be handled in REQUEST_GET_IMEI) this.sendChromeMessage({
// The result[1] is for IMEISV. (Already be handled in REQUEST_GET_IMEISV) rilMessageType: "deviceidentitieschange",
// They are both ignored. deviceIdentities: this.deviceIdentities
this.ESN = result[2]; });
this.MEID = result[3];
}; };
RilObject.prototype[REQUEST_EXIT_EMERGENCY_CALLBACK_MODE] = function REQUEST_EXIT_EMERGENCY_CALLBACK_MODE(length, options) { RilObject.prototype[REQUEST_EXIT_EMERGENCY_CALLBACK_MODE] = function REQUEST_EXIT_EMERGENCY_CALLBACK_MODE(length, options) {
if (options.internal) { if (options.internal) {
@ -5061,6 +5021,11 @@ RilObject.prototype[UNSOLICITED_RESPONSE_RADIO_STATE_CHANGED] = function UNSOLIC
return; return;
} }
if (radioState !== RADIO_STATE_UNAVAILABLE) {
// Retrieve device identities once radio is available.
this.getDeviceIdentity();
}
if (radioState == RADIO_STATE_ON) { if (radioState == RADIO_STATE_ON) {
// This value is defined in RIL v7, we will retrieve radio tech by another // This value is defined in RIL v7, we will retrieve radio tech by another
// request. We leave _isCdma untouched, and it will be set once we get the // request. We leave _isCdma untouched, and it will be set once we get the
@ -5073,14 +5038,6 @@ RilObject.prototype[UNSOLICITED_RESPONSE_RADIO_STATE_CHANGED] = function UNSOLIC
this.radioState == GECKO_RADIOSTATE_DISABLED) && this.radioState == GECKO_RADIOSTATE_DISABLED) &&
newState == GECKO_RADIOSTATE_ENABLED) { newState == GECKO_RADIOSTATE_ENABLED) {
// The radio became available, let's get its info. // The radio became available, let's get its info.
if (!this._waitingRadioTech) {
if (this._isCdma) {
this.getDeviceIdentity();
} else {
this.getIMEI();
this.getIMEISV();
}
}
this.getBasebandVersion(); this.getBasebandVersion();
this.updateCellBroadcastConfig(); this.updateCellBroadcastConfig();
if ((RILQUIRKS_DATA_REGISTRATION_ON_DEMAND || if ((RILQUIRKS_DATA_REGISTRATION_ON_DEMAND ||

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

@ -359,7 +359,8 @@ MobileConnectionListener.prototype = {
notifyClirModeChanged: function(mode) {}, notifyClirModeChanged: function(mode) {},
notifyLastKnownNetworkChanged: function() {}, notifyLastKnownNetworkChanged: function() {},
notifyLastKnownHomeNetworkChanged: function() {}, notifyLastKnownHomeNetworkChanged: function() {},
notifyNetworkSelectionModeChanged: function() {} notifyNetworkSelectionModeChanged: function() {},
notifyDeviceIdentitiesChanged: function() {}
}; };
function TelephonyService() { function TelephonyService() {
@ -1230,22 +1231,13 @@ TelephonyService.prototype = {
* A nsITelephonyDialCallback object. * A nsITelephonyDialCallback object.
*/ */
_getImeiMMI: function(aClientId, aMmi, aCallback) { _getImeiMMI: function(aClientId, aMmi, aCallback) {
this._sendToRilWorker(aClientId, "getIMEI", {}, aResponse => { let connection = gGonkMobileConnectionService.getItemByServiceId(aClientId);
if (aResponse.errorMsg) { if (!connection.deviceIdentities || !connection.deviceIdentities.imei) {
aCallback.notifyDialMMIError(aResponse.errorMsg); aCallback.notifyDialMMIError(RIL.GECKO_ERROR_GENERIC_FAILURE);
return; return;
} }
// We expect to have an IMEI at this point if the request was supposed aCallback.notifyDialMMISuccess(connection.deviceIdentities.imei);
// to query for the IMEI, so getting a successful reply from the RIL
// without containing an actual IMEI number is considered an error.
if (!aResponse.imei) {
aCallback.notifyDialMMIError(RIL.GECKO_ERROR_GENERIC_FAILURE);
return;
}
aCallback.notifyDialMMISuccess(aResponse.imei);
});
}, },
/** /**