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 {Activity} from '../common'; 18import {shortenName} from '../mixin'; 19import {WindowContainer} from './WindowContainer'; 20 21Activity.fromProto = (proto: any, nextSeq: () => number): Activity => { 22 if (proto == null) { 23 return null; 24 } else { 25 const windowContainer = WindowContainer.fromProto( 26 /* proto */ proto.windowToken.windowContainer, 27 /* protoChildren */ proto.windowToken.windowContainer?.children ?? [], 28 /* isActivityInTree */ true, 29 /* computedZ */ nextSeq, 30 /* nameOverride */ proto.name, 31 /* identifierOverride */ proto.identifier 32 ); 33 34 const entry = new Activity( 35 proto.state, 36 proto.frontOfTask, 37 proto.procId, 38 proto.translucent, 39 windowContainer 40 ); 41 42 addAttributes(entry, proto); 43 return entry; 44 } 45}; 46 47function addAttributes(entry: Activity, proto: any) { 48 entry.proto = proto; 49 entry.kind = entry.constructor.name; 50 entry.shortName = shortenName(entry.name); 51} 52 53export {Activity}; 54