1 /* 2 * Copyright (C) 2024 Huawei Device Co., Ltd. 3 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * you may not use this file except in compliance with the License. 5 * You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software 10 * distributed under the License is distributed on an "AS IS" BASIS, 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 * See the License for the specific language governing permissions and 13 * limitations under the License. 14 */ 15 16 #ifndef GNSS_GEOFENCE_REQUEST_H 17 #define GNSS_GEOFENCE_REQUEST_H 18 19 #include <mutex> 20 #include <vector> 21 #include "geofence_definition.h" 22 #include <parcel.h> 23 #include "iremote_object.h" 24 25 namespace OHOS { 26 namespace Notification { 27 class NotificationRequest; 28 } 29 30 namespace Location { 31 typedef struct { 32 double latitude; 33 double longitude; 34 double radius; 35 double expiration; 36 CoordinateSystemType coordinateSystemType; 37 } GeoFence; 38 39 class GeofenceRequest : public Parcelable { 40 public: 41 GeofenceRequest(); 42 43 GeofenceRequest(GeofenceRequest& geofenceRequest); 44 45 ~GeofenceRequest(); 46 47 GeoFence GetGeofence(); 48 void SetGeofence(GeoFence geofence); 49 50 int GetScenario(); 51 52 void SetScenario(int scenario); 53 54 void SetWantAgentParcelData(const Parcel& data); 55 56 bool GetWantAgentParcelData(Parcel& data); 57 58 std::vector<GeofenceTransitionEvent> GetGeofenceTransitionEventList(); 59 60 void SetGeofenceTransitionEvent(GeofenceTransitionEvent status); 61 62 void SetGeofenceTransitionEventList(std::vector<GeofenceTransitionEvent> statusList); 63 64 std::vector<std::shared_ptr<OHOS::Notification::NotificationRequest>> GetNotificationRequestList(); 65 66 void SetNotificationRequest(std::shared_ptr<OHOS::Notification::NotificationRequest> request); 67 68 void SetNotificationRequestList(std::vector<std::shared_ptr<OHOS::Notification::NotificationRequest>> requestList); 69 70 void SetGeofenceTransitionCallback(const sptr<IRemoteObject>& callback); 71 72 sptr<IRemoteObject> GetGeofenceTransitionCallback(); 73 74 int GetFenceId(); 75 76 void SetFenceId(int fenceId); 77 78 const std::string& GetBundleName(); 79 80 void SetBundleName(const std::string& bundleName); 81 82 int32_t GetUid(); 83 84 void SetUid(int32_t uid); 85 86 bool GetAppAliveStatus(); 87 88 void SetAppAliveStatus(bool appAliveStatus); 89 90 int64_t GetRequestExpirationTime(); 91 92 void SetRequestExpirationTime(int64_t requestExpirationTime); 93 94 void ReadFromParcel(Parcel& parcel); 95 bool Marshalling(Parcel& parcel) const override; 96 static std::shared_ptr<GeofenceRequest> UnmarshallingShared(Parcel& parcel); 97 static GeofenceRequest* Unmarshalling(Parcel& parcel); 98 private: 99 std::vector<GeofenceTransitionEvent> transitionStatusList_; 100 std::vector<std::shared_ptr<OHOS::Notification::NotificationRequest>> notificationRequestList_; 101 sptr<IRemoteObject> callback_ = nullptr; 102 GeoFence geofence_{0.0, 0.0, 0.0, WGS84}; 103 int scenario_; 104 int fenceId_; 105 int32_t uid_; 106 std::vector<char> wantAgentBuffer_; 107 std::string bundleName_; 108 bool appAliveStatus_; 109 int64_t requestExpirationTime_ = 0; 110 mutable std::mutex geofenceRequestMutex_; 111 }; 112 } // namespace Location 113 } // namespace OHOS 114 #endif // GNSS_GEOFENCE_REQUEST_H 115