1 /* 2 * Copyright (C) 2020 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_GNSSMEASUREMENT_H 18 #define _ANDROID_SERVER_GNSS_GNSSMEASUREMENT_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/IGnssMeasurement.h> 27 #include <android/hardware/gnss/1.1/IGnssMeasurement.h> 28 #include <android/hardware/gnss/2.0/IGnssMeasurement.h> 29 #include <android/hardware/gnss/2.1/IGnssMeasurement.h> 30 #include <android/hardware/gnss/BnGnssMeasurementInterface.h> 31 #include <log/log.h> 32 #include "GnssMeasurementCallback.h" 33 #include "jni.h" 34 35 namespace android::gnss { 36 37 class GnssMeasurementInterface { 38 public: ~GnssMeasurementInterface()39 virtual ~GnssMeasurementInterface() {} 40 virtual jboolean setCallback( 41 const std::unique_ptr<GnssMeasurementCallback>& callback, 42 const android::hardware::gnss::IGnssMeasurementInterface::Options& options) = 0; 43 virtual jboolean close() = 0; 44 virtual int getInterfaceVersion() = 0; 45 }; 46 47 class GnssMeasurement : public GnssMeasurementInterface { 48 public: 49 GnssMeasurement(const sp<android::hardware::gnss::IGnssMeasurementInterface>& iGnssMeasurement); 50 jboolean setCallback( 51 const std::unique_ptr<GnssMeasurementCallback>& callback, 52 const android::hardware::gnss::IGnssMeasurementInterface::Options& options) override; 53 jboolean close() override; getInterfaceVersion()54 int getInterfaceVersion() override { 55 return mIGnssMeasurement->getInterfaceVersion(); 56 } 57 58 private: 59 const sp<android::hardware::gnss::IGnssMeasurementInterface> mIGnssMeasurement; 60 }; 61 62 class GnssMeasurement_V1_0 : public GnssMeasurementInterface { 63 public: 64 GnssMeasurement_V1_0( 65 const sp<android::hardware::gnss::V1_0::IGnssMeasurement>& iGnssMeasurement); 66 jboolean setCallback( 67 const std::unique_ptr<GnssMeasurementCallback>& callback, 68 const android::hardware::gnss::IGnssMeasurementInterface::Options& options) override; 69 jboolean close() override; getInterfaceVersion()70 int getInterfaceVersion() override { 71 return 0; 72 } 73 74 private: 75 const sp<android::hardware::gnss::V1_0::IGnssMeasurement> mIGnssMeasurement_V1_0; 76 }; 77 78 class GnssMeasurement_V1_1 : public GnssMeasurement_V1_0 { 79 public: 80 GnssMeasurement_V1_1( 81 const sp<android::hardware::gnss::V1_1::IGnssMeasurement>& iGnssMeasurement); 82 jboolean setCallback( 83 const std::unique_ptr<GnssMeasurementCallback>& callback, 84 const android::hardware::gnss::IGnssMeasurementInterface::Options& options) override; 85 86 private: 87 const sp<android::hardware::gnss::V1_1::IGnssMeasurement> mIGnssMeasurement_V1_1; 88 }; 89 90 class GnssMeasurement_V2_0 : public GnssMeasurement_V1_1 { 91 public: 92 GnssMeasurement_V2_0( 93 const sp<android::hardware::gnss::V2_0::IGnssMeasurement>& iGnssMeasurement); 94 jboolean setCallback( 95 const std::unique_ptr<GnssMeasurementCallback>& callback, 96 const android::hardware::gnss::IGnssMeasurementInterface::Options& options) override; 97 98 private: 99 const sp<android::hardware::gnss::V2_0::IGnssMeasurement> mIGnssMeasurement_V2_0; 100 }; 101 102 class GnssMeasurement_V2_1 : public GnssMeasurement_V2_0 { 103 public: 104 GnssMeasurement_V2_1( 105 const sp<android::hardware::gnss::V2_1::IGnssMeasurement>& iGnssMeasurement); 106 jboolean setCallback( 107 const std::unique_ptr<GnssMeasurementCallback>& callback, 108 const android::hardware::gnss::IGnssMeasurementInterface::Options& options) override; 109 110 private: 111 const sp<android::hardware::gnss::V2_1::IGnssMeasurement> mIGnssMeasurement_V2_1; 112 }; 113 114 } // namespace android::gnss 115 116 #endif // _ANDROID_SERVER_GNSS_GNSSMEASUREMENT_H