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_GNSSGEOFENCE_H 18 #define _ANDROID_SERVER_GNSS_GNSSGEOFENCE_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/IGnssGeofencing.h> 27 #include <android/hardware/gnss/BnGnssGeofence.h> 28 #include <log/log.h> 29 30 #include "GnssGeofenceCallback.h" 31 #include "jni.h" 32 33 namespace android::gnss { 34 35 class GnssGeofenceInterface { 36 public: ~GnssGeofenceInterface()37 virtual ~GnssGeofenceInterface() {} 38 virtual jboolean setCallback(const std::unique_ptr<GnssGeofenceCallback>& callback); 39 virtual jboolean addGeofence(int geofenceId, double latitudeDegrees, double longitudeDegrees, 40 double radiusMeters, int lastTransition, int monitorTransitions, 41 int notificationResponsivenessMs, int unknownTimerMs); 42 virtual jboolean pauseGeofence(int geofenceId); 43 virtual jboolean resumeGeofence(int geofenceId, int monitorTransitions); 44 virtual jboolean removeGeofence(int geofenceId); 45 }; 46 47 class GnssGeofenceAidl : public GnssGeofenceInterface { 48 public: 49 GnssGeofenceAidl(const sp<android::hardware::gnss::IGnssGeofence>& iGnssGeofence); 50 jboolean setCallback(const std::unique_ptr<GnssGeofenceCallback>& callback) override; 51 jboolean addGeofence(int geofenceId, double latitudeDegrees, double longitudeDegrees, 52 double radiusMeters, int lastTransition, int monitorTransitions, 53 int notificationResponsivenessMs, int unknownTimerMs) override; 54 jboolean pauseGeofence(int geofenceId) override; 55 jboolean resumeGeofence(int geofenceId, int monitorTransitions) override; 56 jboolean removeGeofence(int geofenceId) override; 57 58 private: 59 const sp<android::hardware::gnss::IGnssGeofence> mIGnssGeofenceAidl; 60 }; 61 62 class GnssGeofenceHidl : public GnssGeofenceInterface { 63 public: 64 GnssGeofenceHidl(const sp<android::hardware::gnss::V1_0::IGnssGeofencing>& iGnssGeofence); 65 jboolean setCallback(const std::unique_ptr<GnssGeofenceCallback>& callback) override; 66 jboolean addGeofence(int geofenceId, double latitudeDegrees, double longitudeDegrees, 67 double radiusMeters, int lastTransition, int monitorTransitions, 68 int notificationResponsivenessMs, int unknownTimerMs) override; 69 jboolean pauseGeofence(int geofenceId) override; 70 jboolean resumeGeofence(int geofenceId, int monitorTransitions) override; 71 jboolean removeGeofence(int geofenceId) override; 72 73 private: 74 const sp<android::hardware::gnss::V1_0::IGnssGeofencing> mIGnssGeofenceHidl; 75 }; 76 77 } // namespace android::gnss 78 79 #endif // _ANDROID_SERVER_GNSS_GNSSGEOFENCE_H 80