15ccb8f90Sopenharmony_ci/*
25ccb8f90Sopenharmony_ci * Copyright (c) 2021-2023 Huawei Device Co., Ltd.
35ccb8f90Sopenharmony_ci * Licensed under the Apache License, Version 2.0 (the "License");
45ccb8f90Sopenharmony_ci * you may not use this file except in compliance with the License.
55ccb8f90Sopenharmony_ci * You may obtain a copy of the License at
65ccb8f90Sopenharmony_ci *
75ccb8f90Sopenharmony_ci *     http://www.apache.org/licenses/LICENSE-2.0
85ccb8f90Sopenharmony_ci *
95ccb8f90Sopenharmony_ci * Unless required by applicable law or agreed to in writing, software
105ccb8f90Sopenharmony_ci * distributed under the License is distributed on an "AS IS" BASIS,
115ccb8f90Sopenharmony_ci * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
125ccb8f90Sopenharmony_ci * See the License for the specific language governing permissions and
135ccb8f90Sopenharmony_ci * limitations under the License.
145ccb8f90Sopenharmony_ci */
155ccb8f90Sopenharmony_ci
165ccb8f90Sopenharmony_ci#ifndef POWERMGR_POWER_MGR_PowerSaveMode_H
175ccb8f90Sopenharmony_ci#define POWERMGR_POWER_MGR_PowerSaveMode_H
185ccb8f90Sopenharmony_ci
195ccb8f90Sopenharmony_ci#include <string>
205ccb8f90Sopenharmony_ci#include <list>
215ccb8f90Sopenharmony_ci#include <map>
225ccb8f90Sopenharmony_ci
235ccb8f90Sopenharmony_ci#include "ipc_object_stub.h"
245ccb8f90Sopenharmony_ci#include "libxml/tree.h"
255ccb8f90Sopenharmony_ci#include "sp_singleton.h"
265ccb8f90Sopenharmony_ci#include "system_ability.h"
275ccb8f90Sopenharmony_ci
285ccb8f90Sopenharmony_ci#define RETURN_FLAG_FALSE (-1)
295ccb8f90Sopenharmony_ci#define SLEEP_FILTER_VALUE 102
305ccb8f90Sopenharmony_ci
315ccb8f90Sopenharmony_cinamespace OHOS {
325ccb8f90Sopenharmony_cinamespace PowerMgr {
335ccb8f90Sopenharmony_cistruct ModePolicy {
345ccb8f90Sopenharmony_ci    uint32_t id;
355ccb8f90Sopenharmony_ci    int32_t value;
365ccb8f90Sopenharmony_ci    int32_t recover_flag;
375ccb8f90Sopenharmony_ci};
385ccb8f90Sopenharmony_cienum ValueProp {
395ccb8f90Sopenharmony_ci    value,
405ccb8f90Sopenharmony_ci    recover
415ccb8f90Sopenharmony_ci};
425ccb8f90Sopenharmony_ci
435ccb8f90Sopenharmony_ciclass PowerSaveMode : public RefBase {
445ccb8f90Sopenharmony_cipublic:
455ccb8f90Sopenharmony_ci    PowerSaveMode();
465ccb8f90Sopenharmony_ci    ~PowerSaveMode()=default;
475ccb8f90Sopenharmony_ci    int32_t GetSleepTime(int32_t mode);
485ccb8f90Sopenharmony_ci    std::map<int32_t, std::list<ModePolicy>> GetPolicyCache()
495ccb8f90Sopenharmony_ci    {
505ccb8f90Sopenharmony_ci        return policyCache_;
515ccb8f90Sopenharmony_ci    }
525ccb8f90Sopenharmony_ci
535ccb8f90Sopenharmony_ciprivate:
545ccb8f90Sopenharmony_ci    std::map<int32_t, std::list<ModePolicy>> policyCache_;
555ccb8f90Sopenharmony_ci    bool StartXMlParse(std::string path);
565ccb8f90Sopenharmony_ci    std::string GetProp(const xmlNodePtr& nodePtr, const std::string& key);
575ccb8f90Sopenharmony_ci};
585ccb8f90Sopenharmony_ci} // namespace PowerMgr
595ccb8f90Sopenharmony_ci} // namespace OHOS
605ccb8f90Sopenharmony_ci#endif // POWERMGR_POWER_MGR_PowerSaveMode_H
61