Bug 814581 - Part 4/8: fix GonkGPSGeolocationProvider. r=kanru

This commit is contained in:
Vicamo Yang 2013-07-02 17:36:44 +08:00
parent a64909caea
commit 2daf485ca1
2 changed files with 21 additions and 16 deletions

View File

@ -322,12 +322,12 @@ GonkGPSGeolocationProvider::GetGPSInterface()
int32_t
GonkGPSGeolocationProvider::GetDataConnectionState()
{
if (!mRIL) {
if (!mRadioInterface) {
return nsINetworkInterface::NETWORK_STATE_UNKNOWN;
}
int32_t state;
mRIL->GetDataCallStateByType(NS_LITERAL_STRING("supl"), &state);
mRadioInterface->GetDataCallStateByType(NS_LITERAL_STRING("supl"), &state);
return state;
}
@ -375,7 +375,7 @@ GonkGPSGeolocationProvider::RequestDataConnection()
{
MOZ_ASSERT(NS_IsMainThread());
if (!mRIL) {
if (!mRadioInterface) {
return;
}
@ -384,7 +384,7 @@ GonkGPSGeolocationProvider::RequestDataConnection()
// We just get supl APN and make AGPS data connection state updated.
RequestSettingValue("ril.supl.apn");
} else {
mRIL->SetupDataCallByType(NS_LITERAL_STRING("supl"));
mRadioInterface->SetupDataCallByType(NS_LITERAL_STRING("supl"));
}
}
@ -393,11 +393,11 @@ GonkGPSGeolocationProvider::ReleaseDataConnection()
{
MOZ_ASSERT(NS_IsMainThread());
if (!mRIL) {
if (!mRadioInterface) {
return;
}
mRIL->DeactivateDataCallByType(NS_LITERAL_STRING("supl"));
mRadioInterface->DeactivateDataCallByType(NS_LITERAL_STRING("supl"));
}
void
@ -405,14 +405,14 @@ GonkGPSGeolocationProvider::RequestSetID(uint32_t flags)
{
MOZ_ASSERT(NS_IsMainThread());
if (!mRIL) {
if (!mRadioInterface) {
return;
}
AGpsSetIDType type = AGPS_SETID_TYPE_NONE;
nsCOMPtr<nsIRilContext> rilCtx;
mRIL->GetRilContext(getter_AddRefs(rilCtx));
mRadioInterface->GetRilContext(getter_AddRefs(rilCtx));
if (rilCtx) {
nsAutoString id;
@ -440,12 +440,12 @@ GonkGPSGeolocationProvider::SetReferenceLocation()
{
MOZ_ASSERT(NS_IsMainThread());
if (!mRIL) {
if (!mRadioInterface) {
return;
}
nsCOMPtr<nsIRilContext> rilCtx;
mRIL->GetRilContext(getter_AddRefs(rilCtx));
mRadioInterface->GetRilContext(getter_AddRefs(rilCtx));
AGpsRefLocation location;
@ -572,9 +572,14 @@ GonkGPSGeolocationProvider::SetupAGPS()
}
// Setup network state listener
mRIL = do_GetService("@mozilla.org/ril;1");
if (mRIL) {
mRIL->RegisterDataCallCallback(this);
nsCOMPtr<nsIRadioInterfaceLayer> ril = do_GetService("@mozilla.org/ril;1");
if (ril) {
// TODO: Bug 878748 - B2G GPS: acquire correct RadioInterface instance in
// MultiSIM configuration
ril->GetRadioInterface(0 /* clientId */, getter_AddRefs(mRadioInterface));
if (mRadioInterface) {
mRadioInterface->RegisterDataCallCallback(this);
}
}
return;
@ -620,8 +625,8 @@ GonkGPSGeolocationProvider::Shutdown()
}
mStarted = false;
if (mRIL) {
mRIL->UnregisterDataCallCallback(this);
if (mRadioInterface) {
mRadioInterface->UnregisterDataCallCallback(this);
}
mInitThread->Dispatch(NS_NewRunnableMethod(this, &GonkGPSGeolocationProvider::ShutdownGPS),

View File

@ -98,7 +98,7 @@ private:
const AGpsRilInterface* mAGpsRilInterface;
nsCOMPtr<nsIGeolocationUpdate> mLocationCallback;
nsCOMPtr<nsIThread> mInitThread;
nsCOMPtr<nsIRadioInterfaceLayer> mRIL;
nsCOMPtr<nsIRadioInterface> mRadioInterface;
};
#endif /* GonkGPSGeolocationProvider_h */