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 static android.car.feature.Flags.FLAG_ANDROID_VIC_VEHICLE_PROPERTIES; 20 21 import android.annotation.FlaggedApi; 22 import android.annotation.IntDef; 23 import android.annotation.NonNull; 24 import android.annotation.SystemApi; 25 26 import com.android.car.internal.util.ConstantDebugUtils; 27 28 import java.lang.annotation.Retention; 29 import java.lang.annotation.RetentionPolicy; 30 31 /** 32 * Used to enumerate the current warning state of {@link 33 * android.car.VehiclePropertyIds#DRIVER_DISTRACTION_WARNING}. 34 * 35 * <p>This enum could be extended in future releases to include additional feature states. 36 * 37 * @hide 38 */ 39 @FlaggedApi(FLAG_ANDROID_VIC_VEHICLE_PROPERTIES) 40 @SystemApi 41 public final class DriverDistractionWarning { 42 /** 43 * This state is used as an alternative for any {@code DriverDistractionWarning} value 44 * that is not defined in the platform. Ideally, implementations of {@link 45 * android.car.VehiclePropertyIds#DRIVER_DISTRACTION_WARNING} should not use this 46 * state. The framework can use this field to remain backwards compatible if {@code 47 * DriverDistractionWarning} is extended to include additional states. 48 */ 49 public static final int OTHER = 0; 50 /** 51 * When the driver distraction warning is enabled and the driver's current distraction level 52 * does not warrant the system to send a warning. 53 */ 54 public static final int NO_WARNING = 1; 55 /** 56 * When the driver distraction warning is enabled and the system is warning the driver based on 57 * its assessment of the driver's current distraction level. 58 */ 59 public static final int WARNING = 2; 60 DriverDistractionWarning()61 private DriverDistractionWarning() {} 62 63 /** 64 * Returns a user-friendly representation of a {@code DriverDistractionWarning}. 65 */ 66 @NonNull toString( @riverDistractionWarning.DriverDistractionWarningInt int driverDistractionWarning)67 public static String toString( 68 @DriverDistractionWarning.DriverDistractionWarningInt 69 int driverDistractionWarning) { 70 String driverDistractionWarningString = ConstantDebugUtils.toName( 71 DriverDistractionWarning.class, driverDistractionWarning); 72 return (driverDistractionWarningString != null) 73 ? driverDistractionWarningString 74 : "0x" + Integer.toHexString(driverDistractionWarning); 75 } 76 77 /** @hide */ 78 @IntDef({OTHER, NO_WARNING, WARNING}) 79 @Retention(RetentionPolicy.SOURCE) 80 public @interface DriverDistractionWarningInt {} 81 } 82