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 #define LOG_TAG "GnssGeofenceAidl"
18 
19 #include "GnssGeofence.h"
20 #include <aidl/android/hardware/gnss/BnGnssGeofence.h>
21 #include <log/log.h>
22 
23 namespace aidl::android::hardware::gnss {
24 
25 std::shared_ptr<IGnssGeofenceCallback> GnssGeofence::sCallback = nullptr;
26 
setCallback(const std::shared_ptr<IGnssGeofenceCallback> & callback)27 ndk::ScopedAStatus GnssGeofence::setCallback(
28         const std::shared_ptr<IGnssGeofenceCallback>& callback) {
29     ALOGD("setCallback");
30     std::unique_lock<std::mutex> lock(mMutex);
31     sCallback = callback;
32     return ndk::ScopedAStatus::ok();
33 }
34 
addGeofence(int geofenceId,double latitudeDegrees,double longitudeDegrees,double radiusMeters,int lastTransition,int monitorTransitions,int notificationResponsivenessMs,int unknownTimerMs)35 ndk::ScopedAStatus GnssGeofence::addGeofence(int geofenceId, double latitudeDegrees,
36                                              double longitudeDegrees, double radiusMeters,
37                                              int lastTransition, int monitorTransitions,
38                                              int notificationResponsivenessMs, int unknownTimerMs) {
39     ALOGD("addGeofence. geofenceId=%d, lat=%lf, lng=%lf, rad=%lf, lastTransition=%d, "
40           "monitorTransitions=%d, notificationResponsivenessMs=%d, unknownTimerMs=%d",
41           geofenceId, latitudeDegrees, longitudeDegrees, radiusMeters, lastTransition,
42           monitorTransitions, notificationResponsivenessMs, unknownTimerMs);
43     return ndk::ScopedAStatus::ok();
44 }
45 
pauseGeofence(int geofenceId)46 ndk::ScopedAStatus GnssGeofence::pauseGeofence(int geofenceId) {
47     ALOGD("pauseGeofence. id=%d", geofenceId);
48     return ndk::ScopedAStatus::ok();
49 }
50 
resumeGeofence(int geofenceId,int monitorTransitions)51 ndk::ScopedAStatus GnssGeofence::resumeGeofence(int geofenceId, int monitorTransitions) {
52     ALOGD("resumeGeofence. id=%d, monitorTransitions=%d", geofenceId, monitorTransitions);
53     return ndk::ScopedAStatus::ok();
54 }
55 
removeGeofence(int geofenceId)56 ndk::ScopedAStatus GnssGeofence::removeGeofence(int geofenceId) {
57     ALOGD("removeGeofence. id=%d", geofenceId);
58     return ndk::ScopedAStatus::ok();
59 }
60 
61 }  // namespace aidl::android::hardware::gnss
62