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 FOUNDATION_RESOURCESCHEDULE_BACKGROUND_TASK_MGR_SERVICES_COMMON_BGTASK_CONFIG_H 17 #define FOUNDATION_RESOURCESCHEDULE_BACKGROUND_TASK_MGR_SERVICES_COMMON_BGTASK_CONFIG_H 18 #include <string> 19 #include <set> 20 #include <mutex> 21 22 #include "config_data_source_type.h" 23 #include "singleton.h" 24 #include "nlohmann/json.hpp" 25 26 namespace OHOS { 27 namespace BackgroundTaskMgr { 28 class BgtaskConfig : public DelayedSingleton<BgtaskConfig> { 29 public: 30 void Init(); 31 bool IsTransientTaskExemptedQuatoApp(const std::string &bundleName); 32 bool IsTaskKeepingExemptedQuatoApp(const std::string &bundleName); 33 int32_t GetTransientTaskExemptedQuato(); 34 bool AddExemptedQuatoData(const std::string &configData, int32_t sourceType); 35 36 private: 37 void LoadConfigFile(); 38 void ParseTransientTaskExemptedQuatoList(const nlohmann::json &jsonObj); 39 void ParseTransientTaskExemptedQuato(const nlohmann::json &jsonObj); 40 bool SetCloudConfigParam(const nlohmann::json &jsonObj); 41 42 private: 43 bool isInit_ = false; 44 std::set<std::string> transientTaskExemptedQuatoList_ {}; 45 std::set<std::string> transientTaskCloudExemptedQuatoList_ {}; 46 std::set<std::string> taskKeepingExemptedQuatoList_ = { 47 {"com.sankuai.hmeituan.itakeawaybiz"}, 48 {"cn.wps.mobileoffice.hap.ent"}, 49 {"com.estrongs.hm.pop"}, 50 }; 51 int32_t transientTaskExemptedQuato_ = 10 * 1000; // 10s 52 std::mutex configMutex_; 53 }; 54 } 55 } 56 #endif