Update Winscope for TaskFragment

1. Add TaskFragment.ts
2. rename ActivityTask.ts to Task.ts

Bug: 190684677
Test: manual - run "yarn run dev" in winscope directory
               click "dumnp state"
Change-Id: Ie7339af9e4906e38b73bcd01dd9fbf1d00d25a3b
This commit is contained in:
Charles Chen
2021-06-11 16:44:23 +08:00
parent 560d791331
commit 92d1bda2a2
5 changed files with 75 additions and 15 deletions

2
.gitignore vendored
View File

@@ -5,4 +5,6 @@
Thumbs.db
*.iml
.idea/
*.yarn/
.yarnrc
gen/

View File

@@ -24,8 +24,6 @@ const WindowManagerState = require('flicker').com.android.server.wm.traces.commo
const Activity = require('flicker').com.android.server.wm.traces.common.
windowmanager.windows.Activity;
const ActivityTask = require('flicker').com.android.server.wm.traces.common.
windowmanager.windows.ActivityTask;
const Configuration = require('flicker').com.android.server.wm.traces.common.
windowmanager.windows.Configuration;
const ConfigurationContainer = require('flicker').com.android.server.wm.traces.common.
@@ -38,6 +36,10 @@ const KeyguardControllerState = require('flicker').com.android.server.wm.traces.
windowmanager.windows.KeyguardControllerState;
const RootWindowContainer = require('flicker').com.android.server.wm.traces.common.
windowmanager.windows.RootWindowContainer;
const Task = require('flicker').com.android.server.wm.traces.common.
windowmanager.windows.Task;
const TaskFragment = require('flicker').com.android.server.wm.traces.common.
windowmanager.windows.TaskFragment;
const WindowConfiguration = require('flicker').com.android.server.wm.traces.common.
windowmanager.windows.WindowConfiguration;
const WindowContainer = require('flicker').com.android.server.wm.traces.common.
@@ -130,13 +132,14 @@ function toTransform(proto) {
export {
Activity,
ActivityTask,
Configuration,
ConfigurationContainer,
DisplayArea,
DisplayContent,
KeyguardControllerState,
RootWindowContainer,
Task,
TaskFragment,
WindowConfiguration,
WindowContainer,
WindowState,

View File

@@ -16,28 +16,29 @@
import { getPropertiesForDisplay, shortenName } from '../mixin'
import { asRawTreeViewObject } from '../../utils/diff.js'
import { ActivityTask, toRect } from "../common"
import { Task, toRect } from "../common"
import WindowContainer from "./WindowContainer"
ActivityTask.fromProto = function (proto, isActivityInTree: Boolean): ActivityTask {
Task.fromProto = function (proto, isActivityInTree: Boolean): Task {
if (proto == null) {
return null
} else {
const children = proto.windowContainer.children.reverse()
const windowContainerProto = proto?.taskFragment.windowContainer ?? proto.windowContainer
const children = windowContainerProto.children.reverse()
.filter(it => it != null)
.map(it => WindowContainer.childrenFromProto(it, isActivityInTree))
const windowContainer = WindowContainer.fromProto({proto: proto.windowContainer,
const windowContainer = WindowContainer.fromProto({proto: windowContainerProto,
children: children})
if (windowContainer == null) {
throw "Window container should not be null: " + JSON.stringify(proto)
}
const entry = new ActivityTask(
proto.activityType,
const entry = new Task(
proto?.taskFragment.activityType ?? proto.activityType,
proto.fillsParent,
toRect(proto.bounds),
proto.id,
proto.rootTaskId,
proto.displayId,
proto.taskFragment.displayId,
toRect(proto.lastNonFullscreenBounds),
proto.realActivity,
proto.origActivity,
@@ -47,8 +48,8 @@ ActivityTask.fromProto = function (proto, isActivityInTree: Boolean): ActivityTa
proto.surfaceWidth,
proto.surfaceHeight,
proto.createdByOrganizer,
proto.minWidth,
proto.minHeight,
proto?.taskFragment.minWidth ?? proto.minWidth,
proto?.taskFragment.minHeight ?? proto.minHeight,
windowContainer
)
@@ -62,4 +63,4 @@ ActivityTask.fromProto = function (proto, isActivityInTree: Boolean): ActivityTa
}
}
export default ActivityTask
export default Task

View File

@@ -0,0 +1,52 @@
/*
* Copyright 2021, 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 { getPropertiesForDisplay, shortenName } from '../mixin'
import { asRawTreeViewObject } from '../../utils/diff.js'
import { TaskFragment } from "../common"
import WindowContainer from "./WindowContainer"
TaskFragment.fromProto = function (proto, isActivityInTree: Boolean): TaskFragment {
if (proto == null) {
return null
} else {
const children = proto.windowContainer.children.reverse()
.filter(it => it != null)
.map(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)
}
const entry = new TaskFragment(
proto.activityType,
proto.displayId,
proto.minWidth,
proto.minHeight,
windowContainer
)
entry.obj = getPropertiesForDisplay(proto, entry)
entry.kind = entry.constructor.name
entry.shortName = shortenName(entry.name)
entry.rawTreeViewObject = asRawTreeViewObject(entry)
console.warn("Created ", entry.kind, " stableId=", entry.stableId)
return entry
}
}
export default TaskFragment

View File

@@ -29,7 +29,8 @@ import {
import Activity from "./Activity"
import DisplayArea from "./DisplayArea"
import DisplayContent from "./DisplayContent"
import ActivityTask from "./ActivityTask"
import Task from "./Task"
import TaskFragment from "./TaskFragment"
import WindowState from "./WindowState"
import WindowToken from "./WindowToken"
@@ -70,7 +71,8 @@ WindowContainer.fromProto = function ({
WindowContainer.childrenFromProto = function(proto, isActivityInTree: Boolean): WindowContainerChild {
return DisplayContent.fromProto(proto.displayContent, isActivityInTree) ??
DisplayArea.fromProto(proto.displayArea, isActivityInTree) ??
ActivityTask.fromProto(proto.task, isActivityInTree) ??
Task.fromProto(proto.task, isActivityInTree) ??
TaskFragment.fromProto(proto.taskFragment, isActivityInTree) ??
Activity.fromProto(proto.activity) ??
WindowToken.fromProto(proto.windowToken, isActivityInTree) ??
WindowState.fromProto(proto.window, isActivityInTree) ??