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
28namespace OHOS {
29namespace Location {
30typedef struct {
31    double latitude;
32    double longitude;
33    double radius;
34    double expiration;
35    CoordinateSystemType coordinateSystemType;
36} GeoFence;
37
38class GeofenceRequest : public Parcelable {
39public:
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    void ReadFromParcel(Parcel& parcel);
88    bool Marshalling(Parcel& parcel) const override;
89    static std::shared_ptr<GeofenceRequest> Unmarshalling(Parcel& parcel);
90private:
91    std::vector<GeofenceTransitionEvent> transitionStatusList_;
92#ifdef NOTIFICATION_ENABLE
93    std::vector<OHOS::Notification::NotificationRequest> notificationRequestList_;
94#endif
95    sptr<IRemoteObject> callback_ = nullptr;
96    GeoFence geofence_{0.0, 0.0, 0.0, WGS84};
97    int scenario_;
98    int fenceId_;
99    int32_t uid_;
100    AbilityRuntime::WantAgent::WantAgent wantAgent_;
101    std::string bundleName_;
102    mutable std::mutex geofenceRequestMutex_;
103};
104} // namespace Location
105} // namespace OHOS
106#endif // GNSS_GEOFENCE_REQUEST_H
107