1 /* 2 * Copyright (c) 2022 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 #include "bgtask_common.h" 17 18 #include <parameters.h> 19 #include <string_ex.h> 20 21 #include "time_provider.h" 22 23 using OHOS::system::GetIntParameter; 24 using OHOS::system::GetBoolParameter; 25 using OHOS::system::GetParameter; 26 27 namespace OHOS { 28 namespace BackgroundTaskMgr { 29 constexpr int32_t DELAY_TIME_NORMAL_DEFAULT = 3 * MSEC_PER_MIN; // 3min 30 constexpr int32_t DELAY_TIME_LOW_POWER_DEFAULT = 1 * MSEC_PER_MIN; // 1min 31 constexpr int32_t ALLOW_REQUEST_TIME_BG_DEFAULT = 5 * MSEC_PER_SEC; // 5s 32 constexpr int32_t INIT_QUOTA_DEFAULT = 10 * MSEC_PER_MIN; // 10min 33 constexpr int64_t QUOTA_UPDATE_DEFAULT = 1 * MSEC_PER_DAY; // 1day 34 35 const std::string DELAY_TIME_NOMAL_PARAM = "persist.sys.bgtask_delaytime_normal"; 36 const std::string INIT_QUOTA_PARAM = "persist.sys.bgtask_init_quota"; 37 const std::string QUOTA_UPDATE_PARAM = "persist.sys.bgtask_quota_update"; 38 const std::string TASK_KEEPING_PARAM = "bgtask.support_task_keeping"; 39 40 const int32_t DELAY_TIME_NORMAL = GetIntParameter(DELAY_TIME_NOMAL_PARAM, DELAY_TIME_NORMAL_DEFAULT); 41 const int32_t DELAY_TIME_LOW_POWER = DELAY_TIME_LOW_POWER_DEFAULT; 42 const int32_t ALLOW_REQUEST_TIME_BG = ALLOW_REQUEST_TIME_BG_DEFAULT; 43 const int32_t INIT_QUOTA = GetIntParameter(INIT_QUOTA_PARAM, INIT_QUOTA_DEFAULT); 44 const int64_t QUOTA_UPDATE = GetIntParameter(QUOTA_UPDATE_PARAM, QUOTA_UPDATE_DEFAULT); 45 const bool SUPPORT_TASK_KEEPING = GetBoolParameter(TASK_KEEPING_PARAM, false); 46 } // namespace BackgroundTaskMgr 47 } // namespace OHOS