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 836b77b5e8
commit 71655e9ca4
2 changed files with 21 additions and 16 deletions

View File

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

View File

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