dom/system/gonk/GonkGPSGeolocationProvider.h

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/dom/system/gonk/GonkGPSGeolocationProvider.h	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,131 @@
     1.4 +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
     1.5 +/* Copyright 2012 Mozilla Foundation and Mozilla contributors
     1.6 + *
     1.7 + * Licensed under the Apache License, Version 2.0 (the "License");
     1.8 + * you may not use this file except in compliance with the License.
     1.9 + * You may obtain a copy of the License at
    1.10 + *
    1.11 + *     http://www.apache.org/licenses/LICENSE-2.0
    1.12 + *
    1.13 + * Unless required by applicable law or agreed to in writing, software
    1.14 + * distributed under the License is distributed on an "AS IS" BASIS,
    1.15 + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    1.16 + * See the License for the specific language governing permissions and
    1.17 + * limitations under the License.
    1.18 + */
    1.19 +
    1.20 +#ifndef GonkGPSGeolocationProvider_h
    1.21 +#define GonkGPSGeolocationProvider_h
    1.22 +
    1.23 +#include <hardware/gps.h> // for GpsInterface
    1.24 +#include "nsCOMPtr.h"
    1.25 +#include "nsIGeolocationProvider.h"
    1.26 +#include "nsIObserver.h"
    1.27 +#ifdef MOZ_B2G_RIL
    1.28 +#include "nsIRadioInterfaceLayer.h"
    1.29 +#endif
    1.30 +#include "nsISettingsService.h"
    1.31 +
    1.32 +class nsIThread;
    1.33 +
    1.34 +#define GONK_GPS_GEOLOCATION_PROVIDER_CID \
    1.35 +{ 0x48525ec5, 0x5a7f, 0x490a, { 0x92, 0x77, 0xba, 0x66, 0xe0, 0xd2, 0x2c, 0x8b } }
    1.36 +
    1.37 +#define GONK_GPS_GEOLOCATION_PROVIDER_CONTRACTID \
    1.38 +"@mozilla.org/gonk-gps-geolocation-provider;1"
    1.39 +
    1.40 +class GonkGPSGeolocationProvider : public nsIGeolocationProvider
    1.41 +                                 , public nsIObserver
    1.42 +                                 , public nsISettingsServiceCallback
    1.43 +{
    1.44 +public:
    1.45 +  NS_DECL_THREADSAFE_ISUPPORTS
    1.46 +  NS_DECL_NSIGEOLOCATIONPROVIDER
    1.47 +  NS_DECL_NSIOBSERVER
    1.48 +  NS_DECL_NSISETTINGSSERVICECALLBACK
    1.49 +
    1.50 +  static already_AddRefed<GonkGPSGeolocationProvider> GetSingleton();
    1.51 +
    1.52 +private:
    1.53 +
    1.54 +  /* Client should use GetSingleton() to get the provider instance. */
    1.55 +  GonkGPSGeolocationProvider();
    1.56 +  GonkGPSGeolocationProvider(const GonkGPSGeolocationProvider &);
    1.57 +  GonkGPSGeolocationProvider & operator = (const GonkGPSGeolocationProvider &);
    1.58 +  virtual ~GonkGPSGeolocationProvider();
    1.59 +
    1.60 +  static void LocationCallback(GpsLocation* location);
    1.61 +  static void StatusCallback(GpsStatus* status);
    1.62 +  static void SvStatusCallback(GpsSvStatus* sv_info);
    1.63 +  static void NmeaCallback(GpsUtcTime timestamp, const char* nmea, int length);
    1.64 +  static void SetCapabilitiesCallback(uint32_t capabilities);
    1.65 +  static void AcquireWakelockCallback();
    1.66 +  static void ReleaseWakelockCallback();
    1.67 +  static pthread_t CreateThreadCallback(const char* name, void (*start)(void*), void* arg);
    1.68 +  static void RequestUtcTimeCallback();
    1.69 +#ifdef MOZ_B2G_RIL
    1.70 +  static void AGPSStatusCallback(AGpsStatus* status);
    1.71 +  static void AGPSRILSetIDCallback(uint32_t flags);
    1.72 +  static void AGPSRILRefLocCallback(uint32_t flags);
    1.73 +#endif
    1.74 +
    1.75 +  static GpsCallbacks mCallbacks;
    1.76 +#ifdef MOZ_B2G_RIL
    1.77 +  static AGpsCallbacks mAGPSCallbacks;
    1.78 +  static AGpsRilCallbacks mAGPSRILCallbacks;
    1.79 +#endif
    1.80 +
    1.81 +  void Init();
    1.82 +  void StartGPS();
    1.83 +  void ShutdownGPS();
    1.84 +  void InjectLocation(double latitude, double longitude, float accuracy);
    1.85 +  void RequestSettingValue(char* aKey);
    1.86 +#ifdef MOZ_B2G_RIL
    1.87 +  void SetupAGPS();
    1.88 +  int32_t GetDataConnectionState();
    1.89 +  void SetAGpsDataConn(nsAString& aApn);
    1.90 +  void RequestDataConnection();
    1.91 +  void ReleaseDataConnection();
    1.92 +  void RequestSetID(uint32_t flags);
    1.93 +  void SetReferenceLocation();
    1.94 +#endif
    1.95 +
    1.96 +  const GpsInterface* GetGPSInterface();
    1.97 +
    1.98 +  static GonkGPSGeolocationProvider* sSingleton;
    1.99 +
   1.100 +  bool mStarted;
   1.101 +
   1.102 +  bool mSupportsScheduling;
   1.103 +#ifdef MOZ_B2G_RIL
   1.104 +  bool mSupportsMSB;
   1.105 +  bool mSupportsMSA;
   1.106 +#endif
   1.107 +  bool mSupportsSingleShot;
   1.108 +  bool mSupportsTimeInjection;
   1.109 +
   1.110 +  const GpsInterface* mGpsInterface;
   1.111 +#ifdef MOZ_B2G_RIL
   1.112 +  const AGpsInterface* mAGpsInterface;
   1.113 +  const AGpsRilInterface* mAGpsRilInterface;
   1.114 +  nsCOMPtr<nsIRadioInterface> mRadioInterface;
   1.115 +#endif
   1.116 +  nsCOMPtr<nsIGeolocationUpdate> mLocationCallback;
   1.117 +  PRTime mLastGPSDerivedLocationTime;
   1.118 +  nsCOMPtr<nsIThread> mInitThread;
   1.119 +  nsCOMPtr<nsIGeolocationProvider> mNetworkLocationProvider;
   1.120 +
   1.121 +  class NetworkLocationUpdate : public nsIGeolocationUpdate
   1.122 +  {
   1.123 +    public:
   1.124 +      NS_DECL_ISUPPORTS
   1.125 +      NS_DECL_NSIGEOLOCATIONUPDATE
   1.126 +
   1.127 +      NetworkLocationUpdate() {}
   1.128 +
   1.129 +    private:
   1.130 +      virtual ~NetworkLocationUpdate() {}
   1.131 +  };
   1.132 +};
   1.133 +
   1.134 +#endif /* GonkGPSGeolocationProvider_h */

mercurial