• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2025 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 UTIL_H
16 #define UTIL_H
17 
18 #include "ohos.geoLocationManager.proj.hpp"
19 #include "ohos.geoLocationManager.impl.hpp"
20 #include "taihe/runtime.hpp"
21 #include "stdexcept"
22 #include "location.h"
23 #include "common_utils.h"
24 #include "geo_address.h"
25 #include "request_config.h"
26 #include "ipc_skeleton.h"
27 #include "common_utils.h"
28 #include "permission_manager.h"
29 #include "locating_required_data.h"
30 #include "satellite_status.h"
31 #include "bluetooth_scan_result.h"
32 #include <list>
33 #include <vector>
34 namespace OHOS {
35 namespace Location {
36 class Util {
37 public:
38     static std::map<int, std::string> GetErrorCodeMapTaihe();
39     static int ConvertErrorCodeTaihe(int errorCode);
40     static std::string GetErrorMsgByCodeTaihe(int code);
41     static void ThrowBussinessError(int code);
42     static void LocationToTaihe(::ohos::geoLocationManager::Location& location,
43         std::unique_ptr<Location>& lastlocation);
44     static void TaiheCurrentRequestObjToRequestConfig(
45         ::taihe::optional_view<::ohos::geoLocationManager::CurrentRequest> request,
46         std::unique_ptr<RequestConfig>& requestConfig);
47     static void GeoAddressToTaihe(std::vector<::ohos::geoLocationManager::GeoAddress>& geoAddressList,
48         std::list<std::shared_ptr<GeoAddress>> replyList);
49     static void TaiheCurrentRequestObjToRequestConfig(::ohos::geoLocationManager::OnRequest const& request,
50         std::unique_ptr<RequestConfig>& requestConfig);
51     static void LocatingRequiredDataToTaihe(
52         std::vector<::ohos::geoLocationManager::LocatingRequiredData>& locatingRequiredDataList,
53         const std::vector<std::shared_ptr<LocatingRequiredData>>& replyList);
54     static void SatelliteStatusInfoToTaihe(::ohos::geoLocationManager::SatelliteStatusInfo& satelliteStatusInfo,
55         const std::unique_ptr<SatelliteStatus>& statusInfo);
56     static void BluetoothScanResultToTaihe(::ohos::geoLocationManager::BluetoothScanResult& bluetoothScanResultTaihe,
57         const std::unique_ptr<BluetoothScanResult>& bluetoothScanResult);
58 };
59 }
60 }
61 #endif