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 23 import java.lang.annotation.Retention; 24 import java.lang.annotation.RetentionPolicy; 25 26 /** 27 * Used to enumerate the possible error states. For Android 14, {@code ErrorState} is used by ADAS 28 * STATE properties in {@link android.car.VehiclePropertyIds}, but its use may be expanded in future 29 * releases. 30 * 31 * <p>This list of states may be extended in future releases to include additional states. 32 * @hide 33 */ 34 @SystemApi 35 public final class ErrorState { 36 /** 37 * This state is used as an alternative for any {@code ErrorState} value that is not defined in 38 * the platform. Ideally, implementations of vehicle properties should not use this state. The 39 * framework can use this field to remain backwards compatible if this enum is extended to 40 * include additional states. 41 */ 42 public static final int OTHER_ERROR_STATE = -1; 43 44 /** 45 * Vehicle property is not available because the feature is disabled. 46 */ 47 public static final int NOT_AVAILABLE_DISABLED = -2; 48 49 /** 50 * Vehicle property is not available because the vehicle speed is too low to use this feature. 51 */ 52 public static final int NOT_AVAILABLE_SPEED_LOW = -3; 53 54 /** 55 * Vehicle property is not available because the vehicle speed is too high to use this feature. 56 */ 57 public static final int NOT_AVAILABLE_SPEED_HIGH = -4; 58 59 /** 60 * Vehicle property is not available because sensor or camera visibility is insufficient to use 61 * this feature. For example, this can be caused by bird poop blocking the camera, poor weather 62 * conditions such as snow or fog, or by any object obstructing the required sensors. 63 */ 64 public static final int NOT_AVAILABLE_POOR_VISIBILITY = -5; 65 66 /** 67 * Vehicle property is not available because there is a safety risk that makes this feature 68 * unavailable to use presently. For example, this can be caused by someone blocking the trunk 69 * door while it is closing, or by the system being in a faulty state. 70 */ 71 public static final int NOT_AVAILABLE_SAFETY = -6; 72 ErrorState()73 private ErrorState() {} 74 75 /** 76 * Returns a user-friendly representation of an {@code ErrorState}. 77 */ 78 @NonNull toString(@rrorStateInt int errorState)79 public static String toString(@ErrorStateInt int errorState) { 80 switch (errorState) { 81 case OTHER_ERROR_STATE: 82 return "OTHER_ERROR_STATE"; 83 case NOT_AVAILABLE_DISABLED: 84 return "NOT_AVAILABLE_DISABLED"; 85 case NOT_AVAILABLE_SPEED_LOW: 86 return "NOT_AVAILABLE_SPEED_LOW"; 87 case NOT_AVAILABLE_SPEED_HIGH: 88 return "NOT_AVAILABLE_SPEED_HIGH"; 89 case NOT_AVAILABLE_POOR_VISIBILITY: 90 return "NOT_AVAILABLE_POOR_VISIBILITY"; 91 case NOT_AVAILABLE_SAFETY: 92 return "NOT_AVAILABLE_SAFETY"; 93 default: 94 return "0x" + Integer.toHexString(errorState); 95 } 96 } 97 98 /** @hide */ 99 @IntDef({OTHER_ERROR_STATE, NOT_AVAILABLE_DISABLED, NOT_AVAILABLE_SPEED_LOW, 100 NOT_AVAILABLE_SPEED_HIGH, NOT_AVAILABLE_POOR_VISIBILITY, NOT_AVAILABLE_SAFETY}) 101 @Retention(RetentionPolicy.SOURCE) 102 public @interface ErrorStateInt {} 103 } 104 105