2012-01-19 06:53:51 -08:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
2012-07-20 02:10:44 -07:00
|
|
|
/* Copyright 2012 Mozilla Foundation and Mozilla contributors
|
|
|
|
*
|
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
* you may not use this file except in compliance with the License.
|
|
|
|
* You may obtain a copy of the License at
|
|
|
|
*
|
|
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
*
|
|
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
|
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
* See the License for the specific language governing permissions and
|
|
|
|
* limitations under the License.
|
|
|
|
*/
|
|
|
|
|
2012-01-19 06:53:51 -08:00
|
|
|
#ifndef GonkGPSGeolocationProvider_h
|
|
|
|
#define GonkGPSGeolocationProvider_h
|
|
|
|
|
|
|
|
#include <hardware/gps.h> // for GpsInterface
|
2012-07-16 17:38:46 -07:00
|
|
|
#include "nsCOMPtr.h"
|
2012-01-19 06:53:51 -08:00
|
|
|
#include "nsIGeolocationProvider.h"
|
2012-07-16 17:38:46 -07:00
|
|
|
#include "nsIRadioInterfaceLayer.h"
|
|
|
|
#include "nsString.h"
|
2012-01-19 06:53:51 -08:00
|
|
|
|
2012-07-16 17:38:46 -07:00
|
|
|
class nsIThread;
|
|
|
|
|
2012-01-19 06:53:51 -08:00
|
|
|
class GonkGPSGeolocationProvider : public nsIGeolocationProvider
|
2012-07-16 17:38:46 -07:00
|
|
|
, public nsIRILDataCallback
|
2012-01-19 06:53:51 -08:00
|
|
|
{
|
|
|
|
public:
|
|
|
|
NS_DECL_ISUPPORTS
|
|
|
|
NS_DECL_NSIGEOLOCATIONPROVIDER
|
2012-07-16 17:38:46 -07:00
|
|
|
NS_DECL_NSIRILDATACALLBACK
|
2012-01-19 06:53:51 -08:00
|
|
|
|
|
|
|
static already_AddRefed<GonkGPSGeolocationProvider> GetSingleton();
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
|
|
|
/* Client should use GetSingleton() to get the provider instance. */
|
|
|
|
GonkGPSGeolocationProvider();
|
|
|
|
GonkGPSGeolocationProvider(const GonkGPSGeolocationProvider &);
|
|
|
|
GonkGPSGeolocationProvider & operator = (const GonkGPSGeolocationProvider &);
|
|
|
|
~GonkGPSGeolocationProvider();
|
|
|
|
|
2012-07-16 17:38:46 -07:00
|
|
|
static void LocationCallback(GpsLocation* location);
|
|
|
|
static void StatusCallback(GpsStatus* status);
|
|
|
|
static void SvStatusCallback(GpsSvStatus* sv_info);
|
|
|
|
static void NmeaCallback(GpsUtcTime timestamp, const char* nmea, int length);
|
|
|
|
static void SetCapabilitiesCallback(uint32_t capabilities);
|
|
|
|
static void AcquireWakelockCallback();
|
|
|
|
static void ReleaseWakelockCallback();
|
|
|
|
static pthread_t CreateThreadCallback(const char* name, void (*start)(void*), void* arg);
|
|
|
|
static void RequestUtcTimeCallback();
|
2012-07-16 17:38:46 -07:00
|
|
|
static void AGPSStatusCallback(AGpsStatus* status);
|
|
|
|
static void AGPSRILSetIDCallback(uint32_t flags);
|
|
|
|
static void AGPSRILRefLocCallback(uint32_t flags);
|
2012-07-16 17:38:46 -07:00
|
|
|
|
|
|
|
static GpsCallbacks mCallbacks;
|
2012-07-16 17:38:46 -07:00
|
|
|
static AGpsCallbacks mAGPSCallbacks;
|
|
|
|
static AGpsRilCallbacks mAGPSRILCallbacks;
|
2012-07-16 17:38:46 -07:00
|
|
|
|
|
|
|
void Init();
|
2012-07-16 17:38:46 -07:00
|
|
|
void SetupAGPS();
|
2012-07-16 17:38:46 -07:00
|
|
|
void StartGPS();
|
|
|
|
void ShutdownNow();
|
2012-07-16 17:38:46 -07:00
|
|
|
void RequestDataConnection();
|
|
|
|
void ReleaseDataConnection();
|
|
|
|
void RequestSetID(uint32_t flags);
|
|
|
|
void SetReferenceLocation();
|
2012-07-16 17:38:46 -07:00
|
|
|
|
2012-01-19 06:53:51 -08:00
|
|
|
const GpsInterface* GetGPSInterface();
|
|
|
|
|
|
|
|
static GonkGPSGeolocationProvider* sSingleton;
|
|
|
|
|
|
|
|
bool mStarted;
|
2012-07-16 17:38:46 -07:00
|
|
|
|
|
|
|
bool mSupportsScheduling;
|
|
|
|
bool mSupportsMSB;
|
|
|
|
bool mSupportsMSA;
|
|
|
|
bool mSupportsSingleShot;
|
|
|
|
bool mSupportsTimeInjection;
|
|
|
|
|
2012-01-19 06:53:51 -08:00
|
|
|
const GpsInterface* mGpsInterface;
|
2012-07-16 17:38:46 -07:00
|
|
|
const AGpsInterface* mAGpsInterface;
|
|
|
|
const AGpsRilInterface* mAGpsRilInterface;
|
2012-01-19 06:53:51 -08:00
|
|
|
nsCOMPtr<nsIGeolocationUpdate> mLocationCallback;
|
2012-07-16 17:38:46 -07:00
|
|
|
nsCOMPtr<nsIThread> mInitThread;
|
2012-07-16 17:38:46 -07:00
|
|
|
nsCOMPtr<nsIRadioInterfaceLayer> mRIL;
|
|
|
|
nsAutoString mCid;
|
2012-01-19 06:53:51 -08:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif /* GonkGPSGeolocationProvider_h */
|