xref: /aosp_15_r20/platform_testing/libraries/flicker/utils/src/android/tools/traces/inputmethod/EditorInfo.kt (revision dd0948b35e70be4c0246aabd6c72554a5eb8b22a)
1 /*
2  * Copyright (C) 2023 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 android.tools.traces.inputmethod
18 
19 /**
20  * Represents the EditorInfoProto in IME traces
21  *
22  * This is a generic object that is reused by both Flicker and Winscope and cannot access internal
23  * Java/Android functionality
24  */
25 open class EditorInfo(
26     val inputType: Int,
27     val imeOptions: Int,
28     val privateImeOptions: String,
29     val packageName: String,
30     val fieldId: Int,
31     val targetInputMethodUserId: Int,
32 ) {
toStringnull33     override fun toString(): String {
34         return "${this::class.simpleName}: {$packageName, inputType: $inputType," +
35             "imeOptions: $imeOptions}"
36     }
37 
equalsnull38     override fun equals(other: Any?): Boolean {
39         if (this === other) return true
40         if (other !is EditorInfo) return false
41 
42         if (inputType != other.inputType) return false
43         if (imeOptions != other.imeOptions) return false
44         if (privateImeOptions != other.privateImeOptions) return false
45         if (packageName != other.packageName) return false
46         if (fieldId != other.fieldId) return false
47         if (targetInputMethodUserId != other.targetInputMethodUserId) return false
48 
49         return true
50     }
51 
hashCodenull52     override fun hashCode(): Int {
53         var result = inputType
54         result = 31 * result + imeOptions
55         result = 31 * result + privateImeOptions.hashCode()
56         result = 31 * result + packageName.hashCode()
57         result = 31 * result + fieldId
58         result = 31 * result + targetInputMethodUserId
59         return result
60     }
61 }
62