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 { shortenName } from '../mixin' 18import { WindowToken } from "../common" 19import WindowContainer from "./WindowContainer" 20 21WindowToken.fromProto = function (proto: any, isActivityInTree: Boolean): WindowToken { 22 if (proto == null) { 23 return null; 24 } 25 26 const windowContainer = WindowContainer.fromProto( 27 /* proto */ proto.windowContainer, 28 /* protoChildren */ proto.windowContainer.children.reverse(), 29 /* isActivityInTree */ isActivityInTree, 30 /* nameOverride */ null, 31 /* identifierOverride */ null, 32 /* tokenOverride */ proto.hashCode 33 ); 34 const entry = new WindowToken(windowContainer); 35 entry.kind = entry.constructor.name; 36 entry.proto = proto; 37 entry.shortName = shortenName(entry.name); 38 console.warn("Created ", entry.kind, " stableId=", entry.stableId); 39 return entry; 40} 41 42export default WindowToken; 43