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