1/* 2 * Copyright 2020, The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17import { getPropertiesForDisplay, shortenName } from '../mixin' 18import { asRawTreeViewObject } from '../../utils/diff.js' 19import { DisplayArea } from "../common" 20import WindowContainer from "./WindowContainer" 21 22DisplayArea.fromProto = function (proto, isActivityInTree: Boolean): DisplayArea { 23 if (proto == null) { 24 return null 25 } else { 26 const children = proto.windowContainer.children.reverse() 27 .filter(it => it != null) 28 .map(it => WindowContainer.childrenFromProto(it, isActivityInTree)) 29 const windowContainer = WindowContainer.fromProto({proto: proto.windowContainer, 30 children: children, nameOverride: proto.name}) 31 if (windowContainer == null) { 32 throw "Window container should not be null: " + JSON.stringify(proto) 33 } 34 const entry = new DisplayArea(proto.isTaskDisplayArea, windowContainer) 35 36 entry.obj = getPropertiesForDisplay(proto, entry) 37 entry.kind = entry.constructor.name 38 entry.shortName = shortenName(entry.name) 39 entry.rawTreeViewObject = asRawTreeViewObject(entry) 40 41 console.warn("Created ", entry.kind, " stableId=", entry.stableId) 42 return entry 43 } 44} 45 46export default DisplayArea 47