• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2022 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 REQUEST_H
17 #define REQUEST_H
18 
19 #include <list>
20 #include <string>
21 
22 #include "i_locator_callback.h"
23 #include "request_config.h"
24 
25 namespace OHOS {
26 namespace Location {
27 class Request {
28 public:
29     Request();
30     ~Request();
31     pid_t GetUid();
32     pid_t GetPid();
33     std::string GetPackageName();
34     sptr<RequestConfig> GetRequestConfig();
35     sptr<ILocatorCallback> GetLocatorCallBack();
36     std::string GetUuid();
37     void SetUid(pid_t uid);
38     void SetPid(pid_t pid);
39     void SetPackageName(std::string packageName);
40     void SetRequestConfig(RequestConfig& requestConfig);
41     void SetLocatorCallBack(const sptr<ILocatorCallback>& callback);
42     void SetUuid(std::string uuid);
43     std::string ToString() const;
44     void GetProxyName(std::shared_ptr<std::list<std::string>> proxys);
45     bool GetIsRequesting();
46     void SetRequesting(bool state);
47     sptr<Location> GetLastLocation();
48     void SetLastLocation(const std::unique_ptr<Location>& location);
49     uint32_t GetTokenId();
50     uint32_t GetFirstTokenId();
51     uint64_t GetTokenIdEx();
52     void SetTokenId(uint32_t tokenId);
53     void SetFirstTokenId(uint32_t firstTokenId);
54     void SetTokenIdEx(uint64_t tokenIdEx);
55     bool GetLocationPermState();
56     bool GetBackgroundPermState();
57     bool GetApproximatelyPermState();
58     void SetLocationPermState(bool state);
59     void SetBackgroundPermState(bool state);
60     void SetApproximatelyPermState(bool state);
61 private:
62     void GetProxyNameByPriority(std::shared_ptr<std::list<std::string>> proxys);
63 
64     pid_t uid_;
65     pid_t pid_;
66     uint32_t tokenId_;
67     uint64_t tokenIdEx_;
68     uint32_t firstTokenId_;
69     sptr<Location> lastLocation_;
70     std::string packageName_;
71     std::string uuid_;
72     sptr<RequestConfig> requestConfig_;
73     sptr<ILocatorCallback> callBack_;
74     bool isRequesting_;
75     bool isUsingLocationPerm_;
76     bool isUsingBackgroundPerm_;
77     bool isUsingApproximatelyPerm_;
78 };
79 } // namespace Location
80 } // namespace OHOS
81 #endif // REQUEST_H
82