1 /*
2  * Copyright (C) 2017 The Android Open Source Project
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 #ifndef CHRE_PLATFORM_PLATFORM_GNSS_H_
18 #define CHRE_PLATFORM_PLATFORM_GNSS_H_
19 
20 #include "chre/target_platform/platform_gnss_base.h"
21 #include "chre/util/time.h"
22 
23 namespace chre {
24 
25 class PlatformGnss : public PlatformGnssBase {
26  public:
27   /**
28    * Performs platform-specific deinitialization of the PlatformGnss instance.
29    */
30   ~PlatformGnss();
31 
32   /**
33    * Initializes the platform-specific GNSS implementation. This is potentially
34    * called at a later stage of initialization than the constructor, so platform
35    * implementations are encouraged to put any blocking initialization here.
36    */
37   void init();
38 
39   /**
40    * Returns the set of GNSS capabilities that the platform has exposed. This
41    * may return CHRE_GNSS_CAPABILITIES_NONE if GNSS is not supported.
42    *
43    * @return the GNSS capabilities exposed by this platform.
44    */
45   uint32_t getCapabilities();
46 
47   /**
48    * Starts/stops/modifies the GNSS location session. This is an asynchronous
49    * request and the result is delivered through an async call into the
50    * GNSS manager.
51    *
52    * @param enable Whether to enable/disable the location session.
53    * @param minInterval The minimum reporting interval.
54    * @param minTimeToNextFix The minimum time to the next fix.
55    *
56    * @return true if the request was accepted.
57    */
58   bool controlLocationSession(bool enable, Milliseconds minInterval,
59                               Milliseconds minTimeToNextFix);
60 
61   /**
62    * Releases a location event that was previously provided to the GNSS manager.
63    *
64    * @param event the event to release.
65    */
66   void releaseLocationEvent(chreGnssLocationEvent *event);
67 
68   /**
69    * Starts/stops/modifies the GNSS measurement session. This is an asynchronous
70    * request and the result is delivered through an async call into the
71    * GNSS manager.
72    *
73    * @param enable Whether to enable/disable the measurement session.
74    * @param minInterval The minimum reporting interval.
75    *
76    * @return true if the request was accepted.
77    */
78   bool controlMeasurementSession(bool enable, Milliseconds minInterval);
79 
80   /**
81    * Releases a measurement data event that was previously provided to the GNSS
82    * manager.
83    *
84    * @param event the event to release.
85    */
86   void releaseMeasurementDataEvent(chreGnssDataEvent *event);
87 
88   /**
89    * @param enable true to enable the configuration.
90    *
91    * @return true if the request was received.
92    */
93   bool configurePassiveLocationListener(bool enable);
94 };
95 
96 }  // namespace chre
97 
98 #endif  // CHRE_PLATFORM_PLATFORM_GNSS_H_
99