blob: 94a73dea02e9d2e7417d87dfe27537ff0da8426b [file] [log] [blame]
Michael Bestas58e7cab2023-05-12 04:05:32 +03001/*
2 * Copyright (c) 2017-2018, The Linux Foundation. All rights reserved.
3 * Not a Contribution
4 */
5/*
6 * Copyright (C) 2016 The Android Open Source Project
7 *
8 * Licensed under the Apache License, Version 2.0 (the "License");
9 * you may not use this file except in compliance with the License.
10 * You may obtain a copy of the License at
11 *
12 * http://www.apache.org/licenses/LICENSE-2.0
13 *
14 * Unless required by applicable law or agreed to in writing, software
15 * distributed under the License is distributed on an "AS IS" BASIS,
16 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17 * See the License for the specific language governing permissions and
18 * limitations under the License.
19 */
20
21#ifndef ANDROID_HARDWARE_GNSS_V1_1_GNSSGEOFENCING_H
22#define ANDROID_HARDWARE_GNSS_V1_1_GNSSGEOFENCING_H
23
24#include <android/hardware/gnss/1.0/IGnssGeofencing.h>
25#include <hidl/Status.h>
26
27namespace android {
28namespace hardware {
29namespace gnss {
30namespace V1_1 {
31namespace implementation {
32
33using ::android::hardware::gnss::V1_0::IGnssGeofenceCallback;
34using ::android::hardware::gnss::V1_0::IGnssGeofencing;
35using ::android::hardware::Return;
36using ::android::hardware::Void;
37using ::android::hardware::hidl_vec;
38using ::android::hardware::hidl_string;
39using ::android::sp;
40
41class GeofenceAPIClient;
42struct GnssGeofencing : public IGnssGeofencing {
43 GnssGeofencing();
44 ~GnssGeofencing();
45
46 /*
47 * Methods from ::android::hardware::gnss::V1_0::IGnssGeofencing follow.
48 * These declarations were generated from IGnssGeofencing.hal.
49 */
50 Return<void> setCallback(const sp<IGnssGeofenceCallback>& callback) override;
51 Return<void> addGeofence(int32_t geofenceId,
52 double latitudeDegrees,
53 double longitudeDegrees,
54 double radiusMeters,
55 IGnssGeofenceCallback::GeofenceTransition lastTransition,
56 int32_t monitorTransitions,
57 uint32_t notificationResponsivenessMs,
58 uint32_t unknownTimerMs) override;
59
60 Return<void> pauseGeofence(int32_t geofenceId) override;
61 Return<void> resumeGeofence(int32_t geofenceId, int32_t monitorTransitions) override;
62 Return<void> removeGeofence(int32_t geofenceId) override;
63
64 private:
65 // This method is not part of the IGnss base class.
66 // It is called by GnssGeofencingDeathRecipient to remove all geofences added so far.
67 Return<void> removeAllGeofences();
68
69 private:
70 struct GnssGeofencingDeathRecipient : hidl_death_recipient {
71 GnssGeofencingDeathRecipient(sp<GnssGeofencing> gnssGeofencing) :
72 mGnssGeofencing(gnssGeofencing) {
73 }
74 ~GnssGeofencingDeathRecipient() = default;
75 virtual void serviceDied(uint64_t cookie, const wp<IBase>& who) override;
76 sp<GnssGeofencing> mGnssGeofencing;
77 };
78
79 private:
80 sp<GnssGeofencingDeathRecipient> mGnssGeofencingDeathRecipient = nullptr;
81 sp<IGnssGeofenceCallback> mGnssGeofencingCbIface = nullptr;
82 GeofenceAPIClient* mApi = nullptr;
83};
84
85} // namespace implementation
86} // namespace V1_1
87} // namespace gnss
88} // namespace hardware
89} // namespace android
90
91#endif // ANDROID_HARDWARE_GNSS_V1_1_GNSSGEOFENCING_H