• 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 #define LOG_TAG "ProcessCallback"
16 #include "progress_callback.h"
17 
18 #include "error_code.h"
19 #include "ipc_skeleton.h"
20 #include "logger.h"
21 #include "udmf_async_client.h"
22 
23 
24 namespace OHOS {
25 namespace UDMF {
OnRemoteRequest(uint32_t code,MessageParcel & data,MessageParcel & reply,MessageOption & option)26 int32_t ProgressSignalStub::OnRemoteRequest(uint32_t code,
27     MessageParcel &data, MessageParcel &reply, MessageOption &option)
28 {
29     std::u16string myDescriptor = ProgressSignalStub::GetDescriptor();
30     std::u16string remoteDescriptor = data.ReadInterfaceToken();
31     if (myDescriptor != remoteDescriptor) {
32         LOG_ERROR(UDMF_SERVICE, "Descriptor checked fail");
33         return E_ERROR;
34     }
35     pid_t pid = IPCSkeleton::GetCallingPid();
36     pid_t uid = IPCSkeleton::GetCallingUid();
37     LOG_INFO(UDMF_SERVICE, "CallingPid=%{public}d, CallingUid=%{public}d, code=%{public}u", pid, uid, code);
38     HandleProgressSignalValue(data);
39     return E_OK;
40 }
41 
HandleProgressSignalValue(MessageParcel & data)42 void ProgressSignalCallback::HandleProgressSignalValue(MessageParcel &data)
43 {
44     int32_t cancelStatus = 0;
45     std::string signalValue = data.ReadString();
46 
47     try {
48         cancelStatus = std::stoi(signalValue);
49     } catch (const std::exception& e) {
50         LOG_ERROR(UDMF_CLIENT, "Signal value error, signalValue=%{public}s", signalValue.c_str());
51         return;
52     }
53     switch (cancelStatus) {
54         case NORMAL_PASTE:
55             break;
56         case CANCEL_PASTE:
57             UdmfAsyncClient::GetInstance().CancelOnSingleTask();
58             break;
59         case PASTE_TIME_OUT:
60             LOG_ERROR(UDMF_CLIENT, "Progress timed out");
61             break;
62         default:
63             LOG_ERROR(UDMF_CLIENT, "status error, status=%{public}d", cancelStatus);
64             break;
65     }
66 }
67 } // namespace UDMF
68 } // namespace OHOS