• 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 #include "ui_effect_controller_stub.h"
16 
17 #include "wm_common.h"
18 #include "window_manager_hilog.h"
19 #include "ui_effect_controller_common.h"
20 namespace OHOS::Rosen {
OnRemoteRequest(uint32_t code,MessageParcel & data,MessageParcel & reply,MessageOption & option)21 int32_t UIEffectControllerStub::OnRemoteRequest(uint32_t code, MessageParcel& data,
22     MessageParcel& reply, MessageOption& option)
23 {
24     if (data.ReadInterfaceToken() != GetDescriptor()) {
25         TLOGE(WmsLogTag::WMS_ANIMATION, "Failed to check interface token!");
26         return ERR_TRANSACTION_FAILED;
27     }
28     switch (code) {
29         case static_cast<uint32_t>(UIEffectControllerMessage::TRANS_ID_UIEFFECT_SET_PARAM):
30             return HandleSetParams(data, reply);
31         case static_cast<uint32_t>(UIEffectControllerMessage::TRANS_ID_UIEFFECT_ANIMATE_TO):
32             return HandleAnimateTo(data, reply);
33         default:
34             TLOGE(WmsLogTag::WMS_ANIMATION, "Failed to find function handler!");
35             return IPCObjectStub::OnRemoteRequest(code, data, reply, option);
36     }
37 }
38 
HandleSetParams(MessageParcel & data,MessageParcel & reply)39 int UIEffectControllerStub::HandleSetParams(MessageParcel& data, MessageParcel& reply)
40 {
41     sptr<UIEffectParams> params = data.ReadStrongParcelable<UIEffectParams>();
42     if (params == nullptr) {
43         TLOGE(WmsLogTag::WMS_ANIMATION, "read ui effect params failed");
44         return ERR_INVALID_DATA;
45     }
46     WMError errCode = SetParams(params);
47     if (!reply.WriteUint32(static_cast<uint32_t>(errCode))) {
48         TLOGE(WmsLogTag::WMS_ANIMATION, "Write errCode failed.");
49         return ERR_INVALID_DATA;
50     }
51     return ERR_NONE;
52 }
53 
HandleAnimateTo(MessageParcel & data,MessageParcel & reply)54 int UIEffectControllerStub::HandleAnimateTo(MessageParcel& data, MessageParcel& reply)
55 {
56     sptr<UIEffectParams> params = data.ReadStrongParcelable<UIEffectParams>();
57     if (params == nullptr) {
58         TLOGE(WmsLogTag::WMS_ANIMATION, "read ui effect params failed");
59         return ERR_INVALID_DATA;
60     }
61     sptr<WindowAnimationOption> config = data.ReadStrongParcelable<WindowAnimationOption>();
62     if (config == nullptr) {
63         TLOGE(WmsLogTag::WMS_ANIMATION, "read animation config failed");
64         return ERR_INVALID_DATA;
65     }
66     sptr<WindowAnimationOption> interruptOption = nullptr;
67     bool hasInterruptOption = false;
68     if (!data.ReadBool(hasInterruptOption)) {
69         TLOGE(WmsLogTag::WMS_ANIMATION, "read has interrupt option failed");
70         return ERR_INVALID_DATA;
71     }
72     if (hasInterruptOption) {
73         interruptOption = data.ReadStrongParcelable<WindowAnimationOption>();
74         if (interruptOption == nullptr) {
75             TLOGE(WmsLogTag::WMS_ANIMATION, "read animation interrupt config failed");
76             return ERR_INVALID_DATA;
77         }
78     }
79     WMError errCode = AnimateTo(params, config, interruptOption);
80     if (!reply.WriteUint32(static_cast<uint32_t>(errCode))) {
81         TLOGE(WmsLogTag::WMS_ANIMATION, "Write errCode failed.");
82         return ERR_INVALID_DATA;
83     }
84     return ERR_NONE;
85 }
86 }