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_opp_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 BluetoothOppObserverStub::OnRemoteRequest(
21 uint32_t code, MessageParcel& data, MessageParcel& reply, MessageOption& option)
22 {
23 HILOGI("BluetoothOppObserverStub OnRemoteRequest start");
24 switch (code) {
25 case static_cast<uint32_t>(BluetoothOppObserverInterfaceCode::COMMAND_ON_RECEIVE_INCOMING_FILE_CHANGED): {
26 if (BluetoothOppObserverStub::GetDescriptor() != data.ReadInterfaceToken()) {
27 HILOGE("local descriptor is not equal to remote");
28 return IPC_INVOKER_TRANSLATE_ERR;
29 }
30 std::shared_ptr<BluetoothIOppTransferInformation> oppInformation(
31 data.ReadParcelable<BluetoothIOppTransferInformation>());
32 if (oppInformation == nullptr) {
33 return ERR_NULL_OBJECT;
34 }
35 OnReceiveIncomingFileChanged(*oppInformation);
36 HILOGE("BluetoothOppObserverInterfaceCode::COMMAND_ON_RECEIVE_INCOMING_FILE_CHANGED end");
37 return NO_ERROR;
38 }
39 case static_cast<uint32_t>(BluetoothOppObserverInterfaceCode::COMMAND_ON_TRANSFER_STATE_CHANGED): {
40 if (BluetoothOppObserverStub::GetDescriptor() != data.ReadInterfaceToken()) {
41 HILOGE("local descriptor is not equal to remote");
42 return IPC_INVOKER_TRANSLATE_ERR;
43 }
44 std::shared_ptr<BluetoothIOppTransferInformation> oppInformation(
45 data.ReadParcelable<BluetoothIOppTransferInformation>());
46 if (oppInformation == nullptr) {
47 return ERR_NULL_OBJECT;
48 }
49 OnTransferStateChanged(*oppInformation);
50 HILOGE("BluetoothOppObserverInterfaceCode::COMMAND_ON_TRANSFER_STATE_CHANGED end");
51 return NO_ERROR;
52 }
53 default:
54 return IPCObjectStub::OnRemoteRequest(code, data, reply, option);
55 }
56
57 return ERR_TRANSACTION_FAILED;
58 }
59 } // namespace Bluetooth
60 } // namespace OHOS