• 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 
16 #include "file_access_notify_stub.h"
17 
18 #include "file_access_framework_errno.h"
19 #include "hilog_wrapper.h"
20 #include "message_parcel.h"
21 
22 namespace OHOS {
23 namespace FileAccessFwk {
OnRemoteRequest(uint32_t code,MessageParcel & data,MessageParcel & reply,MessageOption & option)24 int32_t FileAccessNotifyStub::OnRemoteRequest(uint32_t code, MessageParcel &data,
25     MessageParcel &reply, MessageOption &option)
26 {
27     auto descriptor = FileAccessNotifyStub::GetDescriptor();
28     auto remoteDescriptor = data.ReadInterfaceToken();
29     if (descriptor != remoteDescriptor) {
30         HILOG_ERROR("local descriptor is not equal to remote");
31         return EINVAL;
32     }
33     HILOG_INFO("FileAccessNotifyStub::OnRemoteRequest, code:%{public}u", code);
34     switch (code) {
35         case CMD_NOTIFY: {
36             std::shared_ptr<NotifyMessage> message(data.ReadParcelable<NotifyMessage>());
37             if (message == nullptr) {
38                 HILOG_ERROR("read parcelable message fail");
39                 return E_IPCS;
40             }
41             auto ret = Notify(*message);
42             if (ret != ERR_OK) {
43                 HILOG_ERROR("FileAccessNotifyStub::OnRemoteRequest, Notify error, ret:%{public}d", ret);
44             }
45             return ret;
46         }
47         default:
48             HILOG_DEBUG("FileAccessNotifyStub::OnRemoteRequest error code:%{public}u", code);
49             return IPCObjectStub::OnRemoteRequest(code, data, reply, option);
50     }
51 }
52 }  // namespace FileAccessFwk
53 }  // namespace OHOS