1 /* 2 * Copyright (C) 2022 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_AGNSSRIL_H 18 #define _ANDROID_SERVER_GNSS_AGNSSRIL_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/IAGnssRil.h> 27 #include <android/hardware/gnss/2.0/IAGnssRil.h> 28 #include <android/hardware/gnss/BnAGnssRil.h> 29 #include <log/log.h> 30 31 #include "AGnssRilCallback.h" 32 #include "jni.h" 33 34 namespace android::gnss { 35 36 class AGnssRilInterface { 37 public: ~AGnssRilInterface()38 virtual ~AGnssRilInterface() {} 39 virtual jboolean setCallback(const std::unique_ptr<AGnssRilCallback>& callback) = 0; 40 virtual jboolean setSetId(jint type, const jstring& setid_string) = 0; 41 virtual jboolean setRefLocation(jint type, jint mcc, jint mnc, jint lac, jlong cid, jint tac, 42 jint pcid, jint arfcn) = 0; 43 virtual jboolean updateNetworkState(jboolean connected, jint type, jboolean roaming, 44 jboolean available, const jstring& apn, jlong networkHandle, 45 jshort capabilities) = 0; 46 virtual jboolean injectNiSuplMessageData(const jbyteArray& msgData, jint length, 47 jint slotIndex) = 0; 48 }; 49 50 class AGnssRil : public AGnssRilInterface { 51 public: 52 AGnssRil(const sp<android::hardware::gnss::IAGnssRil>& iAGnssRil); 53 jboolean setCallback(const std::unique_ptr<AGnssRilCallback>& callback) override; 54 jboolean setSetId(jint type, const jstring& setid_string) override; 55 jboolean setRefLocation(jint type, jint mcc, jint mnc, jint lac, jlong cid, jint tac, jint pcid, 56 jint arfcn) override; 57 jboolean updateNetworkState(jboolean connected, jint type, jboolean roaming, jboolean available, 58 const jstring& apn, jlong networkHandle, 59 jshort capabilities) override; 60 jboolean injectNiSuplMessageData(const jbyteArray& msgData, jint length, 61 jint slotIndex) override; 62 63 private: 64 const sp<android::hardware::gnss::IAGnssRil> mIAGnssRil; 65 }; 66 67 class AGnssRil_V1_0 : public AGnssRilInterface { 68 public: 69 AGnssRil_V1_0(const sp<android::hardware::gnss::V1_0::IAGnssRil>& iAGnssRil); 70 jboolean setCallback(const std::unique_ptr<AGnssRilCallback>& callback) override; 71 jboolean setSetId(jint type, const jstring& setid_string) override; 72 jboolean setRefLocation(jint type, jint mcc, jint mnc, jint lac, jlong cid, jint, jint, 73 jint) override; 74 jboolean updateNetworkState(jboolean connected, jint type, jboolean roaming, jboolean available, 75 const jstring& apn, jlong networkHandle, 76 jshort capabilities) override; 77 jboolean injectNiSuplMessageData(const jbyteArray&, jint, jint) override; 78 79 private: 80 const sp<android::hardware::gnss::V1_0::IAGnssRil> mAGnssRil_V1_0; 81 }; 82 83 class AGnssRil_V2_0 : public AGnssRil_V1_0 { 84 public: 85 AGnssRil_V2_0(const sp<android::hardware::gnss::V2_0::IAGnssRil>& iAGnssRil); 86 jboolean updateNetworkState(jboolean connected, jint type, jboolean roaming, jboolean available, 87 const jstring& apn, jlong networkHandle, 88 jshort capabilities) override; 89 90 private: 91 const sp<android::hardware::gnss::V2_0::IAGnssRil> mAGnssRil_V2_0; 92 }; 93 94 } // namespace android::gnss 95 96 #endif // _ANDROID_SERVER_GNSS_AGNSSRIL_H 97