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_GNSSPSDSCALLBACK_H 18 #define _ANDROID_SERVER_GNSS_GNSSPSDSCALLBACK_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/IGnssXtraCallback.h> 27 #include <android/hardware/gnss/BnGnssPsdsCallback.h> 28 #include <log/log.h> 29 30 #include "jni.h" 31 32 namespace android::gnss { 33 34 namespace { 35 extern jmethodID method_psdsDownloadRequest; 36 } // anonymous namespace 37 38 void GnssPsds_class_init_once(JNIEnv* env, jclass clazz); 39 40 class GnssPsdsCallbackAidl : public hardware::gnss::BnGnssPsdsCallback { 41 public: GnssPsdsCallbackAidl()42 GnssPsdsCallbackAidl() {} 43 binder::Status downloadRequestCb(hardware::gnss::PsdsType psdsType) override; 44 }; 45 46 class GnssPsdsCallbackHidl : public hardware::gnss::V1_0::IGnssXtraCallback { 47 public: GnssPsdsCallbackHidl()48 GnssPsdsCallbackHidl() {} 49 hardware::Return<void> downloadRequestCb() override; 50 }; 51 52 class GnssPsdsCallback { 53 public: GnssPsdsCallback()54 GnssPsdsCallback() {} getAidl()55 sp<GnssPsdsCallbackAidl> getAidl() { 56 if (callbackAidl == nullptr) { 57 callbackAidl = sp<GnssPsdsCallbackAidl>::make(); 58 } 59 return callbackAidl; 60 } 61 getHidl()62 sp<GnssPsdsCallbackHidl> getHidl() { 63 if (callbackHidl == nullptr) { 64 callbackHidl = sp<GnssPsdsCallbackHidl>::make(); 65 } 66 return callbackHidl; 67 } 68 69 private: 70 sp<GnssPsdsCallbackAidl> callbackAidl; 71 sp<GnssPsdsCallbackHidl> callbackHidl; 72 }; 73 74 } // namespace android::gnss 75 76 #endif // _ANDROID_SERVER_GNSS_GNSSPSDSCALLBACK_H