1 /* 2 * Copyright (c) 2021-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 #ifndef HI_APP_EVENT_CONFIG_H 16 #define HI_APP_EVENT_CONFIG_H 17 18 #include <string> 19 #include <map> 20 21 #include "nocopyable.h" 22 23 namespace OHOS { 24 namespace HiviewDFX { 25 class HiAppEventConfig : public NoCopyable { 26 public: 27 static HiAppEventConfig& GetInstance(); 28 void SetStorageDir(const std::string& dir); 29 bool SetConfigurationItem(std::string name, std::string value); 30 bool GetDisable(); 31 uint64_t GetMaxStorageSize(); 32 std::string GetStorageDir(); 33 std::string GetRunningId(); 34 bool IsFreeSizeOverLimit(); 35 void RefreshFreeSize(); 36 int SetEventConfig(const std::string& name, const std::map<std::string, std::string>& eventConfig); 37 int SetCrashConfig(const std::map<uint8_t, uint32_t> &configMap); 38 39 private: HiAppEventConfig()40 HiAppEventConfig() {} ~HiAppEventConfig()41 ~HiAppEventConfig() {} 42 HiAppEventConfig(const HiAppEventConfig&); 43 HiAppEventConfig& operator=(const HiAppEventConfig&); 44 bool SetDisableItem(const std::string& value); 45 bool SetMaxStorageSizeItem(const std::string& value); 46 void SetDisable(bool disable); 47 void SetMaxStorageSize(uint64_t size); 48 49 private: 50 bool disable_ = false; 51 int64_t freeSize_ = -1; 52 bool isInitFreeSize_ = false; 53 uint64_t maxStorageSize_ = 10 * 1024 * 1024; // max storage size is 10M, 10 * 1024 * 1024 Byte 54 std::string storageDir_ = ""; 55 std::string runningId_ = ""; 56 }; 57 } // namespace HiviewDFX 58 } // namespace OHOS 59 #endif // HI_APP_EVENT_CONFIG_H 60