• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2 * Copyright (c) 2025 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 "ipc_skeleton.h"
17 #include "pasteboard_error.h"
18 #include "pasteboard_hilog.h"
19 #include "pasteboard_signal_stub.h"
20 
21 namespace OHOS {
22 namespace MiscServices {
PasteboardSignalStub()23 PasteboardSignalStub::PasteboardSignalStub()
24 {
25     memberFuncMap_[static_cast<uint32_t>(PasteboardSignalStub::GET_PROGRESS_SIGNAL)] =
26         &PasteboardSignalStub::OnGetProgressSignal;
27 }
28 
OnRemoteRequest(uint32_t code,MessageParcel & data,MessageParcel & reply,MessageOption & option)29 int32_t PasteboardSignalStub::OnRemoteRequest(
30     uint32_t code, MessageParcel &data, MessageParcel &reply, MessageOption &option)
31 {
32     std::u16string myDescriptor = PasteboardSignalStub::GetDescriptor();
33     std::u16string remoteDescriptor = data.ReadInterfaceToken();
34     if (myDescriptor != remoteDescriptor) {
35         PASTEBOARD_HILOGE(PASTEBOARD_MODULE_SERVICE, "end##descriptor checked fail");
36         return static_cast<int32_t>(PasteboardError::CHECK_DESCRIPTOR_ERROR);
37     }
38     pid_t pid = IPCSkeleton::GetCallingPid();
39     pid_t uid = IPCSkeleton::GetCallingUid();
40     PASTEBOARD_HILOGI(PASTEBOARD_MODULE_SERVICE,
41         "CallingPid = %{public}d, CallingUid = %{public}d, code = %{public}u", pid, uid, code);
42     auto itFunc = memberFuncMap_.find(code);
43     if (itFunc != memberFuncMap_.end()) {
44         auto memberFunc = itFunc->second;
45         if (memberFunc != nullptr) {
46             return (this->*memberFunc)(data, reply);
47         }
48     }
49     int ret = IPCObjectStub::OnRemoteRequest(code, data, reply, option);
50     PASTEBOARD_HILOGI(PASTEBOARD_MODULE_SERVICE, "end##ret = %{public}d", ret);
51     return ret;
52 }
53 
OnGetProgressSignal(MessageParcel & data,MessageParcel & reply)54 int32_t PasteboardSignalStub::OnGetProgressSignal(MessageParcel &data, MessageParcel &reply)
55 {
56     std::string signalValue = data.ReadString();
57     PASTEBOARD_HILOGI(PASTEBOARD_MODULE_SERVICE, "OnGetProgressSignal signalValue is %{public}s", signalValue.c_str());
58     HandleProgressSignalValue(signalValue);
59     return ERR_OK;
60 }
61 
~PasteboardSignalStub()62 PasteboardSignalStub::~PasteboardSignalStub()
63 {
64     memberFuncMap_.clear();
65 }
66 } // namespace MiscServices
67 } // namespace OHOS