4/ Sort property values on Winscope
Present the values of WM and SF traces alphabetically Bug: 185516271 Test: build winscope and open WM/SF traces, check the property list Change-Id: I6cc5553ae6e987d52f812c030b0e4706ab58606b
This commit is contained in:
37
tools/winscope/src/flickerlib/ObjectFormatter.ts
Normal file
37
tools/winscope/src/flickerlib/ObjectFormatter.ts
Normal file
@@ -0,0 +1,37 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
export default class ObjectFormatter {
|
||||
static format(obj: any): {} {
|
||||
const entries = Object.entries(obj)
|
||||
const sortedEntries = entries.sort()
|
||||
|
||||
const result: any = {}
|
||||
sortedEntries.forEach(entry => {
|
||||
const key = entry[0]
|
||||
const value = entry[1]
|
||||
if (value && typeof(value) == `object`) {
|
||||
result[key] = this.format(value)
|
||||
} else {
|
||||
result[key] = value
|
||||
}
|
||||
})
|
||||
|
||||
// Reassign prototype to ensure formatters work
|
||||
result.__proto__ = obj.__proto__
|
||||
return result
|
||||
}
|
||||
}
|
||||
@@ -14,6 +14,8 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import ObjectFormatter from "./ObjectFormatter"
|
||||
|
||||
/**
|
||||
* Get the properties of a WM object for display.
|
||||
*
|
||||
@@ -30,7 +32,8 @@ export function getWMPropertiesForDisplay(proto: any): any {
|
||||
if (obj.rootDisplayArea) delete obj.rootDisplayArea
|
||||
if (obj.rootWindowContainer) delete obj.rootWindowContainer
|
||||
if (obj.windowContainer?.children) delete obj.windowContainer.children
|
||||
return obj
|
||||
|
||||
return ObjectFormatter.format(obj)
|
||||
}
|
||||
|
||||
export function shortenName(name: any): string {
|
||||
|
||||
@@ -19,6 +19,7 @@ import {transform, nanos_to_string, get_visible_chip} from './transform.js';
|
||||
// eslint-disable-next-line camelcase
|
||||
import {fill_occlusion_state, fill_inherited_state} from './sf_visibility.js';
|
||||
import {getSimplifiedLayerName} from './utils/names';
|
||||
import ObjectFormatter from './flickerlib/ObjectFormatter'
|
||||
|
||||
const RELATIVE_Z_CHIP = {
|
||||
short: 'RelZ',
|
||||
@@ -100,7 +101,7 @@ function transformLayer(layer) {
|
||||
layer.id + ': ' + simplifiedLayerName : undefined;
|
||||
|
||||
const transformedLayer = transform({
|
||||
obj: layer,
|
||||
obj: ObjectFormatter.format(layer),
|
||||
kind: '',
|
||||
name: layer.id + ': ' + layer.name,
|
||||
shortName,
|
||||
|
||||
Reference in New Issue
Block a user