11ebd3d54Sopenharmony_ci/*
21ebd3d54Sopenharmony_ci * Copyright (c) 2024 Huawei Device Co., Ltd.
31ebd3d54Sopenharmony_ci * Licensed under the Apache License, Version 2.0 (the "License");
41ebd3d54Sopenharmony_ci * you may not use this file except in compliance with the License.
51ebd3d54Sopenharmony_ci * You may obtain a copy of the License at
61ebd3d54Sopenharmony_ci *
71ebd3d54Sopenharmony_ci *     http://www.apache.org/licenses/LICENSE-2.0
81ebd3d54Sopenharmony_ci *
91ebd3d54Sopenharmony_ci * Unless required by applicable law or agreed to in writing, software
101ebd3d54Sopenharmony_ci * distributed under the License is distributed on an "AS IS" BASIS,
111ebd3d54Sopenharmony_ci * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
121ebd3d54Sopenharmony_ci * See the License for the specific language governing permissions and
131ebd3d54Sopenharmony_ci * limitations under the License.
141ebd3d54Sopenharmony_ci */
151ebd3d54Sopenharmony_ci
161ebd3d54Sopenharmony_ci#ifndef FOUNDATION_RESOURCESCHEDULE_BACKGROUND_TASK_MGR_SERVICES_COMMON_BGTASK_CONFIG_H
171ebd3d54Sopenharmony_ci#define FOUNDATION_RESOURCESCHEDULE_BACKGROUND_TASK_MGR_SERVICES_COMMON_BGTASK_CONFIG_H
181ebd3d54Sopenharmony_ci#include <string>
191ebd3d54Sopenharmony_ci#include <set>
201ebd3d54Sopenharmony_ci#include <mutex>
211ebd3d54Sopenharmony_ci
221ebd3d54Sopenharmony_ci#include "config_data_source_type.h"
231ebd3d54Sopenharmony_ci#include "singleton.h"
241ebd3d54Sopenharmony_ci#include "nlohmann/json.hpp"
251ebd3d54Sopenharmony_ci
261ebd3d54Sopenharmony_cinamespace OHOS {
271ebd3d54Sopenharmony_cinamespace BackgroundTaskMgr {
281ebd3d54Sopenharmony_ciclass BgtaskConfig : public DelayedSingleton<BgtaskConfig> {
291ebd3d54Sopenharmony_cipublic:
301ebd3d54Sopenharmony_ci    void Init();
311ebd3d54Sopenharmony_ci    bool IsTransientTaskExemptedQuatoApp(const std::string &bundleName);
321ebd3d54Sopenharmony_ci    int32_t GetTransientTaskExemptedQuato();
331ebd3d54Sopenharmony_ci    bool AddExemptedQuatoData(const std::string &configData, int32_t sourceType);
341ebd3d54Sopenharmony_ci
351ebd3d54Sopenharmony_ciprivate:
361ebd3d54Sopenharmony_ci    void LoadConfigFile();
371ebd3d54Sopenharmony_ci    void ParseTransientTaskExemptedQuatoList(const nlohmann::json &jsonObj);
381ebd3d54Sopenharmony_ci    void ParseTransientTaskExemptedQuato(const nlohmann::json &jsonObj);
391ebd3d54Sopenharmony_ci    bool SetCloudConfigParam(const nlohmann::json &jsonObj);
401ebd3d54Sopenharmony_ci
411ebd3d54Sopenharmony_ciprivate:
421ebd3d54Sopenharmony_ci    bool isInit_ = false;
431ebd3d54Sopenharmony_ci    std::set<std::string> transientTaskExemptedQuatoList_ {};
441ebd3d54Sopenharmony_ci    std::set<std::string> transientTaskCloudExemptedQuatoList_ {};
451ebd3d54Sopenharmony_ci    int32_t transientTaskExemptedQuato_ = 10 * 1000; // 10s
461ebd3d54Sopenharmony_ci    std::mutex configMutex_;
471ebd3d54Sopenharmony_ci};
481ebd3d54Sopenharmony_ci}
491ebd3d54Sopenharmony_ci}
501ebd3d54Sopenharmony_ci#endif