• 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 requested policy 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 WindowManagerPolicy(
27     val focusedAppToken: String,
28     val forceStatusBar: Boolean,
29     val forceStatusBarFromKeyguard: Boolean,
30     val keyguardDrawComplete: Boolean,
31     val keyguardOccluded: Boolean,
32     val keyguardOccludedChanged: Boolean,
33     val keyguardOccludedPending: Boolean,
34     val lastSystemUiFlags: Int,
35     val orientation: Int,
36     val rotation: Int,
37     val rotationMode: Int,
38     val screenOnFully: Boolean,
39     val windowManagerDrawComplete: Boolean
40 ) {
41     val isOrientationNoSensor: Boolean
42         get() = orientation == SCREEN_ORIENTATION_NOSENSOR
43 
44     val isFixedOrientation: Boolean
45         get() = isFixedOrientationLandscape ||
46             isFixedOrientationPortrait ||
47             orientation == SCREEN_ORIENTATION_LOCKED
48 
49     private val isFixedOrientationLandscape
50         get() = orientation == SCREEN_ORIENTATION_LANDSCAPE ||
51             orientation == SCREEN_ORIENTATION_SENSOR_LANDSCAPE ||
52             orientation == SCREEN_ORIENTATION_REVERSE_LANDSCAPE ||
53             orientation == SCREEN_ORIENTATION_USER_LANDSCAPE
54 
55     private val isFixedOrientationPortrait
56         get() = orientation == SCREEN_ORIENTATION_PORTRAIT ||
57             orientation == SCREEN_ORIENTATION_SENSOR_PORTRAIT ||
58             orientation == SCREEN_ORIENTATION_REVERSE_PORTRAIT ||
59             orientation == SCREEN_ORIENTATION_USER_PORTRAIT
60 
61     companion object {
62         /**
63          * From [android.content.pm.ActivityInfo]
64          */
65         private const val SCREEN_ORIENTATION_LANDSCAPE = 0
66         private const val SCREEN_ORIENTATION_PORTRAIT = 1
67         private const val SCREEN_ORIENTATION_NOSENSOR = 5
68         private const val SCREEN_ORIENTATION_SENSOR_LANDSCAPE = 6
69         private const val SCREEN_ORIENTATION_SENSOR_PORTRAIT = 7
70         private const val SCREEN_ORIENTATION_REVERSE_LANDSCAPE = 8
71         private const val SCREEN_ORIENTATION_REVERSE_PORTRAIT = 9
72         private const val SCREEN_ORIENTATION_USER_LANDSCAPE = 11
73         private const val SCREEN_ORIENTATION_USER_PORTRAIT = 12
74         private const val SCREEN_ORIENTATION_LOCKED = 14
75     }
76 
equalsnull77     override fun equals(other: Any?): Boolean {
78         if (this === other) return true
79         if (other !is WindowManagerPolicy) return false
80 
81         if (focusedAppToken != other.focusedAppToken) return false
82         if (forceStatusBar != other.forceStatusBar) return false
83         if (forceStatusBarFromKeyguard != other.forceStatusBarFromKeyguard) return false
84         if (keyguardDrawComplete != other.keyguardDrawComplete) return false
85         if (keyguardOccluded != other.keyguardOccluded) return false
86         if (keyguardOccludedChanged != other.keyguardOccludedChanged) return false
87         if (keyguardOccludedPending != other.keyguardOccludedPending) return false
88         if (lastSystemUiFlags != other.lastSystemUiFlags) return false
89         if (orientation != other.orientation) return false
90         if (rotation != other.rotation) return false
91         if (rotationMode != other.rotationMode) return false
92         if (screenOnFully != other.screenOnFully) return false
93         if (windowManagerDrawComplete != other.windowManagerDrawComplete) return false
94 
95         return true
96     }
97 
hashCodenull98     override fun hashCode(): Int {
99         var result = focusedAppToken.hashCode()
100         result = 31 * result + forceStatusBar.hashCode()
101         result = 31 * result + forceStatusBarFromKeyguard.hashCode()
102         result = 31 * result + keyguardDrawComplete.hashCode()
103         result = 31 * result + keyguardOccluded.hashCode()
104         result = 31 * result + keyguardOccludedChanged.hashCode()
105         result = 31 * result + keyguardOccludedPending.hashCode()
106         result = 31 * result + lastSystemUiFlags
107         result = 31 * result + orientation
108         result = 31 * result + rotation
109         result = 31 * result + rotationMode
110         result = 31 * result + screenOnFully.hashCode()
111         result = 31 * result + windowManagerDrawComplete.hashCode()
112         return result
113     }
114 }
115