1 /*
2  * Copyright (c) 2023-2024 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 OHOS_DISTRIBUTED_AUDIO_SINK_HIDUMPER_H
17 #define OHOS_DISTRIBUTED_AUDIO_SINK_HIDUMPER_H
18 
19 #include <map>
20 #include <string>
21 #include <vector>
22 #include "sys/stat.h"
23 
24 #include "single_instance.h"
25 
26 namespace OHOS {
27 namespace DistributedHardware {
28 enum class HidumpFlag {
29     UNKNOWN = 0,
30     GET_HELP,
31     DUMP_AUDIO_DATA_START,
32     DUMP_AUDIO_DATA_STOP,
33 };
34 class DaudioSinkHidumper {
35     DECLARE_SINGLE_INSTANCE_BASE(DaudioSinkHidumper);
36 
37 public:
38     bool Dump(const std::vector<std::string> &args, std::string &result);
39     bool QueryDumpDataFlag();
40     DaudioSinkHidumper();
41     ~DaudioSinkHidumper();
42 
43 private:
44     void ShowHelp(std::string &result);
45     int32_t ShowIllegalInfomation(std::string &result);
46     int32_t ProcessDump(const std::string &args, std::string &result);
47 
48     int32_t StartDumpData(std::string &result);
49     int32_t StopDumpData(std::string &result);
50 
51 private:
52     bool dumpAudioDataFlag_ = false;
53     const int32_t DUMP_MAX_SIZE = 10 * 1024;
54 };
55 } // namespace DistributedHardware
56 } // namespace OHOS
57 #endif // OHOS_DISTRIBUTED_AUDIO_SINK_HIDUMPER_H