From ea8aefcf657335910a97e158e1c4752db9b0a880 Mon Sep 17 00:00:00 2001 From: Michael Bestas Date: Sat, 18 Apr 2020 17:12:06 +0300 Subject: Squashed 'gps/' content from commit 8582827c8 git-subtree-dir: gps git-subtree-split: 8582827c8f8cb19c2eff71f0737e17f3068ba41a --- geofence/GeofenceAdapter.h | 136 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 136 insertions(+) create mode 100644 geofence/GeofenceAdapter.h (limited to 'geofence/GeofenceAdapter.h') diff --git a/geofence/GeofenceAdapter.h b/geofence/GeofenceAdapter.h new file mode 100644 index 0000000..38f4823 --- /dev/null +++ b/geofence/GeofenceAdapter.h @@ -0,0 +1,136 @@ +/* Copyright (c) 2013-2019, The Linux Foundation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following + * disclaimer in the documentation and/or other materials provided + * with the distribution. + * * Neither the name of The Linux Foundation, nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR + * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, + * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE + * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN + * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ +#ifndef GEOFENCE_ADAPTER_H +#define GEOFENCE_ADAPTER_H + +#include +#include +#include +#include + +using namespace loc_core; + +#define COPY_IF_NOT_NULL(dest, src, len) do { \ + if (NULL!=dest && NULL!=src) { \ + for (size_t i=0; i GeofencesMap; //map of hwId to GeofenceObject +typedef std::map GeofenceIdMap; //map of GeofenceKey to hwId + +class GeofenceAdapter : public LocAdapterBase { + + /* ==== GEOFENCES ====================================================================== */ + GeofencesMap mGeofences; //map hwId to GeofenceObject + GeofenceIdMap mGeofenceIds; //map of GeofenceKey to hwId + +protected: + + /* ==== CLIENT ========================================================================= */ + virtual void updateClientsEventMask(); + virtual void stopClientSessions(LocationAPI* client); + +public: + + GeofenceAdapter(); + virtual ~GeofenceAdapter() {} + + /* ==== SSR ============================================================================ */ + /* ======== EVENTS ====(Called from QMI Thread)========================================= */ + virtual void handleEngineUpEvent(); + /* ======== UTILITIES ================================================================== */ + void restartGeofences(); + + /* ==== GEOFENCES ====================================================================== */ + /* ======== COMMANDS ====(Called from Client Thread)==================================== */ + uint32_t* addGeofencesCommand(LocationAPI* client, size_t count, + GeofenceOption* options, GeofenceInfo* info); + void removeGeofencesCommand(LocationAPI* client, size_t count, uint32_t* ids); + void pauseGeofencesCommand(LocationAPI* client, size_t count, uint32_t* ids); + void resumeGeofencesCommand(LocationAPI* client, size_t count, uint32_t* ids); + void modifyGeofencesCommand(LocationAPI* client, size_t count, uint32_t* ids, + GeofenceOption* options); + /* ======== RESPONSES ================================================================== */ + void reportResponse(LocationAPI* client, size_t count, LocationError* errs, uint32_t* ids); + /* ======== UTILITIES ================================================================== */ + void saveGeofenceItem(LocationAPI* client, + uint32_t clientId, + uint32_t hwId, + const GeofenceOption& options, + const GeofenceInfo& info); + void removeGeofenceItem(uint32_t hwId); + void pauseGeofenceItem(uint32_t hwId); + void resumeGeofenceItem(uint32_t hwId); + void modifyGeofenceItem(uint32_t hwId, const GeofenceOption& options); + LocationError getHwIdFromClient(LocationAPI* client, uint32_t clientId, uint32_t& hwId); + LocationError getGeofenceKeyFromHwId(uint32_t hwId, GeofenceKey& key); + void dump(); + + /* ==== REPORTS ======================================================================== */ + /* ======== EVENTS ====(Called from QMI Thread)========================================= */ + void geofenceBreachEvent(size_t count, uint32_t* hwIds, Location& location, + GeofenceBreachType breachType, uint64_t timestamp); + void geofenceStatusEvent(GeofenceStatusAvailable available); + /* ======== UTILITIES ================================================================== */ + void geofenceBreach(size_t count, uint32_t* hwIds, const Location& location, + GeofenceBreachType breachType, uint64_t timestamp); + void geofenceStatus(GeofenceStatusAvailable available); +}; + +#endif /* GEOFENCE_ADAPTER_H */ -- cgit v1.2.3