Merge "Fix parsing of WM trace in critical mode"

This commit is contained in:
Nataniel Borges
2021-10-19 10:01:46 +00:00
committed by Android (Google) Code Review
12 changed files with 20 additions and 12 deletions

View File

@@ -235,7 +235,7 @@ class WindowManagerTraceSelectedConfig:
# defaults set for all configs
self.selectedConfigs = {
"wmbuffersize": "16000",
"tracinglevel": "all",
"tracinglevel": "debug",
"tracingtype": "frame",
}

View File

@@ -243,8 +243,8 @@ const WM_SELECTED_CONFIG = {
'transaction',
],
'tracinglevel': [
'all',
'trim',
'verbose',
'debug',
'critical',
],
};

View File

@@ -537,6 +537,7 @@ function decodeAndTransformProto(buffer, params, displayDefaults) {
// From S onwards, returns a LayerTrace object, iterating over multiple items allows
// winscope to handle both the new and legacy formats
// TODO Refactor the decode.js code into a set of decoders to clean up the code
let lastError = null;
for (var x = 0; x < objTypesProto.length; x++) {
const objType = objTypesProto[x];
const transform = transforms[x];
@@ -546,9 +547,14 @@ function decodeAndTransformProto(buffer, params, displayDefaults) {
const transformed = transform(decoded);
return transformed;
} catch (e) {
lastError = e;
// check next parser
}
}
if (lastError) {
throw lastError;
}
throw new UndetectableFileType('Unable to parse file');
}

View File

@@ -89,7 +89,8 @@ function createWindowManagerPolicy(proto: any): WindowManagerPolicy {
function createRootWindowContainer(proto: any): RootWindowContainer {
const windowContainer = WindowContainer.fromProto(
/* proto */ proto.windowContainer,
/* childrenProto */ proto.windowContainer.children.reverse()
/* childrenProto */ proto.windowContainer?.children?.reverse() ?? [],
/* isActivityInTree */ false
);
if (windowContainer == null) {

View File

@@ -25,7 +25,7 @@ Activity.fromProto = function (proto: any): Activity {
} else {
const windowContainer = WindowContainer.fromProto(
/* proto */ proto.windowToken.windowContainer,
/* protoChildren */ proto.windowToken.windowContainer.children.reverse(),
/* protoChildren */ proto.windowToken.windowContainer?.children?.reverse() ?? [],
/* isActivityInTree */ true,
/* nameOverride */ null,
/* identifierOverride */ proto.identifier

View File

@@ -24,7 +24,7 @@ DisplayArea.fromProto = function (proto: any, isActivityInTree: Boolean): Displa
} else {
const windowContainer = WindowContainer.fromProto(
/* proto */ proto.windowContainer,
/* protoChildren */ proto.windowContainer.children.reverse(),
/* protoChildren */ proto.windowContainer?.children?.reverse() ?? [],
/* isActivityInTree */ isActivityInTree,
/* nameOverride */ proto.name
);

View File

@@ -24,7 +24,7 @@ DisplayContent.fromProto = function (proto: any, isActivityInTree: Boolean): Dis
} else {
const windowContainer = WindowContainer.fromProto(
/* proto */ proto.rootDisplayArea.windowContainer,
/* protoChildren */ proto.rootDisplayArea.windowContainer.children.reverse(),
/* protoChildren */ proto.rootDisplayArea.windowContainer?.children?.reverse() ?? [],
/* isActivityInTree */ isActivityInTree,
/* nameOverride */ proto.displayInfo?.name ?? null
);

View File

@@ -25,7 +25,7 @@ Task.fromProto = function (proto: any, isActivityInTree: Boolean): Task {
const windowContainerProto = proto.taskFragment?.windowContainer ?? proto.windowContainer;
const windowContainer = WindowContainer.fromProto(
/* proto */ windowContainerProto,
/* protoChildren */ windowContainerProto.children.reverse(),
/* protoChildren */ windowContainerProto?.children?.reverse() ?? [],
/* isActivityInTree */ isActivityInTree
);

View File

@@ -24,7 +24,7 @@ TaskFragment.fromProto = function (proto: any, isActivityInTree: Boolean): TaskF
} else {
const windowContainer = WindowContainer.fromProto(
/* proto */ proto.windowContainer,
/* protoChildren */ proto.windowContainer.children.reverse(),
/* protoChildren */ proto.windowContainer?.children?.reverse() ?? [],
/* isActivityInTree */ isActivityInTree);
const entry = new TaskFragment(
proto.activityType,

View File

@@ -47,7 +47,8 @@ WindowContainer.fromProto = function (
const children = protoChildren
.filter(it => it != null)
.map(it => WindowContainer.childrenFromProto(it, isActivityInTree));
.map(it => WindowContainer.childrenFromProto(it, isActivityInTree))
.filter(it => it != null);
const identifier = identifierOverride ?? proto.identifier;
var name = nameOverride ?? identifier?.title ?? "";

View File

@@ -29,7 +29,7 @@ import WindowContainer from "./WindowContainer"
const name = getName(identifierName);
const windowContainer = WindowContainer.fromProto(
/* proto */ proto.windowContainer,
/* protoChildren */ proto.windowContainer.children.reverse(),
/* protoChildren */ proto.windowContainer?.children.reverse() ?? [],
/* isActivityInTree */ isActivityInTree,
/* nameOverride */ name,
/* identifierOverride */ proto.identifier

View File

@@ -25,7 +25,7 @@ WindowToken.fromProto = function (proto: any, isActivityInTree: Boolean): Window
const windowContainer = WindowContainer.fromProto(
/* proto */ proto.windowContainer,
/* protoChildren */ proto.windowContainer.children.reverse(),
/* protoChildren */ proto.windowContainer?.children?.reverse() ?? [],
/* isActivityInTree */ isActivityInTree,
/* nameOverride */ null,
/* identifierOverride */ null,