1 /* 2 * Copyright (c) 2025 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_EXIT_INFO_DATA_MANAGER_H 17 #define OHOS_ABILITY_RUNTIME_EXIT_INFO_DATA_MANAGER_H 18 19 #include <map> 20 #include <mutex> 21 #include <string> 22 #include <vector> 23 24 #include "last_exit_detail_info.h" 25 #include "singleton.h" 26 27 namespace OHOS { 28 namespace AbilityRuntime { 29 struct ExitCacheInfo { 30 AAFwk::LastExitDetailInfo exitInfo = {}; 31 std::string bundleName = ""; 32 std::vector<std::string> abilityNames; 33 std::vector<std::string> uiExtensionNames; 34 }; 35 36 class ExitInfoDataManager { 37 public: GetInstance()38 static ExitInfoDataManager &GetInstance() 39 { 40 static ExitInfoDataManager instance; 41 return instance; 42 } 43 virtual ~ExitInfoDataManager() = default; 44 45 bool AddExitInfo(uint32_t accessTokenId, ExitCacheInfo &cacheInfo); 46 47 bool DeleteExitInfo(uint32_t accessTokenId); 48 49 bool GetExitInfo(uint32_t accessTokenId, ExitCacheInfo &cacheInfo); 50 51 bool GetExitInfo(int32_t pid, int32_t uid, uint32_t &accessTokenId, ExitCacheInfo &cacheInfo); 52 53 bool IsExitInfoExist(uint32_t accessTokenId); 54 55 private: 56 ExitInfoDataManager() = default; 57 DISALLOW_COPY_AND_MOVE(ExitInfoDataManager); 58 59 private: 60 std::mutex mutex_; 61 std::map<uint32_t, ExitCacheInfo> exitCacheInfos_; 62 }; 63 } // namespace AbilityRuntime 64 } // namespace OHOS 65 #endif // OHOS_ABILITY_RUNTIME_EXIT_INFO_DATA_MANAGER_H 66