166f3657fSopenharmony_ci/*
266f3657fSopenharmony_ci * Copyright (c) 2023 Huawei Device Co., Ltd.
366f3657fSopenharmony_ci * Licensed under the Apache License, Version 2.0 (the "License");
466f3657fSopenharmony_ci * you may not use this file except in compliance with the License.
566f3657fSopenharmony_ci * You may obtain a copy of the License at
666f3657fSopenharmony_ci *
766f3657fSopenharmony_ci *     http://www.apache.org/licenses/LICENSE-2.0
866f3657fSopenharmony_ci *
966f3657fSopenharmony_ci * Unless required by applicable law or agreed to in writing, software
1066f3657fSopenharmony_ci * distributed under the License is distributed on an "AS IS" BASIS,
1166f3657fSopenharmony_ci * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1266f3657fSopenharmony_ci * See the License for the specific language governing permissions and
1366f3657fSopenharmony_ci * limitations under the License.
1466f3657fSopenharmony_ci */
1566f3657fSopenharmony_ci
1666f3657fSopenharmony_ci#ifndef OHOS_DISTRIBUTED_SCREEN_HIDUMPER_H
1766f3657fSopenharmony_ci#define OHOS_DISTRIBUTED_SCREEN_HIDUMPER_H
1866f3657fSopenharmony_ci
1966f3657fSopenharmony_ci#include <unistd.h>
2066f3657fSopenharmony_ci#include <sys/types.h>
2166f3657fSopenharmony_ci#include <sys/stat.h>
2266f3657fSopenharmony_ci
2366f3657fSopenharmony_ci#include <cstdio>
2466f3657fSopenharmony_ci#include <fstream>
2566f3657fSopenharmony_ci#include <map>
2666f3657fSopenharmony_ci#include <string>
2766f3657fSopenharmony_ci#include <vector>
2866f3657fSopenharmony_ci
2966f3657fSopenharmony_ci#include "single_instance.h"
3066f3657fSopenharmony_ci#include "dscreen_constants.h"
3166f3657fSopenharmony_ci
3266f3657fSopenharmony_cinamespace OHOS {
3366f3657fSopenharmony_cinamespace DistributedHardware {
3466f3657fSopenharmony_cienum class HidumpFlag {
3566f3657fSopenharmony_ci    UNKNOWN = 0,
3666f3657fSopenharmony_ci    GET_HELP,
3766f3657fSopenharmony_ci    DUMP_SCREEN_DATA,
3866f3657fSopenharmony_ci    DUMP_SCREEN_DATA_RESTART,
3966f3657fSopenharmony_ci    DUMP_SCREEN_DATA_STOP,
4066f3657fSopenharmony_ci};
4166f3657fSopenharmony_ci
4266f3657fSopenharmony_ciclass DscreenHidumper {
4366f3657fSopenharmony_ci    DECLARE_SINGLE_INSTANCE_BASE(DscreenHidumper);
4466f3657fSopenharmony_ci
4566f3657fSopenharmony_cipublic:
4666f3657fSopenharmony_ci    bool Dump(const std::vector<std::string> &args, std::string &result);
4766f3657fSopenharmony_ci    bool GetFlagStatus();
4866f3657fSopenharmony_ci    void SetFlagFalse();
4966f3657fSopenharmony_ci    bool GetFileFlag();
5066f3657fSopenharmony_ci    bool GetReDumpFlag();
5166f3657fSopenharmony_ci    void SetFileFlagFalse();
5266f3657fSopenharmony_ci    void SetFileFlagTrue();
5366f3657fSopenharmony_ci    void SetReDumpFlagFalse();
5466f3657fSopenharmony_ci    void SetReDumpFlagTrue();
5566f3657fSopenharmony_ci    bool GetTransReDumpFlag();
5666f3657fSopenharmony_ci    void SetTransReDumpFlagFalse();
5766f3657fSopenharmony_ci    void SetTransReDumpFlagTrue();
5866f3657fSopenharmony_ci    void SaveFile(std::string file, const VideoData &video);
5966f3657fSopenharmony_ci    DscreenHidumper();
6066f3657fSopenharmony_ci    ~DscreenHidumper();
6166f3657fSopenharmony_ci
6266f3657fSopenharmony_ciprivate:
6366f3657fSopenharmony_ci    void ShowHelp(std::string &result);
6466f3657fSopenharmony_ci    int32_t ShowIllegalInfomation(std::string &result);
6566f3657fSopenharmony_ci    int32_t ProcessDump(const std::string &args, std::string &result);
6666f3657fSopenharmony_ci
6766f3657fSopenharmony_ci    int32_t DumpScreenData(std::string &result);
6866f3657fSopenharmony_ci    int32_t ReDumpScreenData(std::string &result);
6966f3657fSopenharmony_ci
7066f3657fSopenharmony_ciprivate:
7166f3657fSopenharmony_ci    static const constexpr char *DSCREEN_LOG_TAG = "DscreenHidumper";
7266f3657fSopenharmony_ci    bool hidumperFlag_ = false;
7366f3657fSopenharmony_ci    bool fileFullFlag_ = false;
7466f3657fSopenharmony_ci    bool reDumpFlag_ = false;
7566f3657fSopenharmony_ci    bool transReDumpFlag_ = false;
7666f3657fSopenharmony_ci};
7766f3657fSopenharmony_ci} // namespace DistributedHardware
7866f3657fSopenharmony_ci} // namespace OHOS
7966f3657fSopenharmony_ci#endif // OHOS_DISTRIBUTED_SCREEN_HIDUMPER_H