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 <list> 20 #include <set> 21 #include <vector> 22 23 #include "iremote_broker.h" 24 #include "iremote_object.h" 25 #include "iremote_proxy.h" 26 27 #include "constant_definition.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 #include "i_locating_required_data_callback.h" 36 #include "locating_required_data_config.h" 37 #include "locationhub_ipc_interface_code.h" 38 #include "i_bluetooth_scan_result_callback.h" 39 40 namespace OHOS { 41 namespace Location { 42 class LocatorProxy : public IRemoteProxy<ILocator> { 43 public: 44 explicit LocatorProxy(const sptr<IRemoteObject> &impl); 45 ~LocatorProxy() = default; 46 void UpdateSaAbility(); 47 int GetSwitchState(); 48 void EnableAbility(bool isEnabled); 49 void RegisterSwitchCallback(const sptr<IRemoteObject> &callback, pid_t uid); 50 void UnregisterSwitchCallback(const sptr<IRemoteObject> &callback); 51 void RegisterGnssStatusCallback(const sptr<IRemoteObject> &callback, pid_t uid); 52 void UnregisterGnssStatusCallback(const sptr<IRemoteObject> &callback); 53 void RegisterNmeaMessageCallback(const sptr<IRemoteObject> &callback, pid_t uid); 54 void UnregisterNmeaMessageCallback(const sptr<IRemoteObject> &callback); 55 int StartLocating(std::unique_ptr<RequestConfig>& requestConfig, 56 sptr<ILocatorCallback>& callback, std::string bundleName, pid_t pid, pid_t uid); 57 int StopLocating(sptr<ILocatorCallback>& callback); 58 int GetCacheLocation(MessageParcel &replay); 59 int IsGeoConvertAvailable(MessageParcel &replay); 60 int GetAddressByCoordinate(MessageParcel &data, MessageParcel &replay); 61 int GetAddressByLocationName(MessageParcel &data, MessageParcel &replay); 62 bool IsLocationPrivacyConfirmed(const int type); 63 int SetLocationPrivacyConfirmStatus(const int type, bool isConfirmed); 64 int RegisterCachedLocationCallback(std::unique_ptr<CachedGnssLocationsRequest>& request, 65 sptr<ICachedLocationsCallback>& callback, std::string bundleName); 66 int UnregisterCachedLocationCallback(sptr<ICachedLocationsCallback>& callback); 67 int GetCachedGnssLocationsSize(); 68 int FlushCachedGnssLocations(); 69 void SendCommand(std::unique_ptr<LocationCommand>& commands); 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 82 LocationErrCode UpdateSaAbilityV9(); 83 LocationErrCode GetSwitchStateV9(bool &isEnabled); 84 LocationErrCode EnableAbilityV9(bool isEnabled); 85 LocationErrCode EnableAbilityForUser(bool isEnabled, int32_t userId); 86 LocationErrCode RegisterSwitchCallbackV9(const sptr<IRemoteObject> &callback); 87 LocationErrCode UnregisterSwitchCallbackV9(const sptr<IRemoteObject> &callback); 88 LocationErrCode RegisterGnssStatusCallbackV9(const sptr<IRemoteObject> &callback); 89 LocationErrCode UnregisterGnssStatusCallbackV9(const sptr<IRemoteObject> &callback); 90 LocationErrCode RegisterNmeaMessageCallbackV9(const sptr<IRemoteObject> &callback); 91 LocationErrCode UnregisterNmeaMessageCallbackV9(const sptr<IRemoteObject> &callback); 92 LocationErrCode StartLocatingV9(std::unique_ptr<RequestConfig>& requestConfig, 93 sptr<ILocatorCallback>& callback); 94 LocationErrCode StopLocatingV9(sptr<ILocatorCallback>& callback); 95 LocationErrCode GetCacheLocationV9(std::unique_ptr<Location> &loc); 96 LocationErrCode IsGeoConvertAvailableV9(bool &isAvailable); 97 LocationErrCode GetAddressByCoordinateV9(MessageParcel &data, 98 std::list<std::shared_ptr<GeoAddress>>& replyList); 99 LocationErrCode GetAddressByLocationNameV9(MessageParcel &data, 100 std::list<std::shared_ptr<GeoAddress>>& replyList); 101 LocationErrCode IsLocationPrivacyConfirmedV9(const int type, bool &isConfirmed); 102 LocationErrCode SetLocationPrivacyConfirmStatusV9(const int type, bool isConfirmed); 103 LocationErrCode RegisterCachedLocationCallbackV9(std::unique_ptr<CachedGnssLocationsRequest>& request, 104 sptr<ICachedLocationsCallback>& callback, std::string bundleName); 105 LocationErrCode UnregisterCachedLocationCallbackV9(sptr<ICachedLocationsCallback>& callback); 106 LocationErrCode GetCachedGnssLocationsSizeV9(int &size); 107 LocationErrCode FlushCachedGnssLocationsV9(); 108 LocationErrCode SendCommandV9(std::unique_ptr<LocationCommand>& commands); 109 LocationErrCode EnableLocationMockV9(); 110 LocationErrCode DisableLocationMockV9(); 111 LocationErrCode SetMockedLocationsV9( 112 const int timeInterval, const std::vector<std::shared_ptr<Location>> &location); 113 LocationErrCode EnableReverseGeocodingMockV9(); 114 LocationErrCode DisableReverseGeocodingMockV9(); 115 LocationErrCode SetReverseGeocodingMockInfoV9(std::vector<std::shared_ptr<GeocodingMockInfo>>& mockInfo); 116 LocationErrCode SendMsgWithDataReplyV9(const int msgId, MessageParcel& data, MessageParcel& reply); 117 LocationErrCode SendMsgWithReplyV9(const int msgId, MessageParcel& reply); 118 LocationErrCode SendSimpleMsgV9(const int msgId); 119 LocationErrCode SendRegisterMsgToRemoteV9(const int msgId, const sptr<IRemoteObject>& callback); 120 LocationErrCode ProxyForFreeze(std::set<int> pidList, bool isProxy); 121 LocationErrCode ResetAllProxy(); 122 LocationErrCode RegisterLocatingRequiredDataCallback( 123 std::unique_ptr<LocatingRequiredDataConfig>& dataConfig, sptr<ILocatingRequiredDataCallback>& callback); 124 LocationErrCode UnRegisterLocatingRequiredDataCallback(sptr<ILocatingRequiredDataCallback>& callback); 125 LocationErrCode SubscribeBluetoothScanResultChange(sptr<IBluetoohScanResultCallback>& callback); 126 LocationErrCode UnSubscribeBluetoothScanResultChange(sptr<IBluetoohScanResultCallback>& callback); 127 LocationErrCode SubscribeLocationError(sptr<ILocatorCallback>& callback); 128 LocationErrCode UnSubscribeLocationError(sptr<ILocatorCallback>& callback); 129 LocationErrCode GetCurrentWifiBssidForLocating(std::string& bssid); 130 LocationErrCode SetLocationSwitchIgnored(bool isEnabled); 131 private: 132 133 static inline BrokerDelegator<LocatorProxy> delegator_; 134 }; 135 } // namespace Location 136 } // namespace OHOS 137 #endif // LOCATOR_PROXY_H 138