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 OHOS_ABILITY_RUNTIME_NEW_ABILITY_IMPL_H
17 #define OHOS_ABILITY_RUNTIME_NEW_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 NewAbilityImpl final : public AbilityImpl {
28 public:
29     /**
30      * @brief Constructor.
31      *
32      */
33     NewAbilityImpl() = default;
34 
35     /**
36      * @brief Destructor.
37      *
38      */
39     ~NewAbilityImpl() = default;
40 
41     /**
42      * @brief Handling the life cycle switching of NewAbility.
43      *
44      * @param want Indicates the structure containing information about the ability.
45      * @param targetState The life cycle state to switch to.
46      * @param sessionInfo  Indicates the sessionInfo.
47      *
48      */
49     void HandleAbilityTransaction(const Want &want, const AAFwk::LifeCycleStateInfo &targetState,
50         sptr<AAFwk::SessionInfo> sessionInfo = nullptr) override;
51 
52     /**
53      * @brief The life cycle callback of NewAbility.
54      * @param state The life cycle state to switch to.
55      */
56     void AbilityTransactionCallback(const AbilityLifeCycleState &state) override;
57 
58     /**
59      * @brief Handling the life cycle switching of NewAbility in switch.
60      *
61      * @param want Indicates the structure containing information about the ability.
62      * @param targetState The life cycle state to switch to.
63      *
64      * @return return true if the lifecycle transaction successfully, otherwise return false.
65      *
66      */
67     bool AbilityTransaction(const Want &want, const AAFwk::LifeCycleStateInfo &targetState);
68 
69     bool AbilityTransactionForeground(const Want &want, const AAFwk::LifeCycleStateInfo &targetState);
70 
71     /**
72      * @description:  Provide operating system ShareData information to the observer
73      * @param requestCode Indicates the requestCode
74      */
75     void HandleShareData(const int32_t &requestCode) override;
76 };
77 }  // namespace AppExecFwk
78 }  // namespace OHOS
79 #endif  // OHOS_ABILITY_RUNTIME_NEW_ABILITY_IMPL_H
80