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