Make winscope compatible with flicker/CTS infra
Flickerlib is migrating to the same structure as the CTS tests. This cl makes winscope compatible with this changes. It now parses traces with the new information and add a "flickerObj" entry to each node with the calculated vlaues from flickerlib Test: yarn run dev and open a few WM traces Bug: 167521440 Bug: 170372278 Change-Id: I4a116ccabe392c75e5b5049808d4837f865cb2c7
This commit is contained in:
110
tools/winscope/src/flickerlib/WindowManagerState.ts
Normal file
110
tools/winscope/src/flickerlib/WindowManagerState.ts
Normal file
@@ -0,0 +1,110 @@
|
||||
/*
|
||||
* Copyright 2020, The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import { nanosToString, TimeUnits } from "../utils/utils.js"
|
||||
import { getWMPropertiesForDisplay } from './mixin'
|
||||
|
||||
import {
|
||||
KeyguardControllerState,
|
||||
RootWindowContainer,
|
||||
WindowManagerPolicy,
|
||||
WindowManagerState
|
||||
} from "./common"
|
||||
|
||||
import WindowContainer from "./windows/WindowContainer"
|
||||
|
||||
|
||||
WindowManagerState.fromProto = function ({proto, timestamp = 0, where = ""}): WindowManagerState {
|
||||
var inputMethodWIndowAppToken = ""
|
||||
if (proto.inputMethodWindow != null) {
|
||||
proto.inputMethodWindow.hashCode.toString(16)
|
||||
}
|
||||
const rootWindowContainer = newRootWindowContainer(proto.rootWindowContainer)
|
||||
const keyguardControllerState = newKeyguardControllerState(
|
||||
proto.rootWindowContainer.keyguardController)
|
||||
const entry = new WindowManagerState(
|
||||
where,
|
||||
newWindowManagerPolicy(proto.policy),
|
||||
proto.focusedApp,
|
||||
proto.focusedDisplayId,
|
||||
proto.focusedWindow?.title ?? "",
|
||||
inputMethodWIndowAppToken,
|
||||
proto.rootWindowContainer.isHomeRecentsComponent,
|
||||
proto.displayFrozen,
|
||||
proto.rotation,
|
||||
proto.lastOrientation,
|
||||
proto.rootWindowContainer.pendingActivities.map(it => it.title),
|
||||
rootWindowContainer,
|
||||
keyguardControllerState,
|
||||
timestamp = timestamp
|
||||
)
|
||||
|
||||
entry.obj = getWMPropertiesForDisplay(proto)
|
||||
entry.name = nanosToString(entry.timestamp, TimeUnits.MILLI_SECONDS)
|
||||
entry.shortName = entry.name
|
||||
entry.children = entry.root.childrenWindows.reverse()
|
||||
entry.chips = []
|
||||
entry.visible = true
|
||||
return entry
|
||||
}
|
||||
|
||||
function newWindowManagerPolicy(proto): WindowManagerPolicy {
|
||||
return new WindowManagerPolicy(
|
||||
proto.focusedAppToken || "",
|
||||
proto.forceStatusBar,
|
||||
proto.forceStatusBarFromKeyguard,
|
||||
proto.keyguardDrawComplete,
|
||||
proto.keyguardOccluded,
|
||||
proto.keyguardOccludedChanged,
|
||||
proto.keyguardOccludedPending,
|
||||
proto.lastSystemUiFlags,
|
||||
proto.orientation,
|
||||
proto.rotation,
|
||||
proto.rotationMode,
|
||||
proto.screenOnFully,
|
||||
proto.windowManagerDrawComplete
|
||||
)
|
||||
}
|
||||
|
||||
function newRootWindowContainer(proto): RootWindowContainer {
|
||||
const windowContainer = WindowContainer.fromProto({proto: proto.windowContainer})
|
||||
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
|
||||
}
|
||||
|
||||
function newKeyguardControllerState(proto): KeyguardControllerState {
|
||||
const keyguardOccludedStates = {}
|
||||
|
||||
if (proto) {
|
||||
proto.keyguardOccludedStates.forEach(it =>
|
||||
keyguardOccludedStates[it.displayId] = it.keyguardOccluded)
|
||||
}
|
||||
|
||||
return new KeyguardControllerState(
|
||||
proto?.aodShowing ?? false,
|
||||
proto?.keyguardShowing ?? false,
|
||||
keyguardOccludedStates
|
||||
)
|
||||
}
|
||||
|
||||
export default WindowManagerState;
|
||||
Reference in New Issue
Block a user