• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 /**
20  * Represents the configuration of a WM container
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 data class Configuration(
27     val windowConfiguration: WindowConfiguration?,
28     val densityDpi: Int,
29     val orientation: Int,
30     val screenHeightDp: Int,
31     val screenWidthDp: Int,
32     val smallestScreenWidthDp: Int,
33     val screenLayout: Int,
34     val uiMode: Int
35 ) {
36     val isEmpty: Boolean
37         get() = (windowConfiguration == null) &&
38             densityDpi == 0 &&
39             orientation == 0 &&
40             screenHeightDp == 0 &&
41             screenWidthDp == 0 &&
42             smallestScreenWidthDp == 0 &&
43             screenLayout == 0 &&
44             uiMode == 0
45 
equalsnull46     override fun equals(other: Any?): Boolean {
47         if (this === other) return true
48         if (other !is Configuration) return false
49 
50         if (windowConfiguration != other.windowConfiguration) return false
51         if (densityDpi != other.densityDpi) return false
52         if (orientation != other.orientation) return false
53         if (screenHeightDp != other.screenHeightDp) return false
54         if (screenWidthDp != other.screenWidthDp) return false
55         if (smallestScreenWidthDp != other.smallestScreenWidthDp) return false
56         if (screenLayout != other.screenLayout) return false
57         if (uiMode != other.uiMode) return false
58 
59         return true
60     }
61 
hashCodenull62     override fun hashCode(): Int {
63         var result = windowConfiguration?.hashCode() ?: 0
64         result = 31 * result + densityDpi
65         result = 31 * result + orientation
66         result = 31 * result + screenHeightDp
67         result = 31 * result + screenWidthDp
68         result = 31 * result + smallestScreenWidthDp
69         result = 31 * result + screenLayout
70         result = 31 * result + uiMode
71         return result
72     }
73 }