• 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 LOCATOR_PROXY_H
17 #define LOCATOR_PROXY_H
18 
19 #include <vector>
20 #include <list>
21 
22 #include "iremote_broker.h"
23 #include "iremote_object.h"
24 #include "iremote_proxy.h"
25 
26 #include "constant_definition.h"
27 #include "country_code.h"
28 #include "geo_coding_mock_info.h"
29 #include "i_cached_locations_callback.h"
30 #include "i_locator.h"
31 #include "i_locator_callback.h"
32 #include "location.h"
33 #include "request_config.h"
34 
35 namespace OHOS {
36 namespace Location {
37 class LocatorProxy : public IRemoteProxy<ILocator> {
38 public:
39     explicit LocatorProxy(const sptr<IRemoteObject> &impl);
40     ~LocatorProxy() = default;
41     void UpdateSaAbility();
42     int GetSwitchState();
43     void EnableAbility(bool isEnabled);
44     void RegisterSwitchCallback(const sptr<IRemoteObject> &callback, pid_t uid);
45     void UnregisterSwitchCallback(const sptr<IRemoteObject> &callback);
46     void RegisterGnssStatusCallback(const sptr<IRemoteObject> &callback, pid_t uid);
47     void UnregisterGnssStatusCallback(const sptr<IRemoteObject> &callback);
48     void RegisterNmeaMessageCallback(const sptr<IRemoteObject> &callback, pid_t uid);
49     void UnregisterNmeaMessageCallback(const sptr<IRemoteObject> &callback);
50     void RegisterCountryCodeCallback(const sptr<IRemoteObject> &callback, pid_t uid);
51     void UnregisterCountryCodeCallback(const sptr<IRemoteObject> &callback);
52     int StartLocating(std::unique_ptr<RequestConfig>& requestConfig,
53         sptr<ILocatorCallback>& callback, std::string bundleName, pid_t pid, pid_t uid);
54     int StopLocating(sptr<ILocatorCallback>& callback);
55     int GetCacheLocation(MessageParcel &replay);
56     int IsGeoConvertAvailable(MessageParcel &replay);
57     int GetAddressByCoordinate(MessageParcel &data, MessageParcel &replay);
58     int GetAddressByLocationName(MessageParcel &data, MessageParcel &replay);
59     bool IsLocationPrivacyConfirmed(const int type);
60     int SetLocationPrivacyConfirmStatus(const int type, bool isConfirmed);
61     int RegisterCachedLocationCallback(std::unique_ptr<CachedGnssLocationsRequest>& request,
62         sptr<ICachedLocationsCallback>& callback, std::string bundleName);
63     int UnregisterCachedLocationCallback(sptr<ICachedLocationsCallback>& callback);
64     int GetCachedGnssLocationsSize();
65     int FlushCachedGnssLocations();
66     void SendCommand(std::unique_ptr<LocationCommand>& commands);
67     void AddFence(std::unique_ptr<GeofenceRequest>& request);
68     void RemoveFence(std::unique_ptr<GeofenceRequest>& request);
69     std::shared_ptr<CountryCode> GetIsoCountryCode();
70     bool EnableLocationMock();
71     bool DisableLocationMock();
72     bool SetMockedLocations(
73         const int timeInterval, const std::vector<std::shared_ptr<Location>> &location);
74     bool EnableReverseGeocodingMock();
75     bool DisableReverseGeocodingMock();
76     bool SetReverseGeocodingMockInfo(std::vector<std::shared_ptr<GeocodingMockInfo>>& mockInfo);
77     int SendMsgWithDataReply(const int msgId, MessageParcel& data, MessageParcel& reply);
78     int SendMsgWithReply(const int msgId, MessageParcel& reply);
79     int SendSimpleMsg(const int msgId);
80     int SendRegisterMsgToRemote(const int msgId, const sptr<IRemoteObject>& callback, pid_t uid);
81     bool ProxyUidForFreeze(int32_t uid, bool isProxy);
82     bool ResetAllProxy();
83 
84     LocationErrCode UpdateSaAbilityV9();
85     LocationErrCode GetSwitchStateV9(bool &isEnabled);
86     LocationErrCode EnableAbilityV9(bool isEnabled);
87     LocationErrCode RegisterSwitchCallbackV9(const sptr<IRemoteObject> &callback);
88     LocationErrCode UnregisterSwitchCallbackV9(const sptr<IRemoteObject> &callback);
89     LocationErrCode RegisterGnssStatusCallbackV9(const sptr<IRemoteObject> &callback);
90     LocationErrCode UnregisterGnssStatusCallbackV9(const sptr<IRemoteObject> &callback);
91     LocationErrCode RegisterNmeaMessageCallbackV9(const sptr<IRemoteObject> &callback);
92     LocationErrCode UnregisterNmeaMessageCallbackV9(const sptr<IRemoteObject> &callback);
93     LocationErrCode RegisterCountryCodeCallbackV9(const sptr<IRemoteObject> &callback);
94     LocationErrCode UnregisterCountryCodeCallbackV9(const sptr<IRemoteObject> &callback);
95     LocationErrCode StartLocatingV9(std::unique_ptr<RequestConfig>& requestConfig,
96         sptr<ILocatorCallback>& callback);
97     LocationErrCode StopLocatingV9(sptr<ILocatorCallback>& callback);
98     LocationErrCode GetCacheLocationV9(std::unique_ptr<Location> &loc);
99     LocationErrCode IsGeoConvertAvailableV9(bool &isAvailable);
100     LocationErrCode GetAddressByCoordinateV9(MessageParcel &data,
101         std::list<std::shared_ptr<GeoAddress>>& replyList);
102     LocationErrCode GetAddressByLocationNameV9(MessageParcel &data,
103         std::list<std::shared_ptr<GeoAddress>>& replyList);
104     LocationErrCode IsLocationPrivacyConfirmedV9(const int type, bool &isConfirmed);
105     LocationErrCode SetLocationPrivacyConfirmStatusV9(const int type, bool isConfirmed);
106     LocationErrCode RegisterCachedLocationCallbackV9(std::unique_ptr<CachedGnssLocationsRequest>& request,
107         sptr<ICachedLocationsCallback>& callback, std::string bundleName);
108     LocationErrCode UnregisterCachedLocationCallbackV9(sptr<ICachedLocationsCallback>& callback);
109     LocationErrCode GetCachedGnssLocationsSizeV9(int &size);
110     LocationErrCode FlushCachedGnssLocationsV9();
111     LocationErrCode SendCommandV9(std::unique_ptr<LocationCommand>& commands);
112     LocationErrCode AddFenceV9(std::unique_ptr<GeofenceRequest>& request);
113     LocationErrCode RemoveFenceV9(std::unique_ptr<GeofenceRequest>& request);
114     LocationErrCode GetIsoCountryCodeV9(std::shared_ptr<CountryCode>& countryCode);
115     LocationErrCode EnableLocationMockV9();
116     LocationErrCode DisableLocationMockV9();
117     LocationErrCode SetMockedLocationsV9(
118         const int timeInterval, const std::vector<std::shared_ptr<Location>> &location);
119     LocationErrCode EnableReverseGeocodingMockV9();
120     LocationErrCode DisableReverseGeocodingMockV9();
121     LocationErrCode SetReverseGeocodingMockInfoV9(std::vector<std::shared_ptr<GeocodingMockInfo>>& mockInfo);
122     LocationErrCode SendMsgWithDataReplyV9(const int msgId, MessageParcel& data, MessageParcel& reply);
123     LocationErrCode SendMsgWithReplyV9(const int msgId, MessageParcel& reply);
124     LocationErrCode SendSimpleMsgV9(const int msgId);
125     LocationErrCode SendRegisterMsgToRemoteV9(const int msgId, const sptr<IRemoteObject>& callback);
126     LocationErrCode ProxyUidForFreezeV9(int32_t uid, bool isProxy);
127     LocationErrCode ResetAllProxyV9();
128 private:
129     static inline BrokerDelegator<LocatorProxy> delegator_;
130 };
131 } // namespace Location
132 } // namespace OHOS
133 #endif // LOCATOR_PROXY_H
134