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#ifndef UPDATE_SERVICE_CACHE_H
17#define UPDATE_SERVICE_CACHE_H
18
19#include <cstdint>
20
21#include "business_sub_type.h"
22#include "upgrade_info.h"
23#include "upgrade_interval.h"
24
25namespace OHOS {
26namespace UpdateEngine {
27class UpdateServiceCache {
28public:
29    static UpgradeInfo GetUpgradeInfo(BusinessSubType businessSubType);
30    static void SetUpgradeInfo(const UpgradeInfo &upgradeInfo);
31    static uint64_t GetCheckInterval(BusinessSubType businessSubType);
32    static void SetCheckInterval(BusinessSubType businessSubType, uint64_t interval);
33    static uint64_t GetDownloadInterval(BusinessSubType businessSubType);
34    static void SetDownloadInterval(BusinessSubType businessSubType, uint64_t interval);
35    static UpgradeInterval GetUpgradeInterval(BusinessSubType businessSubType);
36    static void SetUpgradeStartTime(BusinessSubType businessSubType, uint64_t time);
37    static void SetUpgradeEndTime(BusinessSubType businessSubType, uint64_t time);
38
39private:
40    static bool IsTypelegal(BusinessSubType businessSubType);
41    static bool IsParamType(BusinessSubType businessSubType);
42
43    static UpgradeInfo upgradeInfo_;
44    static uint64_t checkInterval_;
45    static uint64_t downloadInterval_;
46    static UpgradeInterval upgradeInterval_;
47
48    static UpgradeInfo paramUpgradeInfo_;
49    static uint64_t paramCheckInterval_;
50    static uint64_t paramDownloadInterval_;
51    static UpgradeInterval paramUpgradeInterval_;
52};
53} // namespace UpdateEngine
54} // namespace OHOS
55#endif // UPDATE_SERVICE_CACHE_H