1 /* 2 * Copyright (C) 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 package com.android.server.wm.traces.common.windowmanager.windows 18 19 /** 20 * Represents a task fragment in the window manager hierarchy 21 * 22 * This is a generic object that is reused by both Flicker and Winscope and cannot 23 * access internal Java/Android functionality 24 * 25 */ 26 open class TaskFragment( 27 override val activityType: Int, 28 val displayId: Int, 29 val minWidth: Int, 30 val minHeight: Int, 31 windowContainer: WindowContainer 32 ) : WindowContainer(windowContainer) { 33 val tasks: Array<Task> 34 get() = this.children.reversed().filterIsInstance<Task>().toTypedArray() 35 val taskFragments: Array<TaskFragment> 36 get() = this.children.reversed().filterIsInstance<TaskFragment>().toTypedArray() 37 val activities: Array<Activity> 38 get() = this.children.reversed().filterIsInstance<Activity>().toTypedArray() 39 toStringnull40 override fun toString(): String { 41 return "${this::class.simpleName}: {$token $title} bounds=$bounds" 42 } 43 equalsnull44 override fun equals(other: Any?): Boolean { 45 if (this === other) return true 46 if (other !is TaskFragment) return false 47 48 if (activityType != other.activityType) return false 49 if (displayId != other.displayId) return false 50 if (minWidth != other.minWidth) return false 51 if (minHeight != other.minHeight) return false 52 53 return true 54 } 55 hashCodenull56 override fun hashCode(): Int { 57 var result = super.hashCode() 58 result = 31 * result + activityType 59 result = 31 * result + displayId 60 result = 31 * result + minWidth 61 result = 31 * result + minHeight 62 return result 63 } 64 }