Skip to content

Commit 6b51204

Browse files
author
Arpit Singh
committed
Add display topology to input dump
Add display topology to dump in Dispatcher and Choreographer for debugging. Bug: 245989146 Test: dumpsys input Flag: EXEMPT log only update Change-Id: I8e9eb4d5c3c88e1cb6aeaa35db07006b003aad93
1 parent 269580e commit 6b51204

4 files changed

Lines changed: 48 additions & 0 deletions

File tree

include/input/DisplayTopologyGraph.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,8 @@ struct DisplayTopologyAdjacentDisplay {
4646
DisplayTopologyPosition position;
4747
// The offset in DP of the adjacent display, relative to the source display.
4848
float offsetDp;
49+
50+
std::string dump() const;
4951
};
5052

5153
/**
@@ -57,6 +59,7 @@ struct DisplayTopologyGraph {
5759
std::unordered_map<ui::LogicalDisplayId, int> displaysDensity;
5860

5961
bool isValid() const;
62+
std::string dump() const;
6063
};
6164

6265
} // namespace android

libs/input/DisplayTopologyGraph.cpp

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,15 +17,20 @@
1717
#define LOG_TAG "DisplayTopologyValidator"
1818

1919
#include <android-base/logging.h>
20+
#include <android-base/stringprintf.h>
2021
#include <ftl/enum.h>
2122
#include <input/DisplayTopologyGraph.h>
23+
#include <input/PrintTools.h>
2224
#include <ui/LogicalDisplayId.h>
2325

2426
#include <algorithm>
2527

28+
#define INDENT " "
29+
2630
namespace android {
2731

2832
namespace {
33+
2934
DisplayTopologyPosition getOppositePosition(DisplayTopologyPosition position) {
3035
switch (position) {
3136
case DisplayTopologyPosition::LEFT:
@@ -95,11 +100,45 @@ bool validateDensities(const android::DisplayTopologyGraph& displayTopologyGraph
95100
return true;
96101
}
97102

103+
std::string logicalDisplayIdToString(const ui::LogicalDisplayId& displayId) {
104+
return base::StringPrintf("displayId(%d)", displayId.val());
105+
}
106+
107+
std::string adjacentDisplayToString(const DisplayTopologyAdjacentDisplay& adjacentDisplay) {
108+
return adjacentDisplay.dump();
109+
}
110+
111+
std::string adjacentDisplayVectorToString(
112+
const std::vector<DisplayTopologyAdjacentDisplay>& adjacentDisplays) {
113+
return dumpVector(adjacentDisplays, adjacentDisplayToString);
114+
}
115+
98116
} // namespace
99117

118+
std::string DisplayTopologyAdjacentDisplay::dump() const {
119+
std::string dump;
120+
dump += base::StringPrintf("DisplayTopologyAdjacentDisplay: {displayId: %d, position: %s, "
121+
"offsetDp: %f}",
122+
displayId.val(), ftl::enum_string(position).c_str(), offsetDp);
123+
return dump;
124+
}
125+
100126
bool DisplayTopologyGraph::isValid() const {
101127
return validatePrimaryDisplay(*this) && validateTopologyGraph(*this) &&
102128
validateDensities(*this);
103129
}
104130

131+
std::string DisplayTopologyGraph::dump() const {
132+
std::string dump;
133+
dump += base::StringPrintf("PrimaryDisplayId: %d\n", primaryDisplayId.val());
134+
dump += base::StringPrintf("TopologyGraph:\n");
135+
dump += addLinePrefix(dumpMap(graph, logicalDisplayIdToString, adjacentDisplayVectorToString),
136+
INDENT);
137+
dump += "\n";
138+
dump += base::StringPrintf("DisplaysDensity:\n");
139+
dump += addLinePrefix(dumpMap(displaysDensity, logicalDisplayIdToString), INDENT);
140+
dump += "\n";
141+
return dump;
142+
}
143+
105144
} // namespace android

services/inputflinger/PointerChoreographer.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
#include "PointerChoreographer.h"
3232

3333
#define INDENT " "
34+
#define INDENT2 " "
3435

3536
namespace android {
3637

@@ -647,6 +648,8 @@ void PointerChoreographer::dump(std::string& dump) {
647648
std::string pointerControllerDump = addLinePrefix(drawingTabletController->dump(), INDENT);
648649
dump += INDENT + std::to_string(deviceId) + " : " + pointerControllerDump;
649650
}
651+
dump += INDENT "DisplayTopologyGraph:\n";
652+
dump += addLinePrefix(mTopology.dump(), INDENT2);
650653
dump += "\n";
651654
}
652655

services/inputflinger/dispatcher/InputDispatcher.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5222,6 +5222,9 @@ std::string InputDispatcher::DispatcherWindowInfo::dumpDisplayAndWindowInfo() co
52225222
} else {
52235223
dump += "Displays: <none>\n";
52245224
}
5225+
dump += "DisplayTopologyGraph:\n";
5226+
dump += addLinePrefix(mTopology.dump(), INDENT);
5227+
dump += "\n";
52255228
return dump;
52265229
}
52275230

0 commit comments

Comments
 (0)