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 android.car.input; 18 19 import static com.android.car.internal.ExcludeFromCodeCoverageGeneratedReport.BOILERPLATE_CODE; 20 21 import android.annotation.NonNull; 22 import android.annotation.SystemApi; 23 import android.os.Parcel; 24 import android.os.Parcelable; 25 26 import com.android.car.internal.ExcludeFromCodeCoverageGeneratedReport; 27 import com.android.internal.util.DataClass; 28 29 /** 30 * {@code Parcelable} containing custom input event. 31 * 32 * <p>A custom input event representing HW_CUSTOM_INPUT event defined in 33 * {@code hardware/interfaces/automotive/vehicle/2.0/types.hal}. 34 * 35 * @hide 36 */ 37 // Note: When re-generating code, make sure inputCodeToString raises an exception in case of invalid 38 // input. 39 // TODO(b/12219669): Check with INPUT_CODE_Fn constants should move to 40 // android/car/Constants/CommonConstants.java. If keeping these constants, than add unit tests. 41 @SystemApi 42 @DataClass( 43 genEqualsHashCode = true, 44 genAidl = true) 45 public final class CustomInputEvent implements Parcelable { 46 47 // The following constant values must be in sync with the ones defined in 48 // {@code hardware/interfaces/automotive/vehicle/2.0/types.hal} 49 public static final int INPUT_CODE_F1 = 1001; 50 public static final int INPUT_CODE_F2 = 1002; 51 public static final int INPUT_CODE_F3 = 1003; 52 public static final int INPUT_CODE_F4 = 1004; 53 public static final int INPUT_CODE_F5 = 1005; 54 public static final int INPUT_CODE_F6 = 1006; 55 public static final int INPUT_CODE_F7 = 1007; 56 public static final int INPUT_CODE_F8 = 1008; 57 public static final int INPUT_CODE_F9 = 1009; 58 public static final int INPUT_CODE_F10 = 1010; 59 60 @InputCode 61 private final int mInputCode; 62 63 private final int mTargetDisplayType; 64 private final int mRepeatCounter; 65 66 67 // Code below generated by codegen v1.0.15. 68 // 69 // DO NOT MODIFY! 70 // CHECKSTYLE:OFF Generated code 71 // 72 // To regenerate run: 73 // $ codegen --to-string $ANDROID_BUILD_TOP/packages/services/Car/car-lib/src/android/car 74 // /input/CustomInputEvent.java 75 // 76 // To exclude the generated code from IntelliJ auto-formatting enable (one-time): 77 // Settings > Editor > Code Style > Formatter Control 78 //@formatter:off 79 80 /** @hide */ 81 @android.annotation.IntDef(prefix = "INPUT_CODE_", value = { 82 INPUT_CODE_F1, 83 INPUT_CODE_F2, 84 INPUT_CODE_F3, 85 INPUT_CODE_F4, 86 INPUT_CODE_F5, 87 INPUT_CODE_F6, 88 INPUT_CODE_F7, 89 INPUT_CODE_F8, 90 INPUT_CODE_F9, 91 INPUT_CODE_F10 92 }) 93 @java.lang.annotation.Retention(java.lang.annotation.RetentionPolicy.SOURCE) 94 @DataClass.Generated.Member 95 public @interface InputCode { 96 } 97 98 @DataClass.Generated.Member 99 @NonNull inputCodeToString(@nputCode int value)100 public static String inputCodeToString(@InputCode int value) { 101 switch (value) { 102 case INPUT_CODE_F1: 103 return "INPUT_CODE_F1"; 104 case INPUT_CODE_F2: 105 return "INPUT_CODE_F2"; 106 case INPUT_CODE_F3: 107 return "INPUT_CODE_F3"; 108 case INPUT_CODE_F4: 109 return "INPUT_CODE_F4"; 110 case INPUT_CODE_F5: 111 return "INPUT_CODE_F5"; 112 case INPUT_CODE_F6: 113 return "INPUT_CODE_F6"; 114 case INPUT_CODE_F7: 115 return "INPUT_CODE_F7"; 116 case INPUT_CODE_F8: 117 return "INPUT_CODE_F8"; 118 case INPUT_CODE_F9: 119 return "INPUT_CODE_F9"; 120 case INPUT_CODE_F10: 121 return "INPUT_CODE_F10"; 122 default: 123 throw new java.lang.IllegalArgumentException( 124 "Invalid inputCode {" + value + "}"); 125 } 126 } 127 128 @DataClass.Generated.Member CustomInputEvent( @nputCode int inputCode, int targetDisplayType, int repeatCounter)129 public CustomInputEvent( 130 @InputCode int inputCode, 131 int targetDisplayType, 132 int repeatCounter) { 133 this.mInputCode = inputCode; 134 135 if (!(mInputCode == INPUT_CODE_F1) 136 && !(mInputCode == INPUT_CODE_F2) 137 && !(mInputCode == INPUT_CODE_F3) 138 && !(mInputCode == INPUT_CODE_F4) 139 && !(mInputCode == INPUT_CODE_F5) 140 && !(mInputCode == INPUT_CODE_F6) 141 && !(mInputCode == INPUT_CODE_F7) 142 && !(mInputCode == INPUT_CODE_F8) 143 && !(mInputCode == INPUT_CODE_F9) 144 && !(mInputCode == INPUT_CODE_F10)) { 145 throw new java.lang.IllegalArgumentException( 146 "inputCode was " + mInputCode + " but must be one of: " 147 + "INPUT_CODE_F1(" + INPUT_CODE_F1 + "), " 148 + "INPUT_CODE_F2(" + INPUT_CODE_F2 + "), " 149 + "INPUT_CODE_F3(" + INPUT_CODE_F3 + "), " 150 + "INPUT_CODE_F4(" + INPUT_CODE_F4 + "), " 151 + "INPUT_CODE_F5(" + INPUT_CODE_F5 + "), " 152 + "INPUT_CODE_F6(" + INPUT_CODE_F6 + "), " 153 + "INPUT_CODE_F7(" + INPUT_CODE_F7 + "), " 154 + "INPUT_CODE_F8(" + INPUT_CODE_F8 + "), " 155 + "INPUT_CODE_F9(" + INPUT_CODE_F9 + "), " 156 + "INPUT_CODE_F10(" + INPUT_CODE_F10 + ")"); 157 } 158 159 this.mTargetDisplayType = targetDisplayType; 160 this.mRepeatCounter = repeatCounter; 161 162 // onConstructed(); // You can define this method to get a callback 163 } 164 165 @DataClass.Generated.Member 166 public @InputCode getInputCode()167 int getInputCode() { 168 return mInputCode; 169 } 170 171 @DataClass.Generated.Member getTargetDisplayType()172 public int getTargetDisplayType() { 173 return mTargetDisplayType; 174 } 175 176 @DataClass.Generated.Member getRepeatCounter()177 public int getRepeatCounter() { 178 return mRepeatCounter; 179 } 180 181 @Override 182 @DataClass.Generated.Member 183 @ExcludeFromCodeCoverageGeneratedReport(reason = BOILERPLATE_CODE) toString()184 public String toString() { 185 // You can override field toString logic by defining methods like: 186 // String fieldNameToString() { ... } 187 188 return "CustomInputEvent { " + 189 "inputCode = " + inputCodeToString(mInputCode) + ", " + 190 "targetDisplayType = " + mTargetDisplayType + ", " + 191 "repeatCounter = " + mRepeatCounter + 192 " }"; 193 } 194 195 @Override 196 @DataClass.Generated.Member 197 @ExcludeFromCodeCoverageGeneratedReport(reason = BOILERPLATE_CODE) equals(@ndroid.annotation.Nullable Object o)198 public boolean equals(@android.annotation.Nullable Object o) { 199 // You can override field equality logic by defining either of the methods like: 200 // boolean fieldNameEquals(CustomInputEvent other) { ... } 201 // boolean fieldNameEquals(FieldType otherValue) { ... } 202 203 if (this == o) return true; 204 if (o == null || getClass() != o.getClass()) return false; 205 @SuppressWarnings("unchecked") 206 CustomInputEvent that = (CustomInputEvent) o; 207 //noinspection PointlessBooleanExpression 208 return true 209 && mInputCode == that.mInputCode 210 && mTargetDisplayType == that.mTargetDisplayType 211 && mRepeatCounter == that.mRepeatCounter; 212 } 213 214 @Override 215 @DataClass.Generated.Member 216 @ExcludeFromCodeCoverageGeneratedReport(reason = BOILERPLATE_CODE) hashCode()217 public int hashCode() { 218 // You can override field hashCode logic by defining methods like: 219 // int fieldNameHashCode() { ... } 220 221 int _hash = 1; 222 _hash = 31 * _hash + mInputCode; 223 _hash = 31 * _hash + mTargetDisplayType; 224 _hash = 31 * _hash + mRepeatCounter; 225 return _hash; 226 } 227 228 @Override 229 @DataClass.Generated.Member writeToParcel(@onNull Parcel dest, int flags)230 public void writeToParcel(@NonNull Parcel dest, int flags) { 231 // You can override field parcelling by defining methods like: 232 // void parcelFieldName(Parcel dest, int flags) { ... } 233 234 dest.writeInt(mInputCode); 235 dest.writeInt(mTargetDisplayType); 236 dest.writeInt(mRepeatCounter); 237 } 238 239 @Override 240 @DataClass.Generated.Member 241 @ExcludeFromCodeCoverageGeneratedReport(reason = BOILERPLATE_CODE) describeContents()242 public int describeContents() { 243 return 0; 244 } 245 246 /** @hide */ 247 @SuppressWarnings({"unchecked", "RedundantCast"}) 248 @DataClass.Generated.Member CustomInputEvent(@onNull Parcel in)249 /* package-private */ CustomInputEvent(@NonNull Parcel in) { 250 // You can override field unparcelling by defining methods like: 251 // static FieldType unparcelFieldName(Parcel in) { ... } 252 253 int inputCode = in.readInt(); 254 int targetDisplayType = in.readInt(); 255 int repeatCounter = in.readInt(); 256 257 this.mInputCode = inputCode; 258 259 if (!(mInputCode == INPUT_CODE_F1) 260 && !(mInputCode == INPUT_CODE_F2) 261 && !(mInputCode == INPUT_CODE_F3) 262 && !(mInputCode == INPUT_CODE_F4) 263 && !(mInputCode == INPUT_CODE_F5) 264 && !(mInputCode == INPUT_CODE_F6) 265 && !(mInputCode == INPUT_CODE_F7) 266 && !(mInputCode == INPUT_CODE_F8) 267 && !(mInputCode == INPUT_CODE_F9) 268 && !(mInputCode == INPUT_CODE_F10)) { 269 throw new java.lang.IllegalArgumentException( 270 "inputCode was " + mInputCode + " but must be one of: " 271 + "INPUT_CODE_F1(" + INPUT_CODE_F1 + "), " 272 + "INPUT_CODE_F2(" + INPUT_CODE_F2 + "), " 273 + "INPUT_CODE_F3(" + INPUT_CODE_F3 + "), " 274 + "INPUT_CODE_F4(" + INPUT_CODE_F4 + "), " 275 + "INPUT_CODE_F5(" + INPUT_CODE_F5 + "), " 276 + "INPUT_CODE_F6(" + INPUT_CODE_F6 + "), " 277 + "INPUT_CODE_F7(" + INPUT_CODE_F7 + "), " 278 + "INPUT_CODE_F8(" + INPUT_CODE_F8 + "), " 279 + "INPUT_CODE_F9(" + INPUT_CODE_F9 + "), " 280 + "INPUT_CODE_F10(" + INPUT_CODE_F10 + ")"); 281 } 282 283 this.mTargetDisplayType = targetDisplayType; 284 this.mRepeatCounter = repeatCounter; 285 286 // onConstructed(); // You can define this method to get a callback 287 } 288 289 @DataClass.Generated.Member 290 public static final @NonNull 291 Parcelable.Creator<CustomInputEvent> CREATOR 292 = new Parcelable.Creator<CustomInputEvent>() { 293 @Override 294 public CustomInputEvent[] newArray(int size) { 295 return new CustomInputEvent[size]; 296 } 297 298 @Override 299 public CustomInputEvent createFromParcel(@NonNull Parcel in) { 300 return new CustomInputEvent(in); 301 } 302 }; 303 304 @DataClass.Generated( 305 time = 1600715769152L, 306 codegenVersion = "1.0.15", 307 sourceFile = "packages/services/Car/car-lib/src/android/car/input/CustomInputEvent" 308 + ".java", 309 inputSignatures = "public static final int INPUT_CODE_F1\npublic static final int " 310 + "INPUT_CODE_F2\npublic static final int INPUT_CODE_F3\npublic static final" 311 + " int INPUT_CODE_F4\npublic static final int INPUT_CODE_F5\npublic static" 312 + " final int INPUT_CODE_F6\npublic static final int INPUT_CODE_F7\npublic " 313 + "static final int INPUT_CODE_F8\npublic static final int " 314 + "INPUT_CODE_F9\npublic static final int INPUT_CODE_F10\nprivate final " 315 + "@android.car.input.CustomInputEvent.InputCode int mInputCode\nprivate " 316 + "final int mTargetDisplayType\nprivate final int mRepeatCounter\nclass " 317 + "CustomInputEvent extends java.lang.Object implements [android.os" 318 + ".Parcelable]\n@com.android.internal.util.DataClass(genEqualsHashCode=true," 319 + " genAidl=true)") 320 @Deprecated 321 @ExcludeFromCodeCoverageGeneratedReport(reason = BOILERPLATE_CODE) __metadata()322 private void __metadata() { 323 } 324 325 //@formatter:on 326 // End of generated code 327 } 328 329