1 /* 2 * Copyright (c) 2024 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_APP_EXIT_REASON_HELPER 17 #define OHOS_ABILITY_RUNTIME_APP_EXIT_REASON_HELPER 18 19 #include <memory> 20 #include <mutex> 21 22 #include "bundle_info.h" 23 #include "exit_reason.h" 24 #include "sub_managers_helper.h" 25 26 namespace OHOS { 27 namespace AAFwk { 28 class AppExitReasonHelper { 29 public: 30 explicit AppExitReasonHelper(std::shared_ptr<SubManagersHelper> subManagersHelper); 31 ~AppExitReasonHelper() = default; 32 33 int32_t RecordAppExitReason(const ExitReason &exitReason); 34 int32_t RecordAppExitReason(const std::string &bundleName, int32_t uid, int32_t appIndex, 35 const ExitReason &exitReason); 36 int32_t RecordProcessExtensionExitReason( 37 const int32_t pid, const std::string &bundleName, const ExitReason &exitReason, 38 const AppExecFwk::RunningProcessInfo &processInfo, bool withKillMsg); 39 int32_t RecordProcessExitReason(const int32_t pid, const ExitReason &exitReason, bool fromKillWithReason); 40 int32_t RecordProcessExitReason(int32_t pid, int32_t uid, const ExitReason &exitReason); 41 int32_t RecordUIAbilityExitReason(const pid_t pid, const std::string &abilityName, const ExitReason &exitReason); 42 43 private: 44 int32_t RecordProcessExitReason(const int32_t pid, const std::string bundleName, const int32_t uid, 45 const uint32_t accessTokenId, const ExitReason &exitReason, 46 const AppExecFwk::RunningProcessInfo &processInfo, bool fromKillWithReason, bool searchDead); 47 void GetActiveAbilityList(int32_t uid, std::vector<std::string> &abilityLists, const int32_t pid); 48 int32_t GetActiveAbilityList(int32_t uid, std::vector<std::string> &abilityLists); 49 void GetActiveAbilityListFromUIAbilityManager(int32_t uid, std::vector<std::string> &abilityLists, 50 const int32_t pid); 51 bool IsExitReasonValid(const ExitReason &exitReason); 52 int32_t GetActiveAbilityListWithPid(int32_t uid, std::vector<std::string> &abilityList, int32_t pid); 53 54 std::shared_ptr<SubManagersHelper> subManagersHelper_; 55 }; 56 } // namespace AAFwk 57 } // namespace OHOS 58 #endif // OHOS_ABILITY_RUNTIME_APP_EXIT_REASON_HELPER 59