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 
22 import java.lang.annotation.Retention;
23 import java.lang.annotation.RetentionPolicy;
24 
25 /**
26  * Detailed error codes used in vehicle HAL interface.
27  *
28  * The list of error codes may be extended in future releases to include
29  * additional values.
30  */
31 public final class PropertyNotAvailableErrorCode {
32     /**
33      * General not available error code. Used to support backward compatibility and when other
34      * error codes don't cover the not available reason.
35      */
36     public static final int NOT_AVAILABLE = 0;
37 
38     /**
39      * For features that are not available because the underlying feature is disabled.
40      */
41     public static final int NOT_AVAILABLE_DISABLED = 1;
42     /**
43      * For features that are not available because the vehicle speed is too low.
44      */
45     public static final int NOT_AVAILABLE_SPEED_LOW = 2;
46     /**
47      * For features that are not available because the vehicle speed is too high.
48      */
49     public static final int NOT_AVAILABLE_SPEED_HIGH = 3;
50     /**
51      * For features that are not available because of bad camera or sensor visibility. Examples
52      * might be bird poop blocking the camera or a bumper cover blocking an ultrasonic sensor.
53      */
54     public static final int NOT_AVAILABLE_POOR_VISIBILITY = 4;
55     /**
56      * The feature cannot be accessed due to safety reasons. Eg. System could be
57      * in a faulty state, an object or person could be blocking the requested
58      * operation such as closing a trunk door, etc..
59      */
60     public static final int NOT_AVAILABLE_SAFETY = 5;
61 
62     /**
63      * Returns a user-friendly representation of a {@code PropertyNotAvailableErrorCode}.
64      */
65     @NonNull
toString( @ropertyNotAvailableErrorCodeInt int propertyNotAvailableErrorCode)66     public static String toString(
67             @PropertyNotAvailableErrorCodeInt int propertyNotAvailableErrorCode) {
68         switch (propertyNotAvailableErrorCode) {
69             case NOT_AVAILABLE:
70                 return "NOT_AVAILABLE";
71             case NOT_AVAILABLE_DISABLED:
72                 return "NOT_AVAILABLE_DISABLED";
73             case NOT_AVAILABLE_SPEED_LOW:
74                 return "NOT_AVAILABLE_SPEED_LOW";
75             case NOT_AVAILABLE_SPEED_HIGH:
76                 return "NOT_AVAILABLE_SPEED_HIGH";
77             case NOT_AVAILABLE_POOR_VISIBILITY:
78                 return "NOT_AVAILABLE_POOR_VISIBILITY";
79             case NOT_AVAILABLE_SAFETY:
80                 return "NOT_AVAILABLE_SAFETY";
81             default:
82                 return Integer.toString(propertyNotAvailableErrorCode);
83         }
84     }
85 
86     /** @hide */
87     @IntDef({NOT_AVAILABLE, NOT_AVAILABLE_DISABLED,
88         NOT_AVAILABLE_SPEED_LOW, NOT_AVAILABLE_SPEED_HIGH,
89         NOT_AVAILABLE_POOR_VISIBILITY, NOT_AVAILABLE_SAFETY})
90     @Retention(RetentionPolicy.SOURCE)
91     public @interface PropertyNotAvailableErrorCodeInt {}
92 
PropertyNotAvailableErrorCode()93     private PropertyNotAvailableErrorCode() {}
94 }
95