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 OHOS_ROSEN_WINDOW_DUMPER_H
17 #define OHOS_ROSEN_WINDOW_DUMPER_H
18 
19 #include "dm_common.h"
20 #include "future.h"
21 #include "window_root.h"
22 
23 namespace OHOS {
24 namespace Rosen {
25 enum DumpType : uint32_t {
26     DUMP_ALL = 0,
27     DUMP_WINDOW,
28     DUMP_NONE = 100,
29 };
30 class WindowDumper : public RefBase {
31 public:
WindowDumper(const sptr<WindowRoot> & root)32     explicit WindowDumper(const sptr<WindowRoot>& root) : windowRoot_(root) {}
33     WMError Dump(int fd, const std::vector<std::u16string>& args);
34 
35     RunnableFuture<std::vector<std::string>> dumpInfoFuture_;
36 
37 private:
38     WMError DumpWindowInfo(const std::vector<std::string>& args, std::string& dumpInfo);
39     WMError DumpAllWindowInfo(std::string& dumpInfo);
40     WMError DumpScreenGroupWindowInfo(ScreenId screenGroupId, const sptr<WindowNodeContainer>& windowNodeContainer,
41         std::string& dumpInfo);
42     void AppendWindowNodeInfo(const sptr<WindowNode>& windowNode, int zOrder, std::ostringstream& oss);
43     bool IsValidDigitString(const std::string& windowIdStr);
44     WMError DumpSpecifiedWindowInfo(uint32_t windowId, const std::vector<std::string>& params,
45         std::string& dumpInfo);
46     void AppendSpecifiedWindowNodeInfo(const sptr<WindowNode>& node, std::ostringstream& oss);
47     void ShowHelpInfo(std::string& dumpInfo);
48     void ShowAceDumpHelp(std::string& dumpInfo);
49     void ShowIllegalArgsInfo(std::string& dumpInfo, WMError errCode);
50     const sptr<WindowRoot> windowRoot_;
51 };
52 }
53 }
54 #endif // OHOS_ROSEN_WINDOW_DUMPER_H