1 /*
2  * Copyright (C) 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 package com.android.server.wm.traces.common.windowmanager.windows
18 
19 import com.android.server.wm.traces.common.Rect
20 
21 /**
22  * Represents the configuration of a WM window
23  *
24  * This is a generic object that is reused by both Flicker and Winscope and cannot
25  * access internal Java/Android functionality
26  *
27  */
28 open class WindowConfiguration(
29     _appBounds: Rect?,
30     _bounds: Rect?,
31     _maxBounds: Rect?,
32     val windowingMode: Int,
33     val activityType: Int
34 ) {
35     val appBounds: Rect = _appBounds ?: Rect.EMPTY
36     val bounds: Rect = _bounds ?: Rect.EMPTY
37     val maxBounds: Rect = _maxBounds ?: Rect.EMPTY
38 
39     val isEmpty: Boolean
40         get() = appBounds.isEmpty &&
41             bounds.isEmpty &&
42             maxBounds.isEmpty &&
43             windowingMode == 0 &&
44             activityType == 0
45 
equalsnull46     override fun equals(other: Any?): Boolean {
47         if (this === other) return true
48         if (other !is WindowConfiguration) return false
49 
50         if (windowingMode != other.windowingMode) return false
51         if (activityType != other.activityType) return false
52         if (appBounds != other.appBounds) return false
53         if (bounds != other.bounds) return false
54         if (maxBounds != other.maxBounds) return false
55 
56         return true
57     }
58 
hashCodenull59     override fun hashCode(): Int {
60         var result = windowingMode
61         result = 31 * result + activityType
62         result = 31 * result + appBounds.hashCode()
63         result = 31 * result + bounds.hashCode()
64         result = 31 * result + maxBounds.hashCode()
65         return result
66     }
67 }