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.car.hardware.property; 18 19 import android.annotation.IntDef; 20 import android.annotation.NonNull; 21 import android.annotation.SystemApi; 22 import android.car.annotation.ApiRequirements; 23 24 import java.lang.annotation.Retention; 25 import java.lang.annotation.RetentionPolicy; 26 27 /** 28 * Used to enumerate the current warning state of {@link 29 * android.car.VehiclePropertyIds#HANDS_ON_DETECTION_WARNING}. 30 * 31 * <p>This enum could be extended in future releases to include additional feature states. 32 * @hide 33 */ 34 @SystemApi 35 public class HandsOnDetectionWarning { 36 /** 37 * This state is used as an alternative for any {@code HandsOnDetectionWarning} value that is 38 * not defined in the platform. Ideally, implementations of {@link 39 * android.car.VehiclePropertyIds#HANDS_ON_DETECTION_WARNING} should not use this state. The 40 * framework can use this field to remain backwards compatible if {@code 41 * HandsOnDetectionWarning} is extended to include additional states. 42 */ 43 @ApiRequirements(minCarVersion = ApiRequirements.CarVersion.UPSIDE_DOWN_CAKE_0, 44 minPlatformVersion = ApiRequirements.PlatformVersion.TIRAMISU_0) 45 public static final int OTHER = 0; 46 /** 47 * HOD is enabled and the driver's current safety does not warrant sending a warning. This state 48 * is independent of whether the driver actually has their hands on or off the wheel. 49 */ 50 @ApiRequirements(minCarVersion = ApiRequirements.CarVersion.UPSIDE_DOWN_CAKE_0, 51 minPlatformVersion = ApiRequirements.PlatformVersion.TIRAMISU_0) 52 public static final int NO_WARNING = 1; 53 /** 54 * HOD is enabled and the driver's hands have been off the wheel for too long a duration, and 55 * the vehicle is sending a warning to the driver as a consequence of this. 56 */ 57 @ApiRequirements(minCarVersion = ApiRequirements.CarVersion.UPSIDE_DOWN_CAKE_0, 58 minPlatformVersion = ApiRequirements.PlatformVersion.TIRAMISU_0) 59 public static final int WARNING = 2; 60 HandsOnDetectionWarning()61 private HandsOnDetectionWarning() {} 62 63 /** 64 * Returns a user-friendly representation of a {@code HandsOnDetectionWarning}. 65 */ 66 @NonNull 67 @ApiRequirements(minCarVersion = ApiRequirements.CarVersion.UPSIDE_DOWN_CAKE_0, 68 minPlatformVersion = ApiRequirements.PlatformVersion.TIRAMISU_0) toString( @andsOnDetectionWarning.HandsOnDetectionWarningInt int handsOnDetectionWarning)69 public static String toString( 70 @HandsOnDetectionWarning.HandsOnDetectionWarningInt int handsOnDetectionWarning) { 71 switch (handsOnDetectionWarning) { 72 case OTHER: 73 return "OTHER"; 74 case NO_WARNING: 75 return "NO_WARNING"; 76 case WARNING: 77 return "WARNING"; 78 default: 79 return "0x" + Integer.toHexString(handsOnDetectionWarning); 80 } 81 } 82 83 /** @hide */ 84 @IntDef({OTHER, NO_WARNING, WARNING}) 85 @Retention(RetentionPolicy.SOURCE) 86 public @interface HandsOnDetectionWarningInt {} 87 } 88