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 #ifdef NOTIFICATION_ENABLE
23 #include "notification_request.h"
24 #endif
25 #include "want_agent_helper.h"
26 #include <parcel.h>
27 
28 namespace OHOS {
29 namespace Location {
30 typedef struct {
31     double latitude;
32     double longitude;
33     double radius;
34     double expiration;
35     CoordinateSystemType coordinateSystemType;
36 } GeoFence;
37 
38 class GeofenceRequest : public Parcelable {
39 public:
40     GeofenceRequest();
41 
42     GeofenceRequest(GeofenceRequest& geofenceRequest);
43 
44     ~GeofenceRequest();
45 
46     GeoFence GetGeofence();
47     void SetGeofence(GeoFence geofence);
48 
49     int GetScenario();
50 
51     void SetScenario(int scenario);
52 
53     void SetWantAgent(const AbilityRuntime::WantAgent::WantAgent wantAgent);
54 
55     AbilityRuntime::WantAgent::WantAgent GetWantAgent();
56 
57     std::vector<GeofenceTransitionEvent> GetGeofenceTransitionEventList();
58 
59     void SetGeofenceTransitionEvent(GeofenceTransitionEvent status);
60 
61     void SetGeofenceTransitionEventList(std::vector<GeofenceTransitionEvent> statusList);
62 
63 #ifdef NOTIFICATION_ENABLE
64     std::vector<OHOS::Notification::NotificationRequest> GetNotificationRequestList();
65 
66     void SetNotificationRequest(OHOS::Notification::NotificationRequest request);
67 
68     void SetNotificationRequestList(std::vector<OHOS::Notification::NotificationRequest> requestList);
69 #endif
70 
71     void SetGeofenceTransitionCallback(const sptr<IRemoteObject>& callback);
72 
73     sptr<IRemoteObject> GetGeofenceTransitionCallback();
74 
75     int GetFenceId();
76 
77     void SetFenceId(int fenceId);
78 
79     const std::string& GetBundleName();
80 
81     void SetBundleName(const std::string& bundleName);
82 
83     int32_t GetUid();
84 
85     void SetUid(int32_t uid);
86 
87     bool GetAppAliveStatus();
88 
89     void SetAppAliveStatus(bool appAliveStatus);
90 
91     int64_t GetRequestExpirationTimeStamp();
92 
93     void SetRequestExpirationTimeStamp(int64_t requestExpirationTimeStamp);
94 
95     void ReadFromParcel(Parcel& parcel);
96     bool Marshalling(Parcel& parcel) const override;
97     static std::shared_ptr<GeofenceRequest> Unmarshalling(Parcel& parcel);
98 private:
99     std::vector<GeofenceTransitionEvent> transitionStatusList_;
100 #ifdef NOTIFICATION_ENABLE
101     std::vector<OHOS::Notification::NotificationRequest> notificationRequestList_;
102 #endif
103     sptr<IRemoteObject> callback_ = nullptr;
104     GeoFence geofence_{0.0, 0.0, 0.0, WGS84};
105     int scenario_;
106     int fenceId_;
107     int32_t uid_;
108     AbilityRuntime::WantAgent::WantAgent wantAgent_;
109     std::string bundleName_;
110     bool appAliveStatus_;
111     int64_t requestExpirationTimeStamp_ = 0;
112     mutable std::mutex geofenceRequestMutex_;
113 };
114 } // namespace Location
115 } // namespace OHOS
116 #endif // GNSS_GEOFENCE_REQUEST_H
117