• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 LOG_TAG
16 #define LOG_TAG "bt_ipc_hid_host_observer_stub"
17 #endif
18 
19 #include "bluetooth_hid_host_observer_stub.h"
20 #include "bluetooth_log.h"
21 
22 namespace OHOS {
23 namespace Bluetooth {
OnRemoteRequest(uint32_t code,MessageParcel & data,MessageParcel & reply,MessageOption & option)24 int BluetoothHidHostObserverStub::OnRemoteRequest(
25     uint32_t code,
26     MessageParcel& data,
27     MessageParcel& reply,
28     MessageOption& option)
29 {
30     switch (code) {
31         case static_cast<uint32_t>(BluetoothHidHostObserverInterfaceCode::COMMAND_ON_CONNECTION_STATE_CHANGED): {
32             if (BluetoothHidHostObserverStub::GetDescriptor() != data.ReadInterfaceToken()) {
33                 HILOGE("local descriptor is not equal to remote");
34                 return IPC_INVOKER_TRANSLATE_ERR;
35             }
36             std::shared_ptr<BluetoothRawAddress> device(data.ReadParcelable<BluetoothRawAddress>());
37             if (!device) {
38                 HILOGE("COMMAND_ON_CONNECTION_STATE_CHANGED device is null");
39                 return IPC_INVOKER_TRANSLATE_ERR;
40             }
41             int state = data.ReadInt32();
42             int cause = data.ReadInt32();
43             OnConnectionStateChanged(*device, state, cause);
44             return NO_ERROR;
45         }
46         default:
47             return IPCObjectStub::OnRemoteRequest(code, data, reply, option);
48     }
49 
50     return ERR_TRANSACTION_FAILED;
51 }
52 } // Bluetooth
53 } // OHOS
54