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 state of {@link 33 * android.car.VehiclePropertyIds#DRIVER_DROWSINESS_ATTENTION_STATE}. 34 * 35 * <p>This list of states may be extended in future releases to include additional states. 36 * 37 * @hide 38 */ 39 @FlaggedApi(FLAG_ANDROID_VIC_VEHICLE_PROPERTIES) 40 @SystemApi 41 public final class DriverDrowsinessAttentionState { 42 /** 43 * This state is used as an alternative for any {@code DriverDrowsinessAttentionState} value 44 * that is not defined in the platform. Ideally, implementations of {@link 45 * android.car.VehiclePropertyIds#DRIVER_DROWSINESS_ATTENTION_STATE} should not use this state. 46 * The framework can use this field to remain backwards compatible if {@code 47 * DriverDrowsinessAttentionState} is extended to include additional states. 48 */ 49 public static final int OTHER = 0; 50 51 /** 52 * Karolinska Sleepiness Scale Rating 1 described as extermely alert. 53 */ 54 public static final int KSS_RATING_1_EXTREMELY_ALERT = 1; 55 56 /** 57 * Karolinska Sleepiness Scale Rating 2 described as very alert. 58 */ 59 public static final int KSS_RATING_2_VERY_ALERT = 2; 60 61 /** 62 * Karolinska Sleepiness Scale Rating 3 described as alert. 63 */ 64 public static final int KSS_RATING_3_ALERT = 3; 65 66 /** 67 * Karolinska Sleepiness Scale Rating 4 described as rather alert. 68 */ 69 public static final int KSS_RATING_4_RATHER_ALERT = 4; 70 71 /** 72 * Karolinska Sleepiness Scale Rating 5 described as neither alert nor sleepy. 73 */ 74 public static final int KSS_RATING_5_NEITHER_ALERT_NOR_SLEEPY = 5; 75 76 /** 77 * Karolinska Sleepiness Scale Rating 6 described as some signs of sleepiness. 78 */ 79 public static final int KSS_RATING_6_SOME_SLEEPINESS = 6; 80 81 /** 82 * Karolinska Sleepiness Scale Rating 7 described as sleepy with no effort to keep awake. 83 */ 84 public static final int KSS_RATING_7_SLEEPY_NO_EFFORT = 7; 85 86 /** 87 * Karolinska Sleepiness Scale Rating 8 described as sleepy with some effort to keep awake. 88 */ 89 public static final int KSS_RATING_8_SLEEPY_SOME_EFFORT = 8; 90 91 /** 92 * Karolinska Sleepiness Scale Rating 9 described as very sleepy, with great effort to keep 93 * away, and fighthing sleep. 94 */ 95 public static final int KSS_RATING_9_VERY_SLEEPY = 9; 96 DriverDrowsinessAttentionState()97 private DriverDrowsinessAttentionState() {} 98 99 /** 100 * Returns a user-friendly representation of a {@code DriverDrowsinessAttentionState}. 101 */ 102 @NonNull toString( @riverDrowsinessAttentionStateInt int driverDrowsinessAttentionState)103 public static String toString( 104 @DriverDrowsinessAttentionStateInt int driverDrowsinessAttentionState) { 105 String driverDrowsinessAttentionStateString = ConstantDebugUtils.toName( 106 DriverDrowsinessAttentionState.class, driverDrowsinessAttentionState); 107 return (driverDrowsinessAttentionStateString != null) 108 ? driverDrowsinessAttentionStateString 109 : "0x" + Integer.toHexString(driverDrowsinessAttentionState); 110 } 111 112 /** @hide */ 113 @IntDef({ 114 OTHER, 115 KSS_RATING_1_EXTREMELY_ALERT, 116 KSS_RATING_2_VERY_ALERT, KSS_RATING_3_ALERT, 117 KSS_RATING_4_RATHER_ALERT, 118 KSS_RATING_5_NEITHER_ALERT_NOR_SLEEPY, 119 KSS_RATING_6_SOME_SLEEPINESS, 120 KSS_RATING_7_SLEEPY_NO_EFFORT, 121 KSS_RATING_8_SLEEPY_SOME_EFFORT, 122 KSS_RATING_9_VERY_SLEEPY}) 123 @Retention(RetentionPolicy.SOURCE) 124 public @interface DriverDrowsinessAttentionStateInt {} 125 } 126