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_AGNSS_H 18 #define _ANDROID_SERVER_GNSS_AGNSS_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/BnAGnss.h> 27 #include <log/log.h> 28 29 #include "AGnssCallback.h" 30 #include "jni.h" 31 32 namespace android::gnss { 33 34 class AGnssInterface { 35 public: ~AGnssInterface()36 virtual ~AGnssInterface() {} 37 virtual jboolean setCallback(const std::unique_ptr<AGnssCallback>& callback) = 0; 38 virtual jboolean dataConnOpen(JNIEnv* env, jlong networkHandle, jstring apn, 39 jint apnIpType) = 0; 40 virtual jboolean dataConnClosed() = 0; 41 virtual jboolean dataConnFailed() = 0; 42 virtual jboolean setServer(JNIEnv* env, jint type, jstring hostname, jint port) = 0; 43 }; 44 45 class AGnss : public AGnssInterface { 46 public: 47 AGnss(const sp<android::hardware::gnss::IAGnss>& iAGnss); 48 jboolean setCallback(const std::unique_ptr<AGnssCallback>& callback) override; 49 jboolean dataConnOpen(JNIEnv* env, jlong networkHandle, jstring apn, jint apnIpType) override; 50 jboolean dataConnClosed() override; 51 jboolean dataConnFailed() override; 52 jboolean setServer(JNIEnv* env, jint type, jstring hostname, jint port) override; 53 54 private: 55 const sp<android::hardware::gnss::IAGnss> mIAGnss; 56 }; 57 58 class AGnss_V1_0 : public AGnssInterface { 59 public: 60 AGnss_V1_0(const sp<android::hardware::gnss::V1_0::IAGnss>& iAGnss); 61 jboolean setCallback(const std::unique_ptr<AGnssCallback>& callback) override; 62 jboolean dataConnOpen(JNIEnv* env, jlong, jstring apn, jint apnIpType) override; 63 jboolean dataConnClosed() override; 64 jboolean dataConnFailed() override; 65 jboolean setServer(JNIEnv* env, jint type, jstring hostname, jint port) override; 66 67 private: 68 const sp<android::hardware::gnss::V1_0::IAGnss> mIAGnss_V1_0; 69 }; 70 71 class AGnss_V2_0 : public AGnssInterface { 72 public: 73 AGnss_V2_0(const sp<android::hardware::gnss::V2_0::IAGnss>& iAGnss); 74 jboolean setCallback(const std::unique_ptr<AGnssCallback>& callback) override; 75 jboolean dataConnOpen(JNIEnv* env, jlong networkHandle, jstring apn, jint apnIpType) override; 76 jboolean dataConnClosed() override; 77 jboolean dataConnFailed() override; 78 jboolean setServer(JNIEnv* env, jint type, jstring hostname, jint port) override; 79 80 private: 81 const sp<android::hardware::gnss::V2_0::IAGnss> mIAGnss_V2_0; 82 }; 83 84 } // namespace android::gnss 85 86 #endif // _ANDROID_SERVER_GNSS_AGNSS_H 87