Merge "Make winscope compatible with flickerlib constructors" into sc-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
471c1da8dc
@@ -85,11 +85,59 @@ export default {
|
||||
};
|
||||
},
|
||||
methods: {
|
||||
// Recursively search for an arrowUp method in the children
|
||||
// This is necessary because the VueComponent hierarchy has
|
||||
// different depths depending on the source
|
||||
depthFirstSearchArrowUp(component) {
|
||||
if (component.arrowUp) {
|
||||
component.arrowUp();
|
||||
return true;
|
||||
} else {
|
||||
for (let i = 0; i < component.$children.length; i++) {
|
||||
var child = component.$children[i];
|
||||
if (this.depthFirstSearchArrowUp(child)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
},
|
||||
// Recursively search for an arrowUp method in the children
|
||||
// This is necessary because the VueComponent hierarchy has
|
||||
// different depths depending on the source
|
||||
depthFirstSearchArrowDown(component) {
|
||||
if (component.arrowDown) {
|
||||
component.arrowDown();
|
||||
return true
|
||||
} else {
|
||||
for (let i = 0; i < component.$children.length; i++) {
|
||||
var child = component.$children[i];
|
||||
if (this.depthFirstSearchArrowDown(child)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
},
|
||||
arrowUp() {
|
||||
return this.$refs.view.arrowUp();
|
||||
for (let i = 0; i < this.$children.length; i++) {
|
||||
var child = this.$children[i];
|
||||
let done = this.depthFirstSearchArrowUp(child);
|
||||
if (done) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
},
|
||||
arrowDown() {
|
||||
return this.$refs.view.arrowDown();
|
||||
for (let i = 0; i < this.$children.length; i++) {
|
||||
var child = this.$children[i];
|
||||
let done = this.depthFirstSearchArrowDown(child);
|
||||
if (done) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
},
|
||||
onClick(e) {
|
||||
// Pass click event to parent, so that click event handler can be attached
|
||||
|
||||
@@ -56,7 +56,11 @@ export default {
|
||||
bottom: this.boundsC.height});
|
||||
},
|
||||
filteredRects() {
|
||||
return this.rects.filter((rect) => rect.ref.visible);
|
||||
return this.rects.filter((rect) => {
|
||||
const isVisible = rect.ref.visible ?? rect.ref.isVisible;
|
||||
console.warn(`Name: ${rect.ref.name} Kind: ${rect.ref.kind} isVisible=${isVisible}`);
|
||||
return isVisible;
|
||||
});
|
||||
},
|
||||
},
|
||||
methods: {
|
||||
|
||||
@@ -61,6 +61,8 @@ WindowManagerState.fromProto = function ({proto, timestamp = 0, where = ""}): Wi
|
||||
entry.chips = []
|
||||
entry.visible = true
|
||||
entry.rawTreeViewObject = asRawTreeViewObject(entry)
|
||||
|
||||
console.warn("Created ", entry.kind, " stableId=", entry.stableId)
|
||||
return entry
|
||||
}
|
||||
|
||||
@@ -83,15 +85,15 @@ function newWindowManagerPolicy(proto): WindowManagerPolicy {
|
||||
}
|
||||
|
||||
function newRootWindowContainer(proto): RootWindowContainer {
|
||||
const windowContainer = WindowContainer.fromProto({proto: proto.windowContainer})
|
||||
const children = proto.windowContainer.children.reverse()
|
||||
.mapNotNull(it => WindowContainer.childrenFromProto(it, /* isActivityInTree */ false))
|
||||
const windowContainer = WindowContainer.fromProto(
|
||||
{proto: proto.windowContainer, children: children})
|
||||
if (windowContainer == null) {
|
||||
throw "Window container should not be null: " + JSON.stringify(proto)
|
||||
}
|
||||
const entry = new RootWindowContainer(windowContainer)
|
||||
proto.windowContainer.children.reverse()
|
||||
.map(it => WindowContainer.childrenFromProto(entry, it, /* isActivityInTree */ false))
|
||||
.filter(it => it != null)
|
||||
.forEach(it => windowContainer.childContainers.push(it))
|
||||
|
||||
return entry
|
||||
}
|
||||
|
||||
|
||||
@@ -24,8 +24,8 @@ WindowManagerTrace.fromProto = function (proto) {
|
||||
proto: entryProto.windowManagerService,
|
||||
timestamp: entryProto.elapsedRealtimeNanos,
|
||||
where: entryProto.where})
|
||||
entries.push(transformedEntry)
|
||||
|
||||
entries.push(transformedEntry)
|
||||
}
|
||||
const source = null
|
||||
const sourceChecksum = null
|
||||
|
||||
@@ -42,8 +42,6 @@ const WindowConfiguration = require('flicker').com.android.server.wm.traces.comm
|
||||
windowmanager.windows.WindowConfiguration;
|
||||
const WindowContainer = require('flicker').com.android.server.wm.traces.common.
|
||||
windowmanager.windows.WindowContainer;
|
||||
const WindowContainerChild = require('flicker').com.android.server.wm.traces.common.
|
||||
windowmanager.windows.WindowContainerChild;
|
||||
const WindowManagerPolicy = require('flicker').com.android.server.wm.traces.common.
|
||||
windowmanager.windows.WindowManagerPolicy;
|
||||
const WindowState = require('flicker').com.android.server.wm.traces.common.
|
||||
@@ -56,10 +54,9 @@ const Bounds = require('flicker').com.android.server.wm.traces.common.Bounds;
|
||||
|
||||
function toRect(proto) {
|
||||
if (proto == null) {
|
||||
return new Rect(0, 0, 0, 0)
|
||||
} else {
|
||||
return new Rect(proto.left, proto.top, proto.right, proto.bottom)
|
||||
return null
|
||||
}
|
||||
return new Rect(proto.left, proto.top, proto.right, proto.bottom)
|
||||
}
|
||||
|
||||
export {
|
||||
@@ -73,7 +70,6 @@ export {
|
||||
RootWindowContainer,
|
||||
WindowConfiguration,
|
||||
WindowContainer,
|
||||
WindowContainerChild,
|
||||
WindowState,
|
||||
WindowToken,
|
||||
WindowManagerPolicy,
|
||||
|
||||
@@ -29,6 +29,7 @@ export function getWMPropertiesForDisplay(proto: any): any {
|
||||
if (obj.windowToken) delete obj.windowToken
|
||||
if (obj.rootDisplayArea) delete obj.rootDisplayArea
|
||||
if (obj.rootWindowContainer) delete obj.rootWindowContainer
|
||||
if (obj.windowContainer?.children) delete obj.windowContainer.children
|
||||
return obj
|
||||
}
|
||||
|
||||
|
||||
@@ -19,12 +19,14 @@ import { asRawTreeViewObject } from '../../utils/diff.js'
|
||||
import { Activity } from "../common"
|
||||
import WindowContainer from "./WindowContainer"
|
||||
|
||||
Activity.fromProto = function (proto, parent: WindowContainer): Activity {
|
||||
Activity.fromProto = function (proto): Activity {
|
||||
if (proto == null) {
|
||||
return null
|
||||
} else {
|
||||
const children = proto.windowToken.windowContainer.children.reverse()
|
||||
.mapNotNull(it => WindowContainer.childrenFromProto(it, /* isActivityInTree */ true))
|
||||
const windowContainer = WindowContainer.fromProto({proto: proto.windowToken.windowContainer,
|
||||
identifierOverride: proto.identifier})
|
||||
children: children, identifierOverride: proto.identifier})
|
||||
if (windowContainer == null) {
|
||||
throw "Window container should not be null: " + JSON.stringify(proto)
|
||||
}
|
||||
@@ -35,19 +37,15 @@ Activity.fromProto = function (proto, parent: WindowContainer): Activity {
|
||||
proto.frontOfTask,
|
||||
proto.procId,
|
||||
proto.translucent,
|
||||
parent,
|
||||
windowContainer
|
||||
)
|
||||
|
||||
proto.windowToken.windowContainer.children.reverse()
|
||||
.map(it => WindowContainer.childrenFromProto(entry, it, /* isActivityInTree */ true))
|
||||
.filter(it => it != null)
|
||||
.forEach(it => windowContainer.childContainers.push(it))
|
||||
|
||||
entry.obj = getWMPropertiesForDisplay(proto)
|
||||
entry.shortName = shortenName(entry.name)
|
||||
entry.children = entry.childrenWindows
|
||||
entry.rawTreeViewObject = asRawTreeViewObject(entry)
|
||||
|
||||
console.warn("Created ", entry.kind, " stableId=", entry.stableId)
|
||||
return entry
|
||||
}
|
||||
}
|
||||
|
||||
@@ -23,7 +23,10 @@ ActivityTask.fromProto = function (proto, isActivityInTree: Boolean): ActivityTa
|
||||
if (proto == null) {
|
||||
return null
|
||||
} else {
|
||||
const windowContainer = WindowContainer.fromProto({proto: proto.windowContainer})
|
||||
const children = proto.windowContainer.children.reverse()
|
||||
.mapNotNull(it => WindowContainer.childrenFromProto(it, isActivityInTree))
|
||||
const windowContainer = WindowContainer.fromProto({proto: proto.windowContainer,
|
||||
children: children})
|
||||
if (windowContainer == null) {
|
||||
throw "Window container should not be null: " + JSON.stringify(proto)
|
||||
}
|
||||
@@ -48,15 +51,12 @@ ActivityTask.fromProto = function (proto, isActivityInTree: Boolean): ActivityTa
|
||||
windowContainer
|
||||
)
|
||||
|
||||
proto.windowContainer.children.reverse()
|
||||
.map(it => WindowContainer.childrenFromProto(entry, it, isActivityInTree))
|
||||
.filter(it => it != null)
|
||||
.forEach(it => windowContainer.childContainers.push(it))
|
||||
|
||||
entry.obj = getWMPropertiesForDisplay(proto)
|
||||
entry.shortName = shortenName(entry.name)
|
||||
entry.children = entry.childrenWindows
|
||||
entry.rawTreeViewObject = asRawTreeViewObject(entry)
|
||||
|
||||
console.warn("Created ", entry.kind, " stableId=", entry.stableId)
|
||||
return entry
|
||||
}
|
||||
}
|
||||
|
||||
@@ -23,21 +23,21 @@ DisplayArea.fromProto = function (proto, isActivityInTree: Boolean): DisplayArea
|
||||
if (proto == null) {
|
||||
return null
|
||||
} else {
|
||||
const windowContainer = WindowContainer.fromProto({proto: proto.windowContainer, nameOverride: proto.name})
|
||||
const children = proto.windowContainer.children.reverse()
|
||||
.mapNotNull(it => WindowContainer.childrenFromProto(it, isActivityInTree))
|
||||
const windowContainer = WindowContainer.fromProto({proto: proto.windowContainer,
|
||||
children: children, nameOverride: proto.name})
|
||||
if (windowContainer == null) {
|
||||
throw "Window container should not be null: " + JSON.stringify(proto)
|
||||
}
|
||||
const entry = new DisplayArea(proto.isTaskDisplayArea, windowContainer)
|
||||
|
||||
proto.windowContainer.children.reverse()
|
||||
.map(it => WindowContainer.childrenFromProto(entry, it, isActivityInTree))
|
||||
.filter(it => it != null)
|
||||
.forEach(it => windowContainer.childContainers.push(it))
|
||||
|
||||
entry.obj = getWMPropertiesForDisplay(proto)
|
||||
entry.shortName = shortenName(entry.name)
|
||||
entry.children = entry.childrenWindows
|
||||
entry.rawTreeViewObject = asRawTreeViewObject(entry)
|
||||
|
||||
console.warn("Created ", entry.kind, " stableId=", entry.stableId)
|
||||
return entry
|
||||
}
|
||||
}
|
||||
|
||||
@@ -23,8 +23,10 @@ DisplayContent.fromProto = function (proto, isActivityInTree: Boolean): DisplayC
|
||||
if (proto == null) {
|
||||
return null
|
||||
} else {
|
||||
const children = proto.rootDisplayArea.windowContainer.children.reverse()
|
||||
.mapNotNull(it => WindowContainer.childrenFromProto(it, isActivityInTree))
|
||||
const windowContainer = WindowContainer.fromProto({proto: proto.rootDisplayArea.windowContainer,
|
||||
nameOverride: proto.displayInfo?.name ?? null})
|
||||
children: children, nameOverride: proto.displayInfo?.name ?? null})
|
||||
if (windowContainer == null) {
|
||||
throw "Window container should not be null: " + JSON.stringify(proto)
|
||||
}
|
||||
@@ -58,15 +60,12 @@ DisplayContent.fromProto = function (proto, isActivityInTree: Boolean): DisplayC
|
||||
windowContainer
|
||||
)
|
||||
|
||||
proto.rootDisplayArea.windowContainer.children.reverse()
|
||||
.map(it => WindowContainer.childrenFromProto(entry, it, isActivityInTree))
|
||||
.filter(it => it != null)
|
||||
.forEach(it => windowContainer.childContainers.push(it))
|
||||
|
||||
entry.obj = getWMPropertiesForDisplay(proto)
|
||||
entry.shortName = shortenName(entry.name)
|
||||
entry.children = entry.childrenWindows
|
||||
entry.rawTreeViewObject = asRawTreeViewObject(entry)
|
||||
|
||||
console.warn("Created ", entry.kind, " stableId=", entry.stableId)
|
||||
return entry
|
||||
}
|
||||
}
|
||||
|
||||
@@ -35,45 +35,45 @@ import WindowToken from "./WindowToken"
|
||||
|
||||
WindowContainer.fromProto = function ({
|
||||
proto,
|
||||
children,
|
||||
nameOverride = null,
|
||||
identifierOverride = null,
|
||||
tokenOverride = null
|
||||
}): WindowContainer {
|
||||
if (proto == null) {
|
||||
return null
|
||||
} else {
|
||||
const identifier = identifierOverride ?? proto.identifier
|
||||
var name = nameOverride ?? identifier?.title ?? ""
|
||||
var token = tokenOverride?.toString(16) ?? identifier?.hashCode?.toString(16) ?? ""
|
||||
|
||||
const entry = new WindowContainer(
|
||||
name,
|
||||
token,
|
||||
proto.orientation,
|
||||
proto.visible,
|
||||
newConfigurationContainer(proto.configurationContainer)
|
||||
)
|
||||
|
||||
// we remove the children property from the object to avoid it showing the
|
||||
// the properties view of the element as we can always see those elements'
|
||||
// properties by changing the target element in the hierarchy tree view.
|
||||
entry.obj = getWMPropertiesForDisplay(proto)
|
||||
entry.shortName = shortenName(entry.name)
|
||||
entry.rawTreeViewObject = asRawTreeViewObject(entry)
|
||||
return entry
|
||||
}
|
||||
const identifier = identifierOverride ?? proto.identifier
|
||||
var name = nameOverride ?? identifier?.title ?? ""
|
||||
var token = tokenOverride?.toString(16) ?? identifier?.hashCode?.toString(16) ?? ""
|
||||
|
||||
const config = newConfigurationContainer(proto.configurationContainer)
|
||||
const entry = new WindowContainer(
|
||||
name,
|
||||
token,
|
||||
proto.orientation,
|
||||
proto.visible,
|
||||
config,
|
||||
children
|
||||
)
|
||||
|
||||
// we remove the children property from the object to avoid it showing the
|
||||
// the properties view of the element as we can always see those elements'
|
||||
// properties by changing the target element in the hierarchy tree view.
|
||||
entry.obj = getWMPropertiesForDisplay(proto)
|
||||
entry.shortName = shortenName(entry.name)
|
||||
entry.rawTreeViewObject = asRawTreeViewObject(entry)
|
||||
return entry
|
||||
}
|
||||
|
||||
WindowContainer.childrenFromProto = function(parent: WindowContainer, proto, isActivityInTree: Boolean): WindowContainerChild {
|
||||
return new WindowContainerChild(
|
||||
DisplayContent.fromProto(proto.displayContent, isActivityInTree),
|
||||
DisplayArea.fromProto(proto.displayArea, isActivityInTree),
|
||||
ActivityTask.fromProto(proto.task, isActivityInTree),
|
||||
Activity.fromProto(proto.activity, parent),
|
||||
WindowToken.fromProto(proto.windowToken, isActivityInTree),
|
||||
WindowState.fromProto(proto.window, isActivityInTree),
|
||||
WindowContainer.childrenFromProto = function(proto, isActivityInTree: Boolean): WindowContainerChild {
|
||||
return DisplayContent.fromProto(proto.displayContent, isActivityInTree) ??
|
||||
DisplayArea.fromProto(proto.displayArea, isActivityInTree) ??
|
||||
ActivityTask.fromProto(proto.task, isActivityInTree) ??
|
||||
Activity.fromProto(proto.activity) ??
|
||||
WindowToken.fromProto(proto.windowToken, isActivityInTree) ??
|
||||
WindowState.fromProto(proto.window, isActivityInTree) ??
|
||||
WindowContainer.fromProto({proto: proto.windowContainer})
|
||||
)
|
||||
}
|
||||
|
||||
function newConfigurationContainer(proto): ConfigurationContainer {
|
||||
@@ -89,6 +89,9 @@ function newConfigurationContainer(proto): ConfigurationContainer {
|
||||
}
|
||||
|
||||
function newConfiguration(proto): Configuration {
|
||||
if (proto == null) {
|
||||
return null
|
||||
}
|
||||
var windowConfiguration = null
|
||||
|
||||
if (proto != null && proto.windowConfiguration != null) {
|
||||
|
||||
@@ -42,19 +42,18 @@ import WindowContainer from "./WindowContainer"
|
||||
nameOverride = identifierName.substring(WindowState.DEBUGGER_WINDOW_PREFIX.length)
|
||||
}
|
||||
|
||||
const children = proto.windowContainer.children.reverse()
|
||||
.mapNotNull(it => WindowContainer.childrenFromProto(it, isActivityInTree))
|
||||
|
||||
const windowContainer = WindowContainer.fromProto({
|
||||
proto: proto.windowContainer,
|
||||
children: children,
|
||||
nameOverride: nameOverride,
|
||||
identifierOverride: proto.identifier})
|
||||
if (windowContainer == null) {
|
||||
throw "Window container should not be null: " + JSON.stringify(proto)
|
||||
}
|
||||
|
||||
proto.windowContainer.children.reverse()
|
||||
.map(it => WindowContainer.childrenFromProto(entry, it, isActivityInTree))
|
||||
.filter(it => it != null)
|
||||
.forEach(it => windowContainer.childContainers.push(it))
|
||||
|
||||
const entry = new WindowState(
|
||||
proto.attributes?.type ?? 0,
|
||||
proto.displayId,
|
||||
@@ -74,6 +73,7 @@ import WindowContainer from "./WindowContainer"
|
||||
/* isAppWindow */ isActivityInTree
|
||||
)
|
||||
|
||||
entry.rects.map((rect) => rect.ref = entry)
|
||||
entry.obj = getWMPropertiesForDisplay(proto)
|
||||
entry.shortName = shortenName(entry.name)
|
||||
entry.visible = entry.isSurfaceShown ?? false
|
||||
|
||||
@@ -22,24 +22,23 @@ import WindowContainer from "./WindowContainer"
|
||||
WindowToken.fromProto = function (proto, isActivityInTree: Boolean): WindowToken {
|
||||
if (proto == null) {
|
||||
return null
|
||||
} else {
|
||||
const windowContainer = WindowContainer.fromProto({proto: proto.windowContainer, tokenOverride: proto.hashCode})
|
||||
if (windowContainer == null) {
|
||||
throw "Window container should not be null: " + JSON.stringify(proto)
|
||||
}
|
||||
const entry = new WindowToken(windowContainer)
|
||||
|
||||
proto.windowContainer.children.reverse()
|
||||
.map(it => WindowContainer.childrenFromProto(entry, it, isActivityInTree))
|
||||
.filter(it => it != null)
|
||||
.forEach(it => windowContainer.childContainers.push(it))
|
||||
|
||||
entry.obj = getWMPropertiesForDisplay(proto)
|
||||
entry.shortName = shortenName(entry.name)
|
||||
entry.children = entry.childrenWindows
|
||||
entry.rawTreeViewObject = asRawTreeViewObject(entry)
|
||||
return entry
|
||||
}
|
||||
|
||||
const children = proto.windowContainer.children.reverse()
|
||||
.mapNotNull(it => WindowContainer.childrenFromProto(it, isActivityInTree))
|
||||
const windowContainer = WindowContainer.fromProto({proto: proto.windowContainer,
|
||||
children: children, tokenOverride: proto.hashCode})
|
||||
if (windowContainer == null) {
|
||||
throw "Window container should not be null: " + JSON.stringify(proto)
|
||||
}
|
||||
const entry = new WindowToken(windowContainer)
|
||||
entry.obj = getWMPropertiesForDisplay(proto)
|
||||
entry.shortName = shortenName(entry.name)
|
||||
entry.children = entry.childrenWindows
|
||||
entry.rawTreeViewObject = asRawTreeViewObject(entry)
|
||||
|
||||
console.warn("Created ", entry.kind, " stableId=", entry.stableId)
|
||||
return entry
|
||||
}
|
||||
|
||||
export default WindowToken
|
||||
|
||||
Reference in New Issue
Block a user