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 #include "amsstabilityerrorl1.h" 17 18 namespace OHOS { 19 namespace AppExecFwk { OnStart(const Want & want)20void AmsStAbilityErrorL1::OnStart(const Want &want) 21 { 22 Want mWant(want); 23 shouldReturn = mWant.GetStringParam("shouldReturn"); 24 targetBundle = mWant.GetStringParam("targetBundle"); 25 targetAbility = mWant.GetStringParam("targetAbility"); 26 27 APP_LOGI("AmsStAbilityErrorL1::onStart"); 28 Ability::OnStart(want); 29 } 30 OnStop()31void AmsStAbilityErrorL1::OnStop() 32 { 33 APP_LOGI("AmsStAbilityErrorL1::onStop"); 34 Ability::OnStop(); 35 } 36 OnActive()37void AmsStAbilityErrorL1::OnActive() 38 { 39 APP_LOGI("AmsStAbilityErrorL1::OnActive"); 40 Ability::OnActive(); 41 if (!targetBundle.empty() && !targetAbility.empty()) { 42 Want want; 43 want.SetElementName(targetBundle, targetAbility); 44 want.SetParam("shouldReturn", shouldReturn); 45 StartAbility(want); 46 } 47 if (std::string::npos != shouldReturn.find(GetAbilityName())) { 48 TerminateAbility(); 49 } 50 } 51 OnInactive()52void AmsStAbilityErrorL1::OnInactive() 53 { 54 APP_LOGI("AmsStAbilityErrorL1::OnInactive"); 55 Ability::OnInactive(); 56 } 57 OnBackground()58void AmsStAbilityErrorL1::OnBackground() 59 { 60 APP_LOGI("AmsStAbilityErrorL1::OnBackground"); 61 Ability::OnBackground(); 62 } 63 64 REGISTER_AA(AmsStAbilityErrorL1); 65 } // namespace AppExecFwk 66 } // namespace OHOS