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_VISIBILITYCONTROL_H 18 #define _ANDROID_SERVER_GNSS_VISIBILITYCONTROL_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/visibility_control/BnGnssVisibilityControl.h> 27 #include <log/log.h> 28 29 #include "GnssVisibilityControlCallback.h" 30 #include "jni.h" 31 32 namespace android::gnss { 33 34 class GnssVisibilityControlInterface { 35 public: ~GnssVisibilityControlInterface()36 virtual ~GnssVisibilityControlInterface() {} 37 virtual jboolean enableNfwLocationAccess(JNIEnv* env, jobjectArray proxyApps) = 0; 38 virtual jboolean setCallback( 39 const std::unique_ptr<GnssVisibilityControlCallback>& callback) = 0; 40 }; 41 42 class GnssVisibilityControlAidl : public GnssVisibilityControlInterface { 43 public: 44 GnssVisibilityControlAidl( 45 const sp<android::hardware::gnss::visibility_control::IGnssVisibilityControl>& 46 iGnssVisibilityControl); 47 jboolean enableNfwLocationAccess(JNIEnv* env, jobjectArray proxyApps) override; 48 jboolean setCallback(const std::unique_ptr<GnssVisibilityControlCallback>& callback) override; 49 50 private: 51 const sp<android::hardware::gnss::visibility_control::IGnssVisibilityControl> 52 mIGnssVisibilityControlAidl; 53 }; 54 55 class GnssVisibilityControlHidl : public GnssVisibilityControlInterface { 56 public: 57 GnssVisibilityControlHidl( 58 const sp<android::hardware::gnss::visibility_control::V1_0::IGnssVisibilityControl>& 59 iGnssVisibilityControl); 60 jboolean enableNfwLocationAccess(JNIEnv* env, jobjectArray proxyApps) override; 61 jboolean setCallback(const std::unique_ptr<GnssVisibilityControlCallback>& callback) override; 62 63 private: 64 const sp<android::hardware::gnss::visibility_control::V1_0::IGnssVisibilityControl> 65 mIGnssVisibilityControlHidl; 66 }; 67 68 } // namespace android::gnss 69 70 #endif // _ANDROID_SERVER_GNSS_VISIBILITYCONTROL_H 71