• 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 #ifndef LOCATOR_H
16 #define LOCATOR_H
17 
18 #include <list>
19 #include <vector>
20 
21 #include "iremote_object.h"
22 
23 #include "constant_definition.h"
24 #include "country_code.h"
25 #include "geo_address.h"
26 #include "geo_coding_mock_info.h"
27 #include "i_cached_locations_callback.h"
28 #include "i_locator_callback.h"
29 #include "location.h"
30 #include "request_config.h"
31 
32 namespace OHOS {
33 namespace Location {
34 class Locator {
35 public:
36     static std::unique_ptr<Locator> GetInstance();
37     virtual ~Locator();
38     virtual bool IsLocationEnabled() = 0;
39     virtual void RequestEnableLocation() = 0;
40     virtual void EnableAbility(bool enable) = 0;
41     virtual void StartLocating(std::unique_ptr<RequestConfig>& requestConfig,
42         sptr<ILocatorCallback>& callback) = 0;
43     virtual void StopLocating(sptr<ILocatorCallback>& callback) = 0;
44     virtual std::unique_ptr<Location> GetCachedLocation() = 0;
45     virtual bool RegisterSwitchCallback(const sptr<IRemoteObject>& callback, pid_t uid) = 0;
46     virtual bool UnregisterSwitchCallback(const sptr<IRemoteObject>& callback) = 0;
47     virtual void ShowNotification() = 0;
48     virtual void RequestPermission() = 0;
49     virtual bool IsGeoServiceAvailable() = 0;
50     virtual void GetAddressByCoordinate(MessageParcel &data, std::list<std::shared_ptr<GeoAddress>>& replyList) = 0;
51     virtual void GetAddressByLocationName(MessageParcel &data, std::list<std::shared_ptr<GeoAddress>>& replyList) = 0;
52     virtual bool IsLocationPrivacyConfirmed(const int type) = 0;
53     virtual int SetLocationPrivacyConfirmStatus(const int type, bool isConfirmed) = 0;
54     virtual bool RegisterGnssStatusCallback(const sptr<IRemoteObject>& callback, pid_t uid) = 0;
55     virtual bool UnregisterGnssStatusCallback(const sptr<IRemoteObject>& callback) = 0;
56     virtual bool RegisterNmeaMessageCallback(const sptr<IRemoteObject>& callback, pid_t uid) = 0;
57     virtual bool UnregisterNmeaMessageCallback(const sptr<IRemoteObject>& callback) = 0;
58     virtual bool RegisterCountryCodeCallback(const sptr<IRemoteObject>& callback, pid_t uid) = 0;
59     virtual bool UnregisterCountryCodeCallback(const sptr<IRemoteObject>& callback) = 0;
60     virtual void RegisterCachedLocationCallback(std::unique_ptr<CachedGnssLocationsRequest>& request,
61         sptr<ICachedLocationsCallback>& callback) = 0;
62     virtual void UnregisterCachedLocationCallback(sptr<ICachedLocationsCallback>& callback) = 0;
63     virtual int GetCachedGnssLocationsSize() = 0;
64     virtual int FlushCachedGnssLocations() = 0;
65     virtual bool SendCommand(std::unique_ptr<LocationCommand>& commands) = 0;
66     virtual bool AddFence(std::unique_ptr<GeofenceRequest>& request) = 0;
67     virtual bool RemoveFence(std::unique_ptr<GeofenceRequest>& request) = 0;
68     virtual bool EnableReverseGeocodingMock() = 0;
69     virtual bool DisableReverseGeocodingMock() = 0;
70     virtual bool SetReverseGeocodingMockInfo(std::vector<std::shared_ptr<GeocodingMockInfo>>& mockInfo) = 0;
71     virtual std::shared_ptr<CountryCode> GetIsoCountryCode() = 0;
72     virtual bool EnableLocationMock() = 0;
73     virtual bool DisableLocationMock() = 0;
74     virtual bool SetMockedLocations(
75         const int timeInterval, const std::vector<std::shared_ptr<Location>> &location) = 0;
76     virtual bool ProxyUidForFreeze(int32_t uid, bool isProxy) = 0;
77     virtual bool ResetAllProxy() = 0;
78 
79     virtual LocationErrCode IsLocationEnabledV9(bool &isEnabled) = 0;
80     virtual LocationErrCode EnableAbilityV9(bool enable) = 0;
81     virtual LocationErrCode StartLocatingV9(std::unique_ptr<RequestConfig>& requestConfig,
82         sptr<ILocatorCallback>& callback) = 0;
83     virtual LocationErrCode StopLocatingV9(sptr<ILocatorCallback>& callback) = 0;
84     virtual LocationErrCode GetCachedLocationV9(std::unique_ptr<Location> &loc) = 0;
85     virtual LocationErrCode RegisterSwitchCallbackV9(const sptr<IRemoteObject>& callback) = 0;
86     virtual LocationErrCode UnregisterSwitchCallbackV9(const sptr<IRemoteObject>& callback) = 0;
87     virtual LocationErrCode IsGeoServiceAvailableV9(bool &isAvailable) = 0;
88     virtual LocationErrCode GetAddressByCoordinateV9(MessageParcel &data,
89         std::list<std::shared_ptr<GeoAddress>>& replyList) = 0;
90     virtual LocationErrCode GetAddressByLocationNameV9(MessageParcel &data,
91         std::list<std::shared_ptr<GeoAddress>>& replyList) = 0;
92     virtual LocationErrCode IsLocationPrivacyConfirmedV9(const int type, bool &isConfirmed) = 0;
93     virtual LocationErrCode SetLocationPrivacyConfirmStatusV9(const int type, bool isConfirmed) = 0;
94     virtual LocationErrCode RegisterGnssStatusCallbackV9(const sptr<IRemoteObject>& callback) = 0;
95     virtual LocationErrCode UnregisterGnssStatusCallbackV9(const sptr<IRemoteObject>& callback) = 0;
96     virtual LocationErrCode RegisterNmeaMessageCallbackV9(const sptr<IRemoteObject>& callback) = 0;
97     virtual LocationErrCode UnregisterNmeaMessageCallbackV9(const sptr<IRemoteObject>& callback) = 0;
98     virtual LocationErrCode RegisterCountryCodeCallbackV9(const sptr<IRemoteObject>& callback) = 0;
99     virtual LocationErrCode UnregisterCountryCodeCallbackV9(const sptr<IRemoteObject>& callback) = 0;
100     virtual LocationErrCode RegisterCachedLocationCallbackV9(std::unique_ptr<CachedGnssLocationsRequest>& request,
101         sptr<ICachedLocationsCallback>& callback) = 0;
102     virtual LocationErrCode UnregisterCachedLocationCallbackV9(sptr<ICachedLocationsCallback>& callback) = 0;
103     virtual LocationErrCode GetCachedGnssLocationsSizeV9(int &size) = 0;
104     virtual LocationErrCode FlushCachedGnssLocationsV9() = 0;
105     virtual LocationErrCode SendCommandV9(std::unique_ptr<LocationCommand>& commands) = 0;
106     virtual LocationErrCode AddFenceV9(std::unique_ptr<GeofenceRequest>& request) = 0;
107     virtual LocationErrCode RemoveFenceV9(std::unique_ptr<GeofenceRequest>& request) = 0;
108     virtual LocationErrCode EnableReverseGeocodingMockV9() = 0;
109     virtual LocationErrCode DisableReverseGeocodingMockV9() = 0;
110     virtual LocationErrCode SetReverseGeocodingMockInfoV9(
111         std::vector<std::shared_ptr<GeocodingMockInfo>>& mockInfo) = 0;
112     virtual LocationErrCode GetIsoCountryCodeV9(std::shared_ptr<CountryCode>& countryCode) = 0;
113     virtual LocationErrCode EnableLocationMockV9() = 0;
114     virtual LocationErrCode DisableLocationMockV9() = 0;
115     virtual LocationErrCode SetMockedLocationsV9(
116         const int timeInterval, const std::vector<std::shared_ptr<Location>> &location) = 0;
117     virtual LocationErrCode ProxyUidForFreezeV9(int32_t uid, bool isProxy) = 0;
118     virtual LocationErrCode ResetAllProxyV9() = 0;
119 };
120 } // namespace Location
121 } // namespace OHOS
122 
123 #endif // LOCATOR_H
124