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
17
18import { Tag } from "../common";
19import TransitionType from "./TransitionType";
20
21const transitionTypeMap = new Map([
22  ['ROTATION', TransitionType.ROTATION],
23  ['PIP_ENTER', TransitionType.PIP_ENTER],
24  ['PIP_RESIZE', TransitionType.PIP_RESIZE],
25  ['PIP_CLOSE', TransitionType.PIP_CLOSE],
26  ['PIP_EXIT', TransitionType.PIP_EXIT],
27  ['APP_LAUNCH', TransitionType.APP_LAUNCH],
28  ['APP_CLOSE', TransitionType.APP_CLOSE],
29  ['IME_APPEAR', TransitionType.IME_APPEAR],
30  ['IME_DISAPPEAR', TransitionType.IME_DISAPPEAR],
31  ['APP_PAIRS_ENTER', TransitionType.APP_PAIRS_ENTER],
32  ['APP_PAIRS_EXIT', TransitionType.APP_PAIRS_EXIT],
33]);
34
35Tag.fromProto = function (proto: any): Tag {
36    const tag = new Tag(
37        proto.id,
38        transitionTypeMap.get(proto.transition),
39        proto.isStartTag,
40        proto.layerId,
41        proto.windowToken,
42        proto.taskId
43    );
44    return tag;
45};
46
47export default Tag;
48