• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2021 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 #ifndef FOUNDATION_APPEXECFWK_OHOS_PAGE_ABILITY_IMPL_H
17 #define FOUNDATION_APPEXECFWK_OHOS_PAGE_ABILITY_IMPL_H
18 
19 #include "ability_impl.h"
20 
21 namespace OHOS {
22 namespace AppExecFwk {
23 class Ability;
24 class AbilityHandler;
25 class AbilityLocalRecord;
26 class AbilityImpl;
27 class PageAbilityImpl final : public AbilityImpl {
28 public:
29     /**
30      * @brief Constructor.
31      *
32      */
33     PageAbilityImpl() = default;
34 
35     /**
36      * @brief Destructor.
37      *
38      */
39     ~PageAbilityImpl() = default;
40 
41     /**
42      * @brief Handling the life cycle switching of PageAbility.
43      *
44      * @param want Indicates the structure containing information about the ability.
45      * @param targetState The life cycle state to switch to.
46      *
47      */
48     void HandleAbilityTransaction(const Want &want, const AAFwk::LifeCycleStateInfo &targetState) override;
49 
50     /**
51      * @brief Handling the life cycle switching of PageAbility in switch.
52      *
53      * @param want Indicates the structure containing information about the ability.
54      * @param targetState The life cycle state to switch to.
55      *
56      * @return return true if the lifecycle transaction successfully, otherwise return false.
57      *
58      */
59     bool AbilityTransaction(const Want &want, const AAFwk::LifeCycleStateInfo &targetState);
60 
61     /**
62       * @brief Handling the life cycle switching of PageAbility in switch.
63       *
64       * @param want Indicates the structure containing information about the ability.
65       * @param targetState The life cycle state to switch to.
66       *
67       * @return return true if the lifecycle transaction successfully, otherwise return false.
68       *
69       */
70     bool AbilityTransactionNew(const Want &want, const AAFwk::LifeCycleStateInfo &targetState);
71 
72     /**
73      * @brief Execution the KeyDown callback of the ability
74      * @param keyEvent Indicates the key-down event.
75      *
76      * @return Returns true if this event is handled and will not be passed further; returns false if this event is
77      * not handled and should be passed to other handlers.
78      *
79      */
80     void DoKeyDown(const std::shared_ptr<MMI::KeyEvent>& keyEvent) override;
81 
82     /**
83      * @brief Execution the KeyUp callback of the ability
84      * @param keyEvent Indicates the key-up event.
85      *
86      * @return Returns true if this event is handled and will not be passed further; returns false if this event is
87      * not handled and should be passed to other handlers.
88      *
89      */
90     void DoKeyUp(const std::shared_ptr<MMI::KeyEvent>& keyEvent) override;
91 
92     /**
93      * @brief Called when a touch event is dispatched to this ability. The default implementation of this callback
94      * does nothing and returns false.
95      * @param touchEvent Indicates information about the touch event.
96      *
97      * @return Returns true if the event is handled; returns false otherwise.
98      *
99      */
100     void DoPointerEvent(std::shared_ptr<MMI::PointerEvent>& pointerEvent) override;
101 };
102 }  // namespace AppExecFwk
103 }  // namespace OHOS
104 #endif  // FOUNDATION_APPEXECFWK_OHOS_PAGE_ABILITY_IMPL_H