dom/system/gonk/GonkGPSGeolocationProvider.h

Thu, 22 Jan 2015 13:21:57 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Thu, 22 Jan 2015 13:21:57 +0100
branch
TOR_BUG_9701
changeset 15
b8a032363ba2
permissions
-rw-r--r--

Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6

michael@0 1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
michael@0 2 /* Copyright 2012 Mozilla Foundation and Mozilla contributors
michael@0 3 *
michael@0 4 * Licensed under the Apache License, Version 2.0 (the "License");
michael@0 5 * you may not use this file except in compliance with the License.
michael@0 6 * You may obtain a copy of the License at
michael@0 7 *
michael@0 8 * http://www.apache.org/licenses/LICENSE-2.0
michael@0 9 *
michael@0 10 * Unless required by applicable law or agreed to in writing, software
michael@0 11 * distributed under the License is distributed on an "AS IS" BASIS,
michael@0 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
michael@0 13 * See the License for the specific language governing permissions and
michael@0 14 * limitations under the License.
michael@0 15 */
michael@0 16
michael@0 17 #ifndef GonkGPSGeolocationProvider_h
michael@0 18 #define GonkGPSGeolocationProvider_h
michael@0 19
michael@0 20 #include <hardware/gps.h> // for GpsInterface
michael@0 21 #include "nsCOMPtr.h"
michael@0 22 #include "nsIGeolocationProvider.h"
michael@0 23 #include "nsIObserver.h"
michael@0 24 #ifdef MOZ_B2G_RIL
michael@0 25 #include "nsIRadioInterfaceLayer.h"
michael@0 26 #endif
michael@0 27 #include "nsISettingsService.h"
michael@0 28
michael@0 29 class nsIThread;
michael@0 30
michael@0 31 #define GONK_GPS_GEOLOCATION_PROVIDER_CID \
michael@0 32 { 0x48525ec5, 0x5a7f, 0x490a, { 0x92, 0x77, 0xba, 0x66, 0xe0, 0xd2, 0x2c, 0x8b } }
michael@0 33
michael@0 34 #define GONK_GPS_GEOLOCATION_PROVIDER_CONTRACTID \
michael@0 35 "@mozilla.org/gonk-gps-geolocation-provider;1"
michael@0 36
michael@0 37 class GonkGPSGeolocationProvider : public nsIGeolocationProvider
michael@0 38 , public nsIObserver
michael@0 39 , public nsISettingsServiceCallback
michael@0 40 {
michael@0 41 public:
michael@0 42 NS_DECL_THREADSAFE_ISUPPORTS
michael@0 43 NS_DECL_NSIGEOLOCATIONPROVIDER
michael@0 44 NS_DECL_NSIOBSERVER
michael@0 45 NS_DECL_NSISETTINGSSERVICECALLBACK
michael@0 46
michael@0 47 static already_AddRefed<GonkGPSGeolocationProvider> GetSingleton();
michael@0 48
michael@0 49 private:
michael@0 50
michael@0 51 /* Client should use GetSingleton() to get the provider instance. */
michael@0 52 GonkGPSGeolocationProvider();
michael@0 53 GonkGPSGeolocationProvider(const GonkGPSGeolocationProvider &);
michael@0 54 GonkGPSGeolocationProvider & operator = (const GonkGPSGeolocationProvider &);
michael@0 55 virtual ~GonkGPSGeolocationProvider();
michael@0 56
michael@0 57 static void LocationCallback(GpsLocation* location);
michael@0 58 static void StatusCallback(GpsStatus* status);
michael@0 59 static void SvStatusCallback(GpsSvStatus* sv_info);
michael@0 60 static void NmeaCallback(GpsUtcTime timestamp, const char* nmea, int length);
michael@0 61 static void SetCapabilitiesCallback(uint32_t capabilities);
michael@0 62 static void AcquireWakelockCallback();
michael@0 63 static void ReleaseWakelockCallback();
michael@0 64 static pthread_t CreateThreadCallback(const char* name, void (*start)(void*), void* arg);
michael@0 65 static void RequestUtcTimeCallback();
michael@0 66 #ifdef MOZ_B2G_RIL
michael@0 67 static void AGPSStatusCallback(AGpsStatus* status);
michael@0 68 static void AGPSRILSetIDCallback(uint32_t flags);
michael@0 69 static void AGPSRILRefLocCallback(uint32_t flags);
michael@0 70 #endif
michael@0 71
michael@0 72 static GpsCallbacks mCallbacks;
michael@0 73 #ifdef MOZ_B2G_RIL
michael@0 74 static AGpsCallbacks mAGPSCallbacks;
michael@0 75 static AGpsRilCallbacks mAGPSRILCallbacks;
michael@0 76 #endif
michael@0 77
michael@0 78 void Init();
michael@0 79 void StartGPS();
michael@0 80 void ShutdownGPS();
michael@0 81 void InjectLocation(double latitude, double longitude, float accuracy);
michael@0 82 void RequestSettingValue(char* aKey);
michael@0 83 #ifdef MOZ_B2G_RIL
michael@0 84 void SetupAGPS();
michael@0 85 int32_t GetDataConnectionState();
michael@0 86 void SetAGpsDataConn(nsAString& aApn);
michael@0 87 void RequestDataConnection();
michael@0 88 void ReleaseDataConnection();
michael@0 89 void RequestSetID(uint32_t flags);
michael@0 90 void SetReferenceLocation();
michael@0 91 #endif
michael@0 92
michael@0 93 const GpsInterface* GetGPSInterface();
michael@0 94
michael@0 95 static GonkGPSGeolocationProvider* sSingleton;
michael@0 96
michael@0 97 bool mStarted;
michael@0 98
michael@0 99 bool mSupportsScheduling;
michael@0 100 #ifdef MOZ_B2G_RIL
michael@0 101 bool mSupportsMSB;
michael@0 102 bool mSupportsMSA;
michael@0 103 #endif
michael@0 104 bool mSupportsSingleShot;
michael@0 105 bool mSupportsTimeInjection;
michael@0 106
michael@0 107 const GpsInterface* mGpsInterface;
michael@0 108 #ifdef MOZ_B2G_RIL
michael@0 109 const AGpsInterface* mAGpsInterface;
michael@0 110 const AGpsRilInterface* mAGpsRilInterface;
michael@0 111 nsCOMPtr<nsIRadioInterface> mRadioInterface;
michael@0 112 #endif
michael@0 113 nsCOMPtr<nsIGeolocationUpdate> mLocationCallback;
michael@0 114 PRTime mLastGPSDerivedLocationTime;
michael@0 115 nsCOMPtr<nsIThread> mInitThread;
michael@0 116 nsCOMPtr<nsIGeolocationProvider> mNetworkLocationProvider;
michael@0 117
michael@0 118 class NetworkLocationUpdate : public nsIGeolocationUpdate
michael@0 119 {
michael@0 120 public:
michael@0 121 NS_DECL_ISUPPORTS
michael@0 122 NS_DECL_NSIGEOLOCATIONUPDATE
michael@0 123
michael@0 124 NetworkLocationUpdate() {}
michael@0 125
michael@0 126 private:
michael@0 127 virtual ~NetworkLocationUpdate() {}
michael@0 128 };
michael@0 129 };
michael@0 130
michael@0 131 #endif /* GonkGPSGeolocationProvider_h */

mercurial