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