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_switch_callback_taihe.h"
17 #include "location_log.h"
18
19 namespace OHOS {
20 namespace Location {
OnRemoteRequest(uint32_t code,MessageParcel & data,MessageParcel & reply,MessageOption & option)21 int LocationSwitchCallbackTaihe::OnRemoteRequest(
22 uint32_t code, MessageParcel& data, MessageParcel& reply, MessageOption& option)
23 {
24 LBSLOGD(SWITCH_CALLBACK, "LocationSwitchCallbackTaihe::OnRemoteRequest! code %{punlic}d", code);
25 if (data.ReadInterfaceToken() != GetDescriptor()) {
26 LBSLOGE(SWITCH_CALLBACK, "invalid token.");
27 return -1;
28 }
29
30 switch (code) {
31 case RECEIVE_SWITCH_STATE_EVENT: {
32 OnSwitchChange(data.ReadInt32());
33 break;
34 }
35 default: {
36 IPCObjectStub::OnRemoteRequest(code, data, reply, option);
37 break;
38 }
39 }
40 return 0;
41 }
42
OnSwitchChange(int switchState)43 void LocationSwitchCallbackTaihe::OnSwitchChange(int switchState)
44 {
45 if (callback_) {
46 (*callback_)(switchState == 0? false: true);
47 }
48 }
49 } // namespace Location
50 } // namespace OHOS
51