1 /* 2 * Copyright (c) 2023 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 "ability_app_state_observer.h" 17 #include "ability_record.h" 18 #include "hilog_wrapper.h" 19 20 namespace OHOS { 21 namespace AAFwk { AbilityAppStateObserver(std::shared_ptr<AbilityRecord> abilityRecord)22AbilityAppStateObserver::AbilityAppStateObserver(std::shared_ptr<AbilityRecord> abilityRecord) 23 : abilityRecord_(abilityRecord) {} OnProcessDied(const AppExecFwk::ProcessData & processData)24void AbilityAppStateObserver::OnProcessDied(const AppExecFwk::ProcessData &processData) 25 { 26 auto abilityRecord = abilityRecord_.lock(); 27 if (abilityRecord) { 28 const auto &abilityInfo = abilityRecord->GetAbilityInfo(); 29 if (abilityInfo.bundleName == processData.bundleName && 30 processData.processType == AppExecFwk::ProcessType::NORMAL && 31 abilityInfo.type == AppExecFwk::AbilityType::PAGE) { 32 abilityRecord->OnProcessDied(); 33 } 34 } else { 35 HILOG_WARN("AbilityRecord null"); 36 } 37 } 38 } // namespace AAFwk 39 } // namespace OHOS