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
16 #include "location_error_callback_taihe.h"
17 #include "common_utils.h"
18 #include "ipc_skeleton.h"
19 #include "location_log.h"
20
21 namespace OHOS {
22 namespace Location {
LocationErrorCallbackTaihe()23 LocationErrorCallbackTaihe::LocationErrorCallbackTaihe()
24 {
25 }
26
~LocationErrorCallbackTaihe()27 LocationErrorCallbackTaihe::~LocationErrorCallbackTaihe()
28 {
29 }
30
OnRemoteRequest(uint32_t code,MessageParcel & data,MessageParcel & reply,MessageOption & option)31 int LocationErrorCallbackTaihe::OnRemoteRequest(
32 uint32_t code, MessageParcel& data, MessageParcel& reply, MessageOption& option)
33 {
34 LBSLOGI(LOCATION_ERR_CALLBACK, "LocatorCallbackHost::OnRemoteRequest! code = %{public}d", code);
35 if (data.ReadInterfaceToken() != GetDescriptor()) {
36 LBSLOGE(LOCATION_ERR_CALLBACK, "invalid token.");
37 return -1;
38 }
39
40 switch (code) {
41 case RECEIVE_ERROR_INFO_EVENT: {
42 OnErrorReport(data.ReadInt32());
43 break;
44 }
45 default: {
46 IPCObjectStub::OnRemoteRequest(code, data, reply, option);
47 break;
48 }
49 }
50 return 0;
51 }
52
OnLocationReport(const std::unique_ptr<Location> & location)53 void LocationErrorCallbackTaihe::OnLocationReport(const std::unique_ptr<Location>& location)
54 {
55 }
56
OnLocatingStatusChange(const int status)57 void LocationErrorCallbackTaihe::OnLocatingStatusChange(const int status)
58 {
59 }
60
OnErrorReport(const int errorCode)61 void LocationErrorCallbackTaihe::OnErrorReport(const int errorCode)
62 {
63 LBSLOGI(LOCATION_ERR_CALLBACK, "OnErrorReport code = %{public}d", errorCode);
64 if (callback_) {
65 (*callback_)(static_cast<::ohos::geoLocationManager::LocationError::key_t>(errorCode));
66 }
67 }
68 } // namespace Location
69 } // namespace OHOS
70