1 /* 2 * Copyright 2024 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.input; 18 19 import android.annotation.NonNull; 20 21 import com.android.internal.util.AnnotationValidations; 22 import com.android.internal.util.DataClass; 23 import com.android.tools.r8.keepanno.annotations.KeepItemKind; 24 import com.android.tools.r8.keepanno.annotations.UsedByNative; 25 26 /** 27 * This class represents a touchpad hardware state at a single moment in time. 28 * It is only used by the touchpad visualization which is implemented in TouchpadDebugActivity. 29 */ 30 @DataClass(genToString = true) 31 @UsedByNative( 32 description = "Called from JNI in jni/com_android_server_input_InputManagerService.cpp", 33 kind = KeepItemKind.CLASS_AND_MEMBERS) 34 public final class TouchpadHardwareState{ 35 /** 36 * The time at which the event was received by the system. 37 * The time is in milliseconds and start counting when the program starts. 38 */ 39 private final float mTimestamp; 40 41 /** 42 * Number of buttons pressed. Note that in our case while using 43 * a touchpad only one button is available and can be pressed. 44 */ 45 private final int mButtonsDown; 46 47 /** 48 * The number of FingerState structs pointed to by the fingers field. 49 */ 50 private final int mFingerCount; 51 52 /** 53 * The number of fingers touching the pad, which may be more than fingerCount. 54 */ 55 private final int mTouchCount; 56 57 /** 58 * Array of fingerStates that indicates the properties of each finger touching the touchpad. 59 */ 60 private final @NonNull TouchpadFingerState[] mFingerStates; 61 62 // Code below generated by codegen v1.0.23. 63 // 64 // DO NOT MODIFY! 65 // CHECKSTYLE:OFF Generated code 66 // 67 // To regenerate run: 68 // $ codegen $ANDROID_BUILD_TOP/frameworks/base/services/core/java/com/android/server/input/ 69 // TouchpadHardwareState.java 70 // 71 // To exclude the generated code from IntelliJ auto-formatting enable (one-time): 72 // Settings > Editor > Code Style > Formatter Control 73 //@formatter:off 74 75 76 /** 77 * Creates a new TouchpadHardwareState. 78 * 79 * @param timestamp 80 * The time at which the event was received by the system. 81 * The time is in milliseconds and start counting when the program starts. 82 * @param buttonsDown 83 * Number of buttons pressed. Note that in our case while using 84 * a touchpad only one button is available and can be pressed. 85 * @param fingerCount 86 * The number of FingerState structs pointed to by the fingers field. 87 * @param touchCount 88 * The number of fingers touching the pad, which may be more than fingerCount. 89 * @param fingerStates 90 * Array of fingerStates that indicates the properties of each finger touching the touchpad. 91 */ 92 @DataClass.Generated.Member TouchpadHardwareState( float timestamp, int buttonsDown, int fingerCount, int touchCount, @NonNull TouchpadFingerState[] fingerStates)93 public TouchpadHardwareState( 94 float timestamp, 95 int buttonsDown, 96 int fingerCount, 97 int touchCount, 98 @NonNull TouchpadFingerState[] fingerStates) { 99 this.mTimestamp = timestamp; 100 this.mButtonsDown = buttonsDown; 101 this.mFingerCount = fingerCount; 102 this.mTouchCount = touchCount; 103 this.mFingerStates = fingerStates; 104 AnnotationValidations.validate( 105 NonNull.class, null, mFingerStates); 106 107 // onConstructed(); // You can define this method to get a callback 108 } 109 110 /** 111 * The time at which the event was received by the system. 112 * The time is in milliseconds and start counting when the program starts. 113 */ 114 @DataClass.Generated.Member getTimestamp()115 public float getTimestamp() { 116 return mTimestamp; 117 } 118 119 /** 120 * Number of buttons pressed. Note that in our case while using 121 * a touchpad only one button is available and can be pressed. 122 */ 123 @DataClass.Generated.Member getButtonsDown()124 public int getButtonsDown() { 125 return mButtonsDown; 126 } 127 128 /** 129 * The number of FingerState structs pointed to by the fingers field. 130 */ 131 @DataClass.Generated.Member getFingerCount()132 public int getFingerCount() { 133 return mFingerCount; 134 } 135 136 /** 137 * The number of fingers touching the pad, which may be more than fingerCount. 138 */ 139 @DataClass.Generated.Member getTouchCount()140 public int getTouchCount() { 141 return mTouchCount; 142 } 143 144 /** 145 * Array of fingerStates that indicates the properties of each finger touching the touchpad. 146 */ 147 @DataClass.Generated.Member getFingerStates()148 public @NonNull TouchpadFingerState[] getFingerStates() { 149 return mFingerStates; 150 } 151 152 @Override 153 @DataClass.Generated.Member toString()154 public String toString() { 155 // You can override field toString logic by defining methods like: 156 // String fieldNameToString() { ... } 157 158 return "TouchpadHardwareState { " + 159 "timestamp = " + mTimestamp + ", " + 160 "buttonsDown = " + mButtonsDown + ", " + 161 "fingerCount = " + mFingerCount + ", " + 162 "touchCount = " + mTouchCount + ", " + 163 "fingerStates = " + java.util.Arrays.toString(mFingerStates) + 164 " }"; 165 } 166 167 @DataClass.Generated( 168 time = 1724079048292L, 169 codegenVersion = "1.0.23", 170 sourceFile = "frameworks/base/services/core/java/com/android/server/input/" 171 + "TouchpadHardwareState.java", 172 inputSignatures = "private final float mTimestamp\nprivate final int mButtonsDown\n" 173 + "private final int mFingerCount\nprivate final int mTouchCount\nprivate " 174 + "final @android.annotation.NonNull com.android.server.input." 175 + "TouchpadFingerState[] mFingerStates\nclass TouchpadHardwareState extends " 176 + "java.lang.Object implements []\n@com.android.internal.util.DataClass" 177 + "(genToString=true)") 178 @Deprecated __metadata()179 private void __metadata() {} 180 181 182 //@formatter:on 183 // End of generated code 184 185 } 186