• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2021 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 _ANDROID_SERVER_GNSS_GNSSBATCHING_H
18 #define _ANDROID_SERVER_GNSS_GNSSBATCHING_H
19 
20 #pragma once
21 
22 #ifndef LOG_TAG
23 #error LOG_TAG must be defined before including this file.
24 #endif
25 
26 #include <android/hardware/gnss/1.0/IGnssBatching.h>
27 #include <android/hardware/gnss/2.0/IGnssBatching.h>
28 #include <android/hardware/gnss/BnGnssBatching.h>
29 #include <log/log.h>
30 
31 #include "GnssBatchingCallback.h"
32 #include "jni.h"
33 
34 namespace android::gnss {
35 
36 class GnssBatchingInterface {
37 public:
~GnssBatchingInterface()38     virtual ~GnssBatchingInterface() {}
39     virtual jboolean init(const std::unique_ptr<GnssBatchingCallback>& callback) = 0;
40     virtual jint getBatchSize() = 0;
41     virtual jboolean start(long periodNanos, float minUpdateDistanceMeters,
42                            bool wakeupOnFifoFull) = 0;
43     virtual jboolean stop() = 0;
44     virtual jboolean flush() = 0;
45     virtual jboolean cleanup() = 0;
46 };
47 
48 class GnssBatching : public GnssBatchingInterface {
49 public:
50     GnssBatching(const sp<android::hardware::gnss::IGnssBatching>& iGnssBatching);
51     jboolean init(const std::unique_ptr<GnssBatchingCallback>& callback) override;
52     jint getBatchSize() override;
53     jboolean start(long periodNanos, float minUpdateDistanceMeters, bool wakeupOnFifoFull) override;
54     jboolean stop() override;
55     jboolean flush() override;
56     jboolean cleanup() override;
57 
58 private:
59     const sp<android::hardware::gnss::IGnssBatching> mIGnssBatching;
60 };
61 
62 class GnssBatching_V1_0 : public GnssBatchingInterface {
63 public:
64     GnssBatching_V1_0(const sp<android::hardware::gnss::V1_0::IGnssBatching>& iGnssBatching);
65     jboolean init(const std::unique_ptr<GnssBatchingCallback>& callback) override;
66     jint getBatchSize() override;
67     jboolean start(long periodNanos, float minUpdateDistanceMeters, bool wakeupOnFifoFull) override;
68     jboolean stop() override;
69     jboolean flush() override;
70     jboolean cleanup() override;
71 
72 private:
73     const sp<android::hardware::gnss::V1_0::IGnssBatching> mIGnssBatching_V1_0;
74 };
75 
76 class GnssBatching_V2_0 : public GnssBatching_V1_0 {
77 public:
78     GnssBatching_V2_0(const sp<android::hardware::gnss::V2_0::IGnssBatching>& iGnssBatching);
79     jboolean init(const std::unique_ptr<GnssBatchingCallback>& callback) override;
80 
81 private:
82     const sp<android::hardware::gnss::V2_0::IGnssBatching> mIGnssBatching_V2_0;
83 };
84 
85 } // namespace android::gnss
86 
87 #endif // _ANDROID_SERVER_GNSS_GNSSBATCHING_H
88