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 { ActivityTask, toRect } from "../common" 20import WindowContainer from "./WindowContainer" 21 22ActivityTask.fromProto = function (proto, isActivityInTree: Boolean): ActivityTask { 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}) 31 if (windowContainer == null) { 32 throw "Window container should not be null: " + JSON.stringify(proto) 33 } 34 const entry = new ActivityTask( 35 proto.activityType, 36 proto.fillsParent, 37 toRect(proto.bounds), 38 proto.id, 39 proto.rootTaskId, 40 proto.displayId, 41 toRect(proto.lastNonFullscreenBounds), 42 proto.realActivity, 43 proto.origActivity, 44 proto.resizeMode, 45 proto.resumedActivity?.title ?? "", 46 proto.animatingBounds, 47 proto.surfaceWidth, 48 proto.surfaceHeight, 49 proto.createdByOrganizer, 50 proto.minWidth, 51 proto.minHeight, 52 windowContainer 53 ) 54 55 entry.obj = getPropertiesForDisplay(proto, entry) 56 entry.kind = entry.constructor.name 57 entry.shortName = shortenName(entry.name) 58 entry.rawTreeViewObject = asRawTreeViewObject(entry) 59 60 console.warn("Created ", entry.kind, " stableId=", entry.stableId) 61 return entry 62 } 63} 64 65export default ActivityTask 66