Merge "Add layer filter to winscope" into rvc-dev

This commit is contained in:
TreeHugger Robot
2020-03-31 01:21:56 +00:00
committed by Android (Google) Code Review
2 changed files with 35 additions and 29 deletions

View File

@@ -27,6 +27,7 @@
<h2 class="md-title" style="flex: 1;">Hierarchy</h2>
<md-checkbox v-model="store.onlyVisible">Only visible</md-checkbox>
<md-checkbox v-model="store.flattened">Flat</md-checkbox>
<input id="filter" type="search" placeholder="Filter..." v-model="hierarchyPropertyFilterString" />
</md-whiteframe>
<tree-view class="data-card" :item="tree" @item-selected="itemSelected" :selected="hierarchySelected" :filter="hierarchyFilter" :flattened="store.flattened" ref="hierarchy" />
</md-card>
@@ -93,6 +94,7 @@ export default {
data() {
return {
propertyFilterString: "",
hierarchyPropertyFilterString:"",
selectedTree: {},
hierarchySelected: null,
lastSelectedStableId: null,
@@ -170,30 +172,12 @@ export default {
return this.file.selectedIndex;
},
hierarchyFilter() {
return this.store.onlyVisible ? (c, flattened) => {
return c.visible || c.childrenVisible && !flattened;
} : null;
var hierarchyPropertyFilter = getFilter(this.hierarchyPropertyFilterString);
return this.store.onlyVisible ? (c) => {
return c.visible && hierarchyPropertyFilter(c);} : hierarchyPropertyFilter;
},
propertyFilter() {
var filterStrings = this.propertyFilterString.split(",");
var positive = [];
var negative = [];
filterStrings.forEach((f) => {
if (f.startsWith("!")) {
var str = f.substring(1);
negative.push((s) => s.indexOf(str) === -1);
} else {
var str = f;
positive.push((s) => s.indexOf(str) !== -1);
}
});
var filter = (item) => {
var apply = (f) => f(item.name);
return (positive.length === 0 || positive.some(apply)) &&
(negative.length === 0 || negative.every(apply));
};
filter.includeChildren = true;
return filter;
return getFilter(this.propertyFilterString);
},
hasScreenView() {
return this.file.type !== DATA_TYPES.TRANSACTION;
@@ -205,6 +189,27 @@ export default {
}
}
function getFilter(filterString) {
var filterStrings = filterString.split(",");
var positive = [];
var negative = [];
filterStrings.forEach((f) => {
if (f.startsWith("!")) {
var str = f.substring(1);
negative.push((s) => s.indexOf(str) === -1);
} else {
var str = f;
positive.push((s) => s.indexOf(str) !== -1);
}
});
var filter = (item) => {
var apply = (f) => f(String(item.name));
return (positive.length === 0 || positive.some(apply)) &&
(negative.length === 0 || negative.every(apply));
};
return filter;
}
</script>
<style>
.rects {

View File

@@ -30,10 +30,6 @@ import jsonProtoDefs from 'frameworks/base/core/proto/android/server/windowmanag
import protobuf from 'protobufjs'
var protoDefs = protobuf.Root.fromJSON(jsonProtoDefs);
var TraceMessage = protoDefs.lookupType(
"com.android.server.wm.WindowManagerTraceFileProto");
var ServiceMessage = protoDefs.lookupType(
"com.android.server.wm.WindowManagerServiceDumpProto");
export default {
name: 'tree-view',
@@ -84,14 +80,19 @@ export default {
];
},
filterMatches(c) {
// If a filter is set, consider the item matches if the current item or any of its
// children matches.
if (this.filter) {
return this.filter(c, this.applyingFlattened);
var thisMatches = this.filter(c);
const childMatches = (child) => this.filterMatches(child);
return thisMatches || (!this.applyingFlattened &&
c.children && c.children.some(childMatches));
}
return true;
},
childFilter(c) {
if (this.filter && this.filter.includeChildren) {
if (this.filterMatches(c)) {
if (this.filter) {
if (this.filter(c)) {
// Filter matched c, don't apply further filtering on c's children.
return undefined;
}