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 17// Imports all the compiled common Flicker library classes and exports them 18// as clean es6 modules rather than having them be commonjs modules 19 20const WindowManagerTrace = require('flicker').com.android.server.wm.traces.common. 21 windowmanager.WindowManagerTrace; 22const WindowManagerState = require('flicker').com.android.server.wm.traces.common. 23 windowmanager.WindowManagerState; 24 25const Activity = require('flicker').com.android.server.wm.traces.common. 26 windowmanager.windows.Activity; 27const ActivityTask = require('flicker').com.android.server.wm.traces.common. 28 windowmanager.windows.ActivityTask; 29const Configuration = require('flicker').com.android.server.wm.traces.common. 30 windowmanager.windows.Configuration; 31const ConfigurationContainer = require('flicker').com.android.server.wm.traces.common. 32 windowmanager.windows.ConfigurationContainer; 33const DisplayArea = require('flicker').com.android.server.wm.traces.common. 34 windowmanager.windows.DisplayArea; 35const DisplayContent = require('flicker').com.android.server.wm.traces.common. 36 windowmanager.windows.DisplayContent; 37const KeyguardControllerState = require('flicker').com.android.server.wm.traces.common. 38 windowmanager.windows.KeyguardControllerState; 39const RootWindowContainer = require('flicker').com.android.server.wm.traces.common. 40 windowmanager.windows.RootWindowContainer; 41const WindowConfiguration = require('flicker').com.android.server.wm.traces.common. 42 windowmanager.windows.WindowConfiguration; 43const WindowContainer = require('flicker').com.android.server.wm.traces.common. 44 windowmanager.windows.WindowContainer; 45const WindowLayoutParams= require('flicker').com.android.server.wm.traces.common. 46 windowmanager.windows.WindowLayoutParams; 47const WindowManagerPolicy = require('flicker').com.android.server.wm.traces.common. 48 windowmanager.windows.WindowManagerPolicy; 49const WindowState = require('flicker').com.android.server.wm.traces.common. 50 windowmanager.windows.WindowState; 51const WindowToken = require('flicker').com.android.server.wm.traces.common. 52 windowmanager.windows.WindowToken; 53 54const Matrix = require('flicker').com.android.server.wm.traces.common.layers.Transform.Matrix; 55const Transform = require('flicker').com.android.server.wm.traces.common.layers.Transform; 56 57const Bounds = require('flicker').com.android.server.wm.traces.common.Bounds; 58const Buffer = require('flicker').com.android.server.wm.traces.common.Buffer; 59const Color = require('flicker').com.android.server.wm.traces.common.Color; 60const Point = require('flicker').com.android.server.wm.traces.common.Point; 61const Rect = require('flicker').com.android.server.wm.traces.common.Rect; 62const RectF = require('flicker').com.android.server.wm.traces.common.RectF; 63const Region = require('flicker').com.android.server.wm.traces.common.Region; 64 65function toBounds(proto) { 66 if (proto == null) { 67 return null 68 } 69 return new Bounds(proto.width ?? proto.w ?? 0, proto.height ?? proto.h ?? 0) 70} 71 72function toBuffer(proto) { 73 if (proto == null) { 74 return null 75 } 76 return new Buffer(proto.width ?? 0, proto.height ?? 0, proto.stride ?? 0, proto.format ?? 0) 77} 78 79function toColor(proto) { 80 if (proto == null) { 81 return null 82 } 83 return new Color(proto.r ?? 0, proto.g ?? 0, proto.b ?? 0, proto.a ?? 0) 84} 85 86function toPoint(proto) { 87 if (proto == null) { 88 return null 89 } 90 return new Point(proto.x ?? 0, proto.y ?? 0) 91} 92 93function toRect(proto) { 94 if (proto == null) { 95 return null 96 } 97 return new Rect(proto.left ?? 0, proto.top ?? 0, proto.right ?? 0, proto.bottom ?? 0) 98} 99 100function toRectF(proto) { 101 if (proto == null) { 102 return null 103 } 104 return new RectF(proto.left ?? 0, proto.top ?? 0, proto.right ?? 0, proto.bottom ?? 0) 105} 106 107function toRegion(proto) { 108 if (proto == null) { 109 return null 110 } 111 112 let rects = [] 113 for (let rectNr in proto.rect) { 114 const rect = proto.rect[rectNr] 115 const parsedRect = toRect(rect) 116 rects.push(parsedRect) 117 } 118 119 return new Region(rects) 120} 121 122function toTransform(proto) { 123 if (proto == null) { 124 return null 125 } 126 const matrix = new Matrix(proto.dsdx ?? 0, proto.dtdx ?? 0, 127 proto.tx ?? 0, proto.dsdy ?? 0, proto.dtdy ?? 0, proto.ty ?? 0) 128 return new Transform(proto.type ?? 0, matrix) 129} 130 131export { 132 Activity, 133 ActivityTask, 134 Configuration, 135 ConfigurationContainer, 136 DisplayArea, 137 DisplayContent, 138 KeyguardControllerState, 139 RootWindowContainer, 140 WindowConfiguration, 141 WindowContainer, 142 WindowState, 143 WindowToken, 144 WindowLayoutParams, 145 WindowManagerPolicy, 146 WindowManagerTrace, 147 WindowManagerState, 148 Bounds, 149 Buffer, 150 Color, 151 Point, 152 Rect, 153 RectF, 154 Region, 155 toBounds, 156 toBuffer, 157 toColor, 158 toPoint, 159 toRect, 160 toRectF, 161 toRegion, 162 toTransform 163}; 164