1/* 2 * Copyright 2021, 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 { shortenName } from '../mixin' 18import { TaskFragment } from "../common" 19import WindowContainer from "./WindowContainer" 20 21TaskFragment.fromProto = function (proto: any, isActivityInTree: Boolean): TaskFragment { 22 if (proto == null) { 23 return null; 24 } else { 25 const windowContainer = WindowContainer.fromProto( 26 /* proto */ proto.windowContainer, 27 /* protoChildren */ proto.windowContainer.children.reverse(), 28 /* isActivityInTree */ isActivityInTree); 29 const entry = new TaskFragment( 30 proto.activityType, 31 proto.displayId, 32 proto.minWidth, 33 proto.minHeight, 34 windowContainer 35 ); 36 37 addAttributes(entry, proto); 38 console.warn("Created ", entry.kind, " stableId=", entry.stableId); 39 return entry; 40 } 41} 42 43function addAttributes(entry: TaskFragment, proto: any) { 44 entry.proto = proto; 45 entry.kind = entry.constructor.name; 46 entry.shortName = shortenName(entry.name); 47} 48 49export default TaskFragment; 50