Backed out changeset 9ff2889f236a (bug 1063304)

This commit is contained in:
Carsten "Tomcat" Book 2014-09-17 13:13:08 +02:00
parent 775cb65bd4
commit f39f940858
13 changed files with 85 additions and 160 deletions

View File

@ -7,11 +7,9 @@
#include "BluetoothRilListener.h"
#include "BluetoothHfpManager.h"
#include "nsIIccProvider.h"
#include "nsIMobileConnectionInfo.h"
#include "nsIMobileConnectionService.h"
#include "nsITelephonyService.h"
#include "nsRadioInterfaceLayer.h" // For NS_RILCONTENTHELPER_CONTRACTID.
#include "nsIRadioInterfaceLayer.h"
#include "nsRadioInterfaceLayer.h"
#include "nsServiceManagerUtils.h"
#include "nsString.h"
@ -181,15 +179,11 @@ MobileConnectionListener::Listen(bool aStart)
do_GetService(NS_MOBILE_CONNECTION_SERVICE_CONTRACTID);
NS_ENSURE_TRUE(service, false);
nsCOMPtr<nsIMobileConnection> connection;
service->GetItemByServiceId(mClientId, getter_AddRefs(connection));
NS_ENSURE_TRUE(connection, false);
nsresult rv;
if (aStart) {
rv = connection->RegisterListener(this);
rv = service->RegisterListener(mClientId, this);
} else {
rv = connection->UnregisterListener(this);
rv = service->UnregisterListener(mClientId, this);
}
return NS_SUCCEEDED(rv);
@ -335,17 +329,17 @@ TelephonyListener::Listen(bool aStart)
*/
BluetoothRilListener::BluetoothRilListener()
{
nsCOMPtr<nsIMobileConnectionService> service =
do_GetService(NS_MOBILE_CONNECTION_SERVICE_CONTRACTID);
NS_ENSURE_TRUE_VOID(service);
// Query number of total clients (sim slots)
uint32_t numItems = 0;
if (NS_SUCCEEDED(service->GetNumItems(&numItems))) {
// Init MobileConnectionListener array and IccInfoListener
for (uint32_t i = 0; i < numItems; i++) {
mMobileConnListeners.AppendElement(new MobileConnectionListener(i));
}
uint32_t numOfClients;
nsCOMPtr<nsIRadioInterfaceLayer> radioInterfaceLayer =
do_GetService(NS_RADIOINTERFACELAYER_CONTRACTID);
NS_ENSURE_TRUE_VOID(radioInterfaceLayer);
radioInterfaceLayer->GetNumRadioInterfaces(&numOfClients);
// Init MobileConnectionListener array and IccInfoListener
for (uint32_t i = 0; i < numOfClients; i++) {
mMobileConnListeners.AppendElement(new MobileConnectionListener(i));
}
mTelephonyListener = new TelephonyListener();
@ -381,15 +375,8 @@ BluetoothRilListener::SelectClient()
NS_ENSURE_TRUE_VOID(service);
for (uint32_t i = 0; i < mMobileConnListeners.Length(); i++) {
nsCOMPtr<nsIMobileConnection> connection;
service->GetItemByServiceId(i, getter_AddRefs(connection));
if (!connection) {
BT_WARNING("%s: Failed to get mobile connection", __FUNCTION__);
continue;
}
nsCOMPtr<nsIMobileConnectionInfo> voiceInfo;
connection->GetVoice(getter_AddRefs(voiceInfo));
service->GetVoiceConnectionInfo(i, getter_AddRefs(voiceInfo));
if (!voiceInfo) {
BT_WARNING("%s: Failed to get voice connection info", __FUNCTION__);
continue;

View File

@ -612,16 +612,12 @@ BluetoothHfpManager::HandleVolumeChanged(const nsAString& aData)
void
BluetoothHfpManager::HandleVoiceConnectionChanged(uint32_t aClientId)
{
nsCOMPtr<nsIMobileConnectionService> mcService =
nsCOMPtr<nsIMobileConnectionService> connection =
do_GetService(NS_MOBILE_CONNECTION_SERVICE_CONTRACTID);
NS_ENSURE_TRUE_VOID(mcService);
nsCOMPtr<nsIMobileConnection> connection;
mcService->GetItemByServiceId(aClientId, getter_AddRefs(connection));
NS_ENSURE_TRUE_VOID(connection);
nsCOMPtr<nsIMobileConnectionInfo> voiceInfo;
connection->GetVoice(getter_AddRefs(voiceInfo));
connection->GetVoiceConnectionInfo(aClientId, getter_AddRefs(voiceInfo));
NS_ENSURE_TRUE_VOID(voiceInfo);
nsString type;

View File

@ -606,16 +606,12 @@ BluetoothHfpManager::HandleVolumeChanged(const nsAString& aData)
void
BluetoothHfpManager::HandleVoiceConnectionChanged(uint32_t aClientId)
{
nsCOMPtr<nsIMobileConnectionService> mcService =
nsCOMPtr<nsIMobileConnectionService> connection =
do_GetService(NS_MOBILE_CONNECTION_SERVICE_CONTRACTID);
NS_ENSURE_TRUE_VOID(mcService);
nsCOMPtr<nsIMobileConnection> connection;
mcService->GetItemByServiceId(aClientId, getter_AddRefs(connection));
NS_ENSURE_TRUE_VOID(connection);
nsCOMPtr<nsIMobileConnectionInfo> voiceInfo;
connection->GetVoice(getter_AddRefs(voiceInfo));
connection->GetVoiceConnectionInfo(aClientId, getter_AddRefs(voiceInfo));
NS_ENSURE_TRUE_VOID(voiceInfo);
nsString type;
@ -650,7 +646,7 @@ BluetoothHfpManager::HandleVoiceConnectionChanged(uint32_t aClientId)
* - manual: set mNetworkSelectionMode to 1 (manual)
*/
nsString mode;
connection->GetNetworkSelectionMode(mode);
connection->GetNetworkSelectionMode(aClientId, mode);
if (mode.EqualsLiteral("manual")) {
mNetworkSelectionMode = 1;
} else {

View File

@ -7,11 +7,9 @@
#include "BluetoothRilListener.h"
#include "BluetoothHfpManager.h"
#include "nsIIccProvider.h"
#include "nsIMobileConnectionInfo.h"
#include "nsIMobileConnectionService.h"
#include "nsITelephonyService.h"
#include "nsRadioInterfaceLayer.h" // For NS_RILCONTENTHELPER_CONTRACTID.
#include "nsIRadioInterfaceLayer.h"
#include "nsRadioInterfaceLayer.h"
#include "nsServiceManagerUtils.h"
#include "nsString.h"
@ -181,15 +179,11 @@ MobileConnectionListener::Listen(bool aStart)
do_GetService(NS_MOBILE_CONNECTION_SERVICE_CONTRACTID);
NS_ENSURE_TRUE(service, false);
nsCOMPtr<nsIMobileConnection> connection;
mcService->GetItemByServiceId(mClientId, getter_AddRefs(connection));
NS_ENSURE_TRUE(connection, false);
nsresult rv;
if (aStart) {
rv = connection->RegisterListener(this);
rv = service->RegisterListener(mClientId, this);
} else {
rv = connection->UnregisterListener(this);
rv = service->UnregisterListener(mClientId, this);
}
return NS_SUCCEEDED(rv);
@ -335,17 +329,17 @@ TelephonyListener::Listen(bool aStart)
*/
BluetoothRilListener::BluetoothRilListener()
{
nsCOMPtr<nsIMobileConnectionService> service =
do_GetService(NS_MOBILE_CONNECTION_SERVICE_CONTRACTID);
NS_ENSURE_TRUE_VOID(service);
// Query number of total clients (sim slots)
uint32_t numItems = 0;
if (NS_SUCCEEDED(service->GetNumItems(&numItems))) {
// Init MobileConnectionListener array and IccInfoListener
for (uint32_t i = 0; i < numItems; i++) {
mMobileConnListeners.AppendElement(new MobileConnectionListener(i));
}
uint32_t numOfClients;
nsCOMPtr<nsIRadioInterfaceLayer> radioInterfaceLayer =
do_GetService(NS_RADIOINTERFACELAYER_CONTRACTID);
NS_ENSURE_TRUE_VOID(radioInterfaceLayer);
radioInterfaceLayer->GetNumRadioInterfaces(&numOfClients);
// Init MobileConnectionListener array and IccInfoListener
for (uint32_t i = 0; i < numOfClients; i++) {
mMobileConnListeners.AppendElement(new MobileConnectionListener(i));
}
mTelephonyListener = new TelephonyListener();
@ -381,15 +375,8 @@ BluetoothRilListener::SelectClient()
NS_ENSURE_TRUE_VOID(service);
for (uint32_t i = 0; i < mMobileConnListeners.Length(); i++) {
nsCOMPtr<nsIMobileConnection> connection;
service->GetItemByServiceId(i, getter_AddRefs(connection));
if (!connection) {
BT_WARNING("%s: Failed to get mobile connection", __FUNCTION__);
continue;
}
nsCOMPtr<nsIMobileConnectionInfo> voiceInfo;
connection->GetVoice(getter_AddRefs(voiceInfo));
service->GetVoiceConnectionInfo(i, getter_AddRefs(voiceInfo));
if (!voiceInfo) {
BT_WARNING("%s: Failed to get voice connection info", __FUNCTION__);
continue;

View File

@ -615,16 +615,12 @@ BluetoothHfpManager::HandleVolumeChanged(const nsAString& aData)
void
BluetoothHfpManager::HandleVoiceConnectionChanged(uint32_t aClientId)
{
nsCOMPtr<nsIMobileConnectionService> mcService =
nsCOMPtr<nsIMobileConnectionService> connection =
do_GetService(NS_MOBILE_CONNECTION_SERVICE_CONTRACTID);
NS_ENSURE_TRUE_VOID(mcService);
nsCOMPtr<nsIMobileConnection> connection;
mcService->GetItemByServiceId(aClientId, getter_AddRefs(connection));
NS_ENSURE_TRUE_VOID(connection);
nsCOMPtr<nsIMobileConnectionInfo> voiceInfo;
connection->GetVoice(getter_AddRefs(voiceInfo));
connection->GetVoiceConnectionInfo(aClientId, getter_AddRefs(voiceInfo));
NS_ENSURE_TRUE_VOID(voiceInfo);
nsString type;

View File

@ -606,16 +606,12 @@ BluetoothHfpManager::HandleVolumeChanged(const nsAString& aData)
void
BluetoothHfpManager::HandleVoiceConnectionChanged(uint32_t aClientId)
{
nsCOMPtr<nsIMobileConnectionService> mcService =
nsCOMPtr<nsIMobileConnectionService> connection =
do_GetService(NS_MOBILE_CONNECTION_SERVICE_CONTRACTID);
NS_ENSURE_TRUE_VOID(mcService);
nsCOMPtr<nsIMobileConnection> connection;
mcService->GetItemByServiceId(aClientId, getter_AddRefs(connection));
NS_ENSURE_TRUE_VOID(connection);
nsCOMPtr<nsIMobileConnectionInfo> voiceInfo;
connection->GetVoice(getter_AddRefs(voiceInfo));
connection->GetVoiceConnectionInfo(aClientId, getter_AddRefs(voiceInfo));
NS_ENSURE_TRUE_VOID(voiceInfo);
nsString type;
@ -650,7 +646,7 @@ BluetoothHfpManager::HandleVoiceConnectionChanged(uint32_t aClientId)
* - manual: set mNetworkSelectionMode to 1 (manual)
*/
nsString mode;
connection->GetNetworkSelectionMode(mode);
connection->GetNetworkSelectionMode(aClientId, mode);
if (mode.EqualsLiteral("manual")) {
mNetworkSelectionMode = 1;
} else {

View File

@ -328,9 +328,8 @@ MmsConnection.prototype = {
* @return true if voice call is roaming.
*/
isVoiceRoaming: function() {
let connection =
gMobileConnectionService.getItemByServiceId(this.serviceId);
let isRoaming = connection && connection.voice && connection.voice.roaming;
let voice = gMobileConnectionService.getVoiceConnectionInfo(this.serviceId);
let isRoaming = voice.roaming;
if (DEBUG) debug("isVoiceRoaming = " + isRoaming);
return isRoaming;
},

View File

@ -54,8 +54,7 @@ this.PhoneNumberUtils = {
let clientId = 0;
// Get network mcc
let connection = mobileConnection.getItemByServiceId(clientId);
let voice = connection && connection.voice;
let voice = mobileConnection.getVoiceConnectionInfo(clientId);
if (voice && voice.network && voice.network.mcc) {
mcc = voice.network.mcc;
}

View File

@ -412,14 +412,14 @@ WifiGeoPositionProvider.prototype = {
let service = Cc["@mozilla.org/mobileconnection/mobileconnectionservice;1"]
.getService(Ci.nsIMobileConnectionService);
let numInterfaces = radioService.numRadioInterfaces;
let result = [];
for (let i = 0; i < service.length; i++) {
LOG("Looking for SIM in slot:" + i + " of " + service.length);
let connection = service.getItemByServiceId(i);
let voice = connection && connection.voice;
let cell = voice && voice.cell;
let type = voice && voice.type;
let network = voice && voice.network;
for (let i = 0; i < numInterfaces; i++) {
LOG("Looking for SIM in slot:" + i + " of " + numInterfaces);
let voice = service.getVoiceConnectionInfo(i);
let cell = voice.cell;
let type = voice.type;
let network = voice.network;
if (network && cell && type) {
if (type === "gsm" || type === "gprs" || type === "edge") {

View File

@ -523,14 +523,10 @@ GonkGPSGeolocationProvider::SetReferenceLocation()
return;
}
nsCOMPtr<nsIMobileConnection> connection;
nsCOMPtr<nsIMobileConnectionInfo> voice;
// TODO: Bug 878748 - B2G GPS: acquire correct RadioInterface instance in
// MultiSIM configuration
service->GetItemByServiceId(0 /* Client Id */, getter_AddRefs(connection));
NS_ENSURE_TRUE_VOID(connection);
nsCOMPtr<nsIMobileConnectionInfo> voice;
connection->GetVoice(getter_AddRefs(voice));
service->GetVoiceConnectionInfo(0 /* Client Id */, getter_AddRefs(voice));
if (voice) {
nsCOMPtr<nsIMobileCellInfo> cell;
voice->GetCell(getter_AddRefs(cell));
@ -951,28 +947,16 @@ GonkGPSGeolocationProvider::Observe(nsISupports* aSubject,
bool roaming = false;
int gpsNetworkType = ConvertToGpsNetworkType(type);
if (gpsNetworkType >= 0) {
if (rilface) {
do {
nsCOMPtr<nsIMobileConnectionService> service =
do_GetService(NS_MOBILE_CONNECTION_SERVICE_CONTRACTID);
if (!service) {
break;
}
nsCOMPtr<nsIMobileConnection> connection;
// TODO: Bug 878748 - B2G GPS: acquire correct RadioInterface instance in
// MultiSIM configuration
service->GetItemByServiceId(0 /* Client Id */, getter_AddRefs(connection));
if (!connection) {
break;
}
nsCOMPtr<nsIMobileConnectionInfo> voice;
connection->GetVoice(getter_AddRefs(voice));
if (voice) {
voice->GetRoaming(&roaming);
}
} while (0);
nsCOMPtr<nsIMobileConnectionService> service =
do_GetService(NS_MOBILE_CONNECTION_SERVICE_CONTRACTID);
if (rilface && service) {
nsCOMPtr<nsIMobileConnectionInfo> voice;
// TODO: Bug 878748 - B2G GPS: acquire correct RadioInterface instance in
// MultiSIM configuration
service->GetVoiceConnectionInfo(0 /* Client Id */, getter_AddRefs(voice));
if (voice) {
voice->GetRoaming(&roaming);
}
}
mAGpsRilInterface->update_network_state(
connected,

View File

@ -859,9 +859,7 @@ NetworkManager.prototype = {
dunRetryTimer: Cc["@mozilla.org/timer;1"].createInstance(Ci.nsITimer),
setupDunConnection: function() {
this.dunRetryTimer.cancel();
let connection =
gMobileConnectionService.getItemByServiceId(this._dataDefaultServiceId);
let data = connection && connection.data;
let data = gMobileConnectionService.getDataConnectionInfo(this._dataDefaultServiceId);
if (data && data.state === "registered") {
this.dunRetryTimes = 0;
ril.setupDataCallByType("dun");

View File

@ -584,12 +584,14 @@ XPCOMUtils.defineLazyGetter(this, "gRadioEnabledController", function() {
return false;
},
_isValidStateForSetRadioEnabled: function(radioState) {
_isValidStateForSetRadioEnabled: function(clientId) {
let radioState = gMobileConnectionService.getRadioState(clientId);
return radioState == RIL.GECKO_RADIOSTATE_ENABLED ||
radioState == RIL.GECKO_RADIOSTATE_DISABLED;
},
_isDummyForSetRadioEnabled: function(radioState, data) {
_isDummyForSetRadioEnabled: function(clientId, data) {
let radioState = gMobileConnectionService.getRadioState(clientId);
return (radioState == RIL.GECKO_RADIOSTATE_ENABLED && data.enabled) ||
(radioState == RIL.GECKO_RADIOSTATE_DISABLED && !data.enabled);
},
@ -597,18 +599,16 @@ XPCOMUtils.defineLazyGetter(this, "gRadioEnabledController", function() {
_handleMessage: function(message) {
if (DEBUG) debug("RadioControl: handleMessage: " + JSON.stringify(message));
let clientId = message.clientId || 0;
let connection =
gMobileConnectionService.getItemByServiceId(clientId);
let radioState = connection && connection.radioState;
let radioInterface = _ril.getRadioInterface(clientId);
if (!this._isValidStateForSetRadioEnabled(radioState)) {
if (!this._isValidStateForSetRadioEnabled(clientId)) {
message.data.errorMsg = "InvalidStateError";
message.callback(message.data);
this._processNextMessage();
return;
}
if (this._isDummyForSetRadioEnabled(radioState, message.data)) {
if (this._isDummyForSetRadioEnabled(clientId, message.data)) {
message.callback(message.data);
this._processNextMessage();
return;
@ -1402,12 +1402,9 @@ DataConnectionHandler.prototype = {
return;
}
let connection =
gMobileConnectionService.getItemByServiceId(this.clientId);
// This check avoids data call connection if the radio is not ready
// yet after toggling off airplane mode.
let radioState = connection && connection.radioState;
let radioState = gMobileConnectionService.getRadioState(this.clientId);
if (radioState != RIL.GECKO_RADIOSTATE_ENABLED) {
if (DEBUG) {
this.debug("RIL is not ready for data connection: radio's not ready");
@ -1427,12 +1424,10 @@ DataConnectionHandler.prototype = {
return;
}
let dataInfo = connection && connection.data;
let dataInfo = gMobileConnectionService.getDataConnectionInfo(this.clientId);
let isRegistered =
dataInfo &&
dataInfo.state == RIL.GECKO_MOBILE_CONNECTION_STATE_REGISTERED;
let haveDataConnection =
dataInfo &&
dataInfo.type != RIL.GECKO_MOBILE_CONNECTION_STATE_UNKNOWN;
if (!isRegistered || !haveDataConnection) {
if (DEBUG) {
@ -1492,7 +1487,9 @@ DataConnectionHandler.prototype = {
return;
}
if (gRadioEnabledController.isDeactivatingDataCalls()) {
if (gRadioEnabledController.isDeactivatingDataCalls() ||
radioState == RIL.GECKO_RADIOSTATE_ENABLING ||
radioState == RIL.GECKO_RADIOSTATE_DISABLING) {
// We're changing the radio power currently, ignore any changes.
return;
}
@ -3705,18 +3702,15 @@ RadioInterface.prototype = {
Services.obs.notifyObservers(domMessage, kSmsSendingObserverTopic, null);
}
let connection =
gMobileConnectionService.getItemByServiceId(this.clientId);
// If the radio is disabled or the SIM card is not ready, just directly
// return with the corresponding error code.
let errorCode;
let radioState = connection && connection.radioState;
let radioState = gMobileConnectionService.getRadioState(this.clientId);
if (!PhoneNumberUtils.isPlainPhoneNumber(options.number)) {
if (DEBUG) this.debug("Error! Address is invalid when sending SMS: " +
options.number);
errorCode = Ci.nsIMobileMessageCallback.INVALID_ADDRESS_ERROR;
} else if (radioState == null ||
radioState == RIL.GECKO_RADIOSTATE_DISABLED) {
} else if (radioState == RIL.GECKO_RADIOSTATE_DISABLED) {
if (DEBUG) this.debug("Error! Radio is disabled when sending SMS.");
errorCode = Ci.nsIMobileMessageCallback.RADIO_DISABLED_ERROR;
} else if (this.rilContext.cardState != "ready") {
@ -4220,11 +4214,9 @@ DataCall.prototype = {
this.apnProfile.apn);
}
let connection =
gMobileConnectionService.getItemByServiceId(this.clientId);
let dataInfo = connection && connection.data;
if (dataInfo == null ||
dataInfo.state != RIL.GECKO_MOBILE_CONNECTION_STATE_REGISTERED ||
let radioInterface = this.gRIL.getRadioInterface(this.clientId);
let dataInfo = gMobileConnectionService.getDataConnectionInfo(this.clientId);
if (dataInfo.state != RIL.GECKO_MOBILE_CONNECTION_STATE_REGISTERED ||
dataInfo.type == RIL.GECKO_MOBILE_CONNECTION_STATE_UNKNOWN) {
return;
}
@ -4253,8 +4245,6 @@ DataCall.prototype = {
pdpType = RIL.GECKO_DATACALL_PDP_TYPE_DEFAULT;
}
}
let radioInterface = this.gRIL.getRadioInterface(this.clientId);
radioInterface.sendWorkerMessage("setupDataCall", {
radioTech: radioTechnology,
apn: this.apnProfile.apn,

View File

@ -127,17 +127,14 @@ this.MobileIdentityManager = {
continue;
}
let connection = mobileConnectionService.getItemByServiceId(i);
let voice = connection && connection.voice;
let data = connection && connection.data;
let voice = mobileConnectionService.getVoiceConnectionInfo(i);
let data = mobileConnectionService.getDataConnectionInfo(i);
let operator = null;
if (voice &&
voice.network &&
if (voice.network &&
voice.network.shortName &&
voice.network.shortName.length) {
operator = voice.network.shortName;
} else if (data &&
data.network &&
} else if (data.network &&
data.network.shortName &&
data.network.shortName.length) {
operator = data.network.shortName;
@ -151,7 +148,7 @@ this.MobileIdentityManager = {
msisdn: info.msisdn || info.mdn || null,
operator: operator,
serviceId: i,
roaming: voice && voice.roaming
roaming: voice.roaming
});
}