• 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 #include "bluetooth_pan_observer_stub.h"
16 #include "bluetooth_log.h"
17 
18 namespace OHOS {
19 namespace Bluetooth {
OnRemoteRequest(uint32_t code,MessageParcel & data,MessageParcel & reply,MessageOption & option)20 int BluetoothPanObserverStub::OnRemoteRequest(
21     uint32_t code, MessageParcel& data, MessageParcel& reply, MessageOption& option)
22 {
23     switch (code) {
24         case static_cast<uint32_t>(BluetoothPanObserverInterfaceCode::COMMAND_ON_CONNECTION_STATE_CHANGED): {
25             if (BluetoothPanObserverStub::GetDescriptor() != data.ReadInterfaceToken()) {
26                 HILOGE("local descriptor is not equal to remote");
27                 return IPC_INVOKER_TRANSLATE_ERR;
28             }
29             std::shared_ptr<BluetoothRawAddress> address(data.ReadParcelable<BluetoothRawAddress>());
30             if (address == nullptr) {
31                 HILOGE("null pointer");
32                 return ERR_TRANSACTION_FAILED;
33             }
34             int state = data.ReadInt32();
35             OnConnectionStateChanged(*address, state);
36             return NO_ERROR;
37         }
38         default:
39             return IPCObjectStub::OnRemoteRequest(code, data, reply, option);
40     }
41 
42     return ERR_TRANSACTION_FAILED;
43 }
44 }  // namespace Bluetooth
45 }  // namespace OHOS