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.hardware.input; 18 19 import android.os.Parcelable; 20 21 import com.android.internal.util.DataClass; 22 23 /** 24 * Provides information about the supported Universal Stylus Initiative (USI) version of the 25 * host device. 26 * 27 * This holds version information about the host device (e.g. the touchscreen/display), not 28 * the USI version of a stylus. 29 * 30 * @see InputManager#getHostUsiVersion(android.view.Display) 31 * @see <a href="https://universalstylus.org">Universal Stylus Initiative</a> 32 */ 33 @DataClass(genParcelable = true, genHiddenConstructor = true, genToString = true, 34 genEqualsHashCode = true) 35 public final class HostUsiVersion implements Parcelable { 36 /** 37 * The major USI version supported by the input device. 38 * For example, if the device supports USI 2.0, this will return 2. 39 */ 40 private final int mMajorVersion; 41 42 /** 43 * The minor USI version supported by the input device. 44 * For example, if the device supports USI 2.0, this will return 0. 45 */ 46 private final int mMinorVersion; 47 48 /** @hide */ isValid()49 public boolean isValid() { 50 return mMajorVersion >= 0 && mMinorVersion >= 0; 51 } 52 53 54 55 // Code below generated by codegen v1.0.23. 56 // 57 // DO NOT MODIFY! 58 // CHECKSTYLE:OFF Generated code 59 // 60 // To regenerate run: 61 // $ codegen $ANDROID_BUILD_TOP/frameworks/base/core/java/android/hardware/input/HostUsiVersion.java 62 // 63 // To exclude the generated code from IntelliJ auto-formatting enable (one-time): 64 // Settings > Editor > Code Style > Formatter Control 65 //@formatter:off 66 67 68 /** 69 * Creates a new HostUsiVersion. 70 * 71 * @param majorVersion 72 * The major USI version supported by the input device. 73 * For example, if the device supports USI 2.0, this will return 2. 74 * @param minorVersion 75 * The minor USI version supported by the input device. 76 * For example, if the device supports USI 2.0, this will return 0. 77 * @hide 78 */ 79 @DataClass.Generated.Member HostUsiVersion( int majorVersion, int minorVersion)80 public HostUsiVersion( 81 int majorVersion, 82 int minorVersion) { 83 this.mMajorVersion = majorVersion; 84 this.mMinorVersion = minorVersion; 85 86 // onConstructed(); // You can define this method to get a callback 87 } 88 89 /** 90 * The major USI version supported by the input device. 91 * For example, if the device supports USI 2.0, this will return 2. 92 */ 93 @DataClass.Generated.Member getMajorVersion()94 public int getMajorVersion() { 95 return mMajorVersion; 96 } 97 98 /** 99 * The minor USI version supported by the input device. 100 * For example, if the device supports USI 2.0, this will return 0. 101 */ 102 @DataClass.Generated.Member getMinorVersion()103 public int getMinorVersion() { 104 return mMinorVersion; 105 } 106 107 @Override 108 @DataClass.Generated.Member toString()109 public String toString() { 110 // You can override field toString logic by defining methods like: 111 // String fieldNameToString() { ... } 112 113 return "HostUsiVersion { " + 114 "majorVersion = " + mMajorVersion + ", " + 115 "minorVersion = " + mMinorVersion + 116 " }"; 117 } 118 119 @Override 120 @DataClass.Generated.Member equals(@ndroid.annotation.Nullable Object o)121 public boolean equals(@android.annotation.Nullable Object o) { 122 // You can override field equality logic by defining either of the methods like: 123 // boolean fieldNameEquals(HostUsiVersion other) { ... } 124 // boolean fieldNameEquals(FieldType otherValue) { ... } 125 126 if (this == o) return true; 127 if (o == null || getClass() != o.getClass()) return false; 128 @SuppressWarnings("unchecked") 129 HostUsiVersion that = (HostUsiVersion) o; 130 //noinspection PointlessBooleanExpression 131 return true 132 && mMajorVersion == that.mMajorVersion 133 && mMinorVersion == that.mMinorVersion; 134 } 135 136 @Override 137 @DataClass.Generated.Member hashCode()138 public int hashCode() { 139 // You can override field hashCode logic by defining methods like: 140 // int fieldNameHashCode() { ... } 141 142 int _hash = 1; 143 _hash = 31 * _hash + mMajorVersion; 144 _hash = 31 * _hash + mMinorVersion; 145 return _hash; 146 } 147 148 @Override 149 @DataClass.Generated.Member writeToParcel(@ndroid.annotation.NonNull android.os.Parcel dest, int flags)150 public void writeToParcel(@android.annotation.NonNull android.os.Parcel dest, int flags) { 151 // You can override field parcelling by defining methods like: 152 // void parcelFieldName(Parcel dest, int flags) { ... } 153 154 dest.writeInt(mMajorVersion); 155 dest.writeInt(mMinorVersion); 156 } 157 158 @Override 159 @DataClass.Generated.Member describeContents()160 public int describeContents() { return 0; } 161 162 /** @hide */ 163 @SuppressWarnings({"unchecked", "RedundantCast"}) 164 @DataClass.Generated.Member HostUsiVersion(@ndroid.annotation.NonNull android.os.Parcel in)165 /* package-private */ HostUsiVersion(@android.annotation.NonNull android.os.Parcel in) { 166 // You can override field unparcelling by defining methods like: 167 // static FieldType unparcelFieldName(Parcel in) { ... } 168 169 int majorVersion = in.readInt(); 170 int minorVersion = in.readInt(); 171 172 this.mMajorVersion = majorVersion; 173 this.mMinorVersion = minorVersion; 174 175 // onConstructed(); // You can define this method to get a callback 176 } 177 178 @DataClass.Generated.Member 179 public static final @android.annotation.NonNull Parcelable.Creator<HostUsiVersion> CREATOR 180 = new Parcelable.Creator<HostUsiVersion>() { 181 @Override 182 public HostUsiVersion[] newArray(int size) { 183 return new HostUsiVersion[size]; 184 } 185 186 @Override 187 public HostUsiVersion createFromParcel(@android.annotation.NonNull android.os.Parcel in) { 188 return new HostUsiVersion(in); 189 } 190 }; 191 192 @DataClass.Generated( 193 time = 1673884256908L, 194 codegenVersion = "1.0.23", 195 sourceFile = "frameworks/base/core/java/android/hardware/input/HostUsiVersion.java", 196 inputSignatures = "private final int mMajorVersion\nprivate final int mMinorVersion\npublic boolean isValid()\nclass HostUsiVersion extends java.lang.Object implements [android.os.Parcelable]\n@com.android.internal.util.DataClass(genParcelable=true, genHiddenConstructor=true, genToString=true, genEqualsHashCode=true)") 197 @Deprecated __metadata()198 private void __metadata() {} 199 200 201 //@formatter:on 202 // End of generated code 203 204 } 205