Backed out changeset 7e0b33c685c8 (bug 920551)

This commit is contained in:
Ed Morley 2013-10-25 10:52:14 +01:00
Родитель 15ff1e3c37
Коммит cbfb3cbcec
2 изменённых файлов: 13 добавлений и 55 удалений

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

@ -18,21 +18,19 @@
#include <hardware/gps.h>
#include "GonkGPSGeolocationProvider.h"
#include "SystemWorkerManager.h"
#include "mozilla/Preferences.h"
#include "nsGeoPosition.h"
#include "nsIInterfaceRequestorUtils.h"
#include "nsINetworkManager.h"
#include "nsIRadioInterfaceLayer.h"
#include "nsIDOMIccInfo.h"
#include "nsIDOMMobileConnection.h"
#include "nsJSUtils.h"
#include "nsServiceManagerUtils.h"
#include "nsThreadUtils.h"
#include "nsContentUtils.h"
#ifdef MOZ_B2G_RIL
#include "nsIDOMIccInfo.h"
#include "nsIDOMMobileConnection.h"
#include "nsIRadioInterfaceLayer.h"
#endif
#ifdef AGPS_TYPE_INVALID
#define AGPS_HAVE_DUAL_APN
#endif
@ -46,15 +44,10 @@ static const int kDefaultPeriod = 1000; // ms
// While most methods of GonkGPSGeolocationProvider should only be
// called from main thread, we deliberately put the Init and ShutdownGPS
// methods off main thread to avoid blocking.
#ifdef MOZ_B2G_RIL
NS_IMPL_ISUPPORTS3(GonkGPSGeolocationProvider,
nsIGeolocationProvider,
nsIRILDataCallback,
nsISettingsServiceCallback)
#else
NS_IMPL_ISUPPORTS1(GonkGPSGeolocationProvider,
nsIGeolocationProvider)
#endif
/* static */ GonkGPSGeolocationProvider* GonkGPSGeolocationProvider::sSingleton = nullptr;
GpsCallbacks GonkGPSGeolocationProvider::mCallbacks = {
@ -72,7 +65,6 @@ GpsCallbacks GonkGPSGeolocationProvider::mCallbacks = {
#endif
};
#ifdef MOZ_B2G_RIL
AGpsCallbacks
GonkGPSGeolocationProvider::mAGPSCallbacks = {
AGPSStatusCallback,
@ -85,7 +77,6 @@ GonkGPSGeolocationProvider::mAGPSRILCallbacks = {
AGPSRILRefLocCallback,
CreateThreadCallback,
};
#endif // MOZ_B2G_RIL
void
GonkGPSGeolocationProvider::LocationCallback(GpsLocation* location)
@ -155,10 +146,8 @@ GonkGPSGeolocationProvider::SetCapabilitiesCallback(uint32_t capabilities)
GonkGPSGeolocationProvider::GetSingleton();
provider->mSupportsScheduling = mCapabilities & GPS_CAPABILITY_SCHEDULING;
#ifdef MOZ_B2G_RIL
provider->mSupportsMSB = mCapabilities & GPS_CAPABILITY_MSB;
provider->mSupportsMSA = mCapabilities & GPS_CAPABILITY_MSA;
#endif
provider->mSupportsSingleShot = mCapabilities & GPS_CAPABILITY_SINGLE_SHOT;
#ifdef GPS_CAPABILITY_ON_DEMAND_TIME
provider->mSupportsTimeInjection = mCapabilities & GPS_CAPABILITY_ON_DEMAND_TIME;
@ -207,7 +196,6 @@ GonkGPSGeolocationProvider::RequestUtcTimeCallback()
{
}
#ifdef MOZ_B2G_RIL
void
GonkGPSGeolocationProvider::AGPSStatusCallback(AGpsStatus* status)
{
@ -279,15 +267,12 @@ GonkGPSGeolocationProvider::AGPSRILRefLocCallback(uint32_t flags)
NS_DispatchToMainThread(new RequestRefLocEvent());
}
}
#endif // MOZ_B2G_RIL
GonkGPSGeolocationProvider::GonkGPSGeolocationProvider()
: mStarted(false)
, mSupportsScheduling(false)
#ifdef MOZ_B2G_RIL
, mSupportsMSB(false)
, mSupportsMSA(false)
#endif
, mSupportsSingleShot(false)
, mSupportsTimeInjection(false)
, mGpsInterface(nullptr)
@ -335,7 +320,6 @@ GonkGPSGeolocationProvider::GetGPSInterface()
return result;
}
#ifdef MOZ_B2G_RIL
int32_t
GonkGPSGeolocationProvider::GetDataConnectionState()
{
@ -523,7 +507,6 @@ GonkGPSGeolocationProvider::SetReferenceLocation()
}
}
}
#endif // MOZ_B2G_RIL
void
GonkGPSGeolocationProvider::Init()
@ -540,7 +523,6 @@ GonkGPSGeolocationProvider::Init()
return;
}
#ifdef MOZ_B2G_RIL
mAGpsInterface =
static_cast<const AGpsInterface*>(mGpsInterface->get_extension(AGPS_INTERFACE));
if (mAGpsInterface) {
@ -552,7 +534,6 @@ GonkGPSGeolocationProvider::Init()
if (mAGpsRilInterface) {
mAGpsRilInterface->init(&mAGPSRILCallbacks);
}
#endif
NS_DispatchToMainThread(NS_NewRunnableMethod(this, &GonkGPSGeolocationProvider::StartGPS));
}
@ -565,23 +546,19 @@ GonkGPSGeolocationProvider::StartGPS()
int32_t update = Preferences::GetInt("geo.default.update", kDefaultPeriod);
#ifdef MOZ_B2G_RIL
if (mSupportsMSA || mSupportsMSB) {
SetupAGPS();
}
#endif
int positionMode = GPS_POSITION_MODE_STANDALONE;
bool singleShot = false;
#ifdef MOZ_B2G_RIL
// XXX: If we know this is a single shot request, use MSA can be faster.
if (singleShot && mSupportsMSA) {
positionMode = GPS_POSITION_MODE_MS_ASSISTED;
} else if (mSupportsMSB) {
positionMode = GPS_POSITION_MODE_MS_BASED;
}
#endif
if (!mSupportsScheduling) {
update = kDefaultPeriod;
}
@ -597,7 +574,6 @@ GonkGPSGeolocationProvider::StartGPS()
mGpsInterface->start();
}
#ifdef MOZ_B2G_RIL
void
GonkGPSGeolocationProvider::SetupAGPS()
{
@ -623,8 +599,9 @@ GonkGPSGeolocationProvider::SetupAGPS()
mRadioInterface->RegisterDataCallCallback(this);
}
}
return;
}
#endif // MOZ_B2G_RIL
NS_IMETHODIMP
GonkGPSGeolocationProvider::Startup()
@ -666,11 +643,9 @@ GonkGPSGeolocationProvider::Shutdown()
}
mStarted = false;
#ifdef MOZ_B2G_RIL
if (mRadioInterface) {
mRadioInterface->UnregisterDataCallCallback(this);
}
#endif
mInitThread->Dispatch(NS_NewRunnableMethod(this, &GonkGPSGeolocationProvider::ShutdownGPS),
NS_DISPATCH_NORMAL);
@ -695,7 +670,6 @@ GonkGPSGeolocationProvider::SetHighAccuracy(bool)
return NS_OK;
}
#ifdef MOZ_B2G_RIL
/** nsIRILDataCallback interface **/
NS_IMETHODIMP
@ -747,4 +721,3 @@ GonkGPSGeolocationProvider::HandleError(const nsAString& aErrorMessage)
{
return NS_OK;
}
#endif // MOZ_B2G_RIL

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

@ -20,10 +20,9 @@
#include <hardware/gps.h> // for GpsInterface
#include "nsCOMPtr.h"
#include "nsIGeolocationProvider.h"
#ifdef MOZ_B2G_RIL
#include "nsIRadioInterfaceLayer.h"
#include "nsString.h"
#include "nsISettingsService.h"
#endif
class nsIThread;
@ -34,18 +33,14 @@ class nsIThread;
"@mozilla.org/gonk-gps-geolocation-provider;1"
class GonkGPSGeolocationProvider : public nsIGeolocationProvider
#ifdef MOZ_B2G_RIL
, public nsIRILDataCallback
, public nsISettingsServiceCallback
#endif
{
public:
NS_DECL_THREADSAFE_ISUPPORTS
NS_DECL_NSIGEOLOCATIONPROVIDER
#ifdef MOZ_B2G_RIL
NS_DECL_NSIRILDATACALLBACK
NS_DECL_NSISETTINGSSERVICECALLBACK
#endif
static already_AddRefed<GonkGPSGeolocationProvider> GetSingleton();
@ -66,31 +61,25 @@ private:
static void ReleaseWakelockCallback();
static pthread_t CreateThreadCallback(const char* name, void (*start)(void*), void* arg);
static void RequestUtcTimeCallback();
#ifdef MOZ_B2G_RIL
static void AGPSStatusCallback(AGpsStatus* status);
static void AGPSRILSetIDCallback(uint32_t flags);
static void AGPSRILRefLocCallback(uint32_t flags);
#endif
static GpsCallbacks mCallbacks;
#ifdef MOZ_B2G_RIL
static AGpsCallbacks mAGPSCallbacks;
static AGpsRilCallbacks mAGPSRILCallbacks;
#endif
void Init();
void StartGPS();
void ShutdownGPS();
#ifdef MOZ_B2G_RIL
void SetupAGPS();
int32_t GetDataConnectionState();
void SetAGpsDataConn(nsAString& aApn);
void RequestSettingValue(char* aKey);
void Init();
void SetupAGPS();
void StartGPS();
void ShutdownGPS();
void RequestDataConnection();
void ReleaseDataConnection();
void RequestSettingValue(char* aKey);
void RequestSetID(uint32_t flags);
void SetReferenceLocation();
#endif
const GpsInterface* GetGPSInterface();
@ -99,21 +88,17 @@ private:
bool mStarted;
bool mSupportsScheduling;
#ifdef MOZ_B2G_RIL
bool mSupportsMSB;
bool mSupportsMSA;
#endif
bool mSupportsSingleShot;
bool mSupportsTimeInjection;
const GpsInterface* mGpsInterface;
#ifdef MOZ_B2G_RIL
const AGpsInterface* mAGpsInterface;
const AGpsRilInterface* mAGpsRilInterface;
nsCOMPtr<nsIRadioInterface> mRadioInterface;
#endif
nsCOMPtr<nsIGeolocationUpdate> mLocationCallback;
nsCOMPtr<nsIThread> mInitThread;
nsCOMPtr<nsIRadioInterface> mRadioInterface;
};
#endif /* GonkGPSGeolocationProvider_h */