1e0dac50fSopenharmony_ci/* 2e0dac50fSopenharmony_ci * Copyright (c) 2022 Huawei Device Co., Ltd. 3e0dac50fSopenharmony_ci * Licensed under the Apache License, Version 2.0 (the "License"); 4e0dac50fSopenharmony_ci * you may not use this file except in compliance with the License. 5e0dac50fSopenharmony_ci * You may obtain a copy of the License at 6e0dac50fSopenharmony_ci * 7e0dac50fSopenharmony_ci * http://www.apache.org/licenses/LICENSE-2.0 8e0dac50fSopenharmony_ci * 9e0dac50fSopenharmony_ci * Unless required by applicable law or agreed to in writing, software 10e0dac50fSopenharmony_ci * distributed under the License is distributed on an "AS IS" BASIS, 11e0dac50fSopenharmony_ci * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12e0dac50fSopenharmony_ci * See the License for the specific language governing permissions and 13e0dac50fSopenharmony_ci * limitations under the License. 14e0dac50fSopenharmony_ci */ 15e0dac50fSopenharmony_ci 16e0dac50fSopenharmony_ci#ifndef OHOS_ROSEN_REMOTE_ANIMATION_H 17e0dac50fSopenharmony_ci#define OHOS_ROSEN_REMOTE_ANIMATION_H 18e0dac50fSopenharmony_ci 19e0dac50fSopenharmony_ci#include <refbase.h> 20e0dac50fSopenharmony_ci#include <rs_iwindow_animation_controller.h> 21e0dac50fSopenharmony_ci#include <rs_window_animation_finished_callback.h> 22e0dac50fSopenharmony_ci#include <rs_window_animation_target.h> 23e0dac50fSopenharmony_ci 24e0dac50fSopenharmony_ci#include "wm_common.h" 25e0dac50fSopenharmony_ci#include "window_controller.h" 26e0dac50fSopenharmony_ci#include "window_node.h" 27e0dac50fSopenharmony_ci#include "window_root.h" 28e0dac50fSopenharmony_ci#include "window_transition_info.h" 29e0dac50fSopenharmony_ci 30e0dac50fSopenharmony_cinamespace OHOS { 31e0dac50fSopenharmony_cinamespace Rosen { 32e0dac50fSopenharmony_cienum class TransitionEvent : uint32_t { 33e0dac50fSopenharmony_ci APP_TRANSITION, 34e0dac50fSopenharmony_ci HOME, 35e0dac50fSopenharmony_ci MINIMIZE, 36e0dac50fSopenharmony_ci CLOSE, 37e0dac50fSopenharmony_ci BACK_TRANSITION, 38e0dac50fSopenharmony_ci CLOSE_BUTTON, 39e0dac50fSopenharmony_ci BACKGROUND_TRANSITION, 40e0dac50fSopenharmony_ci UNKNOWN, 41e0dac50fSopenharmony_ci}; 42e0dac50fSopenharmony_ci 43e0dac50fSopenharmony_ciclass RemoteAnimation : public RefBase { 44e0dac50fSopenharmony_cipublic: 45e0dac50fSopenharmony_ci RemoteAnimation() = delete; 46e0dac50fSopenharmony_ci ~RemoteAnimation() = default; 47e0dac50fSopenharmony_ci 48e0dac50fSopenharmony_ci static bool CheckTransition(sptr<WindowTransitionInfo> srcInfo, const sptr<WindowNode>& srcNode, 49e0dac50fSopenharmony_ci sptr<WindowTransitionInfo> dstInfo, const sptr<WindowNode>& dstNode); 50e0dac50fSopenharmony_ci static TransitionEvent GetTransitionEvent(sptr<WindowTransitionInfo> srcInfo, 51e0dac50fSopenharmony_ci sptr<WindowTransitionInfo> dstInfo, const sptr<WindowNode>& srcNode, const sptr<WindowNode>& dstNode); 52e0dac50fSopenharmony_ci static WMError SetWindowAnimationController(const sptr<RSIWindowAnimationController>& controller); 53e0dac50fSopenharmony_ci static WMError NotifyAnimationTransition(sptr<WindowTransitionInfo> srcInfo, sptr<WindowTransitionInfo> dstInfo, 54e0dac50fSopenharmony_ci const sptr<WindowNode>& srcNode, const sptr<WindowNode>& dstNode); 55e0dac50fSopenharmony_ci static WMError NotifyAnimationMinimize(sptr<WindowTransitionInfo> srcInfo, const sptr<WindowNode>& srcNode); 56e0dac50fSopenharmony_ci static WMError NotifyAnimationClose(sptr<WindowTransitionInfo> srcInfo, const sptr<WindowNode>& srcNode, 57e0dac50fSopenharmony_ci TransitionEvent event); 58e0dac50fSopenharmony_ci static WMError NotifyAnimationBackTransition(sptr<WindowTransitionInfo> srcInfo, 59e0dac50fSopenharmony_ci sptr<WindowTransitionInfo> dstInfo, const sptr<WindowNode>& srcNode, 60e0dac50fSopenharmony_ci const sptr<WindowNode>& dstNode, const TransitionEvent event); 61e0dac50fSopenharmony_ci static void NotifyAnimationUpdateWallpaper(sptr<WindowNode> node); 62e0dac50fSopenharmony_ci static void OnRemoteDie(const sptr<IRemoteObject>& remoteObject); 63e0dac50fSopenharmony_ci static bool CheckAnimationController(); 64e0dac50fSopenharmony_ci static bool CheckRemoteAnimationEnabled(DisplayId displayId); 65e0dac50fSopenharmony_ci static void NotifyAnimationAbilityDied(sptr<WindowTransitionInfo> info); 66e0dac50fSopenharmony_ci static WMError NotifyAnimationByHome(); 67e0dac50fSopenharmony_ci static WMError NotifyAnimationScreenUnlock(std::function<void(void)> callback, sptr<WindowNode> node); 68e0dac50fSopenharmony_ci static void SetMainTaskHandler(std::shared_ptr<AppExecFwk::EventHandler> handler); 69e0dac50fSopenharmony_ci static void NotifyAnimationTargetsUpdate(std::vector<uint32_t>& fullScreenWinIds, 70e0dac50fSopenharmony_ci std::vector<uint32_t>& floatWinIds); 71e0dac50fSopenharmony_ci static void SetAnimationFirst(bool animationFirst); 72e0dac50fSopenharmony_ci static void SetWindowControllerAndRoot(const sptr<WindowController>& windowController, 73e0dac50fSopenharmony_ci const sptr<WindowRoot>& windowRoot); 74e0dac50fSopenharmony_ci static bool IsRemoteAnimationEnabledAndFirst(DisplayId displayId = 0); 75e0dac50fSopenharmony_ci static void CallbackTimeOutProcess(); 76e0dac50fSopenharmony_ci static sptr<RSWindowAnimationFinishedCallback> CreateAnimationFinishedCallback( 77e0dac50fSopenharmony_ci const std::function<void(void)>& callback, sptr<WindowNode> windowNode); 78e0dac50fSopenharmony_ci static WMError GetWindowAnimationTargets(std::vector<uint32_t> missionIds, 79e0dac50fSopenharmony_ci std::vector<sptr<RSWindowAnimationTarget>>& targets); 80e0dac50fSopenharmony_ci static inline bool IsAnimationFirst() 81e0dac50fSopenharmony_ci { 82e0dac50fSopenharmony_ci return animationFirst_; 83e0dac50fSopenharmony_ci } 84e0dac50fSopenharmony_ci static bool isRemoteAnimationEnable_; 85e0dac50fSopenharmony_ci 86e0dac50fSopenharmony_ciprivate: 87e0dac50fSopenharmony_ci static sptr<RSWindowAnimationTarget> CreateWindowAnimationTarget(sptr<WindowTransitionInfo> info, 88e0dac50fSopenharmony_ci const sptr<WindowNode>& windowNode); 89e0dac50fSopenharmony_ci static WMError NotifyAnimationStartApp(sptr<WindowTransitionInfo> srcInfo, 90e0dac50fSopenharmony_ci const sptr<WindowNode>& srcNode, const sptr<WindowNode>& dstNode, 91e0dac50fSopenharmony_ci sptr<RSWindowAnimationTarget>& dstTarget, sptr<RSWindowAnimationFinishedCallback>& finishedCallback); 92e0dac50fSopenharmony_ci static sptr<RSWindowAnimationFinishedCallback> CreateShowAnimationFinishedCallback( 93e0dac50fSopenharmony_ci const sptr<WindowNode>& srcNode, const sptr<WindowNode>& dstNode, bool needMinimizeSrcNode); 94e0dac50fSopenharmony_ci static sptr<RSWindowAnimationFinishedCallback> CreateHideAnimationFinishedCallback( 95e0dac50fSopenharmony_ci const sptr<WindowNode>& srcNode, TransitionEvent event); 96e0dac50fSopenharmony_ci static void ProcessNodeStateTask(sptr<WindowNode>& node); 97e0dac50fSopenharmony_ci static void GetExpectRect(const sptr<WindowNode>& dstNode, const sptr<RSWindowAnimationTarget>& dstTarget); 98e0dac50fSopenharmony_ci static void PostProcessShowCallback(const sptr<WindowNode>& node); 99e0dac50fSopenharmony_ci static void ExecuteFinalStateTask(sptr<WindowNode>& node); 100e0dac50fSopenharmony_ci static void GetAnimationTargetsForHome(std::vector<sptr<RSWindowAnimationTarget>>& animationTargets, 101e0dac50fSopenharmony_ci std::vector<wptr<WindowNode>> needMinimizeAppNodes); 102e0dac50fSopenharmony_ci static sptr<RSWindowAnimationFinishedCallback> GetTransitionFinishedCallback( 103e0dac50fSopenharmony_ci const sptr<WindowNode>& srcNode, const sptr<WindowNode>& dstNode); 104e0dac50fSopenharmony_ci 105e0dac50fSopenharmony_ci static sptr<RSIWindowAnimationController> windowAnimationController_; 106e0dac50fSopenharmony_ci static wptr<WindowRoot> windowRoot_; 107e0dac50fSopenharmony_ci static std::weak_ptr<AppExecFwk::EventHandler> wmsTaskHandler_; 108e0dac50fSopenharmony_ci static wptr<WindowController> windowController_; 109e0dac50fSopenharmony_ci static bool animationFirst_; 110e0dac50fSopenharmony_ci static std::atomic<uint32_t> allocationId_; 111e0dac50fSopenharmony_ci}; 112e0dac50fSopenharmony_ci} // Rosen 113e0dac50fSopenharmony_ci} // OHOS 114e0dac50fSopenharmony_ci#endif // OHOS_ROSEN_REMOTE_ANIMATION_H 115