1 /* 2 * Copyright (C) 2020 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.occupantawareness; 18 19 import static com.android.car.internal.ExcludeFromCodeCoverageGeneratedReport.BOILERPLATE_CODE; 20 21 import static java.lang.annotation.RetentionPolicy.SOURCE; 22 23 import android.annotation.IntDef; 24 import android.annotation.NonNull; 25 import android.os.Parcel; 26 import android.os.Parcelable; 27 28 import com.android.car.internal.ExcludeFromCodeCoverageGeneratedReport; 29 30 import java.lang.annotation.Retention; 31 32 /** 33 * Current system status. 34 * 35 * <p>Detection system may be ready, not-supported, in a failure mode or not-yet-ready. 36 * 37 * @hide 38 */ 39 public final class SystemStatusEvent implements Parcelable { 40 /** The system is ready to provide data. */ 41 public static final int SYSTEM_STATUS_READY = 0; 42 43 /** 44 * Detection is not supported in this vehicle due to a permanent lack of capabilities. Clients 45 * need not retry. 46 */ 47 public static final int SYSTEM_STATUS_NOT_SUPPORTED = 1; 48 49 /** The system is not yet ready to serve requests. Clients should check back again later. */ 50 public static final int SYSTEM_STATUS_NOT_READY = 2; 51 52 /** 53 * A permanent hardware failure has occurred. Clients need not retry until the underlying 54 * hardware has been fixed. 55 */ 56 public static final int SYSTEM_STATUS_SYSTEM_FAILURE = 3; 57 58 /** 59 * System state status values. 60 * 61 * @hide 62 */ 63 @Retention(SOURCE) 64 @IntDef({ 65 SYSTEM_STATUS_READY, 66 SYSTEM_STATUS_NOT_SUPPORTED, 67 SYSTEM_STATUS_SYSTEM_FAILURE, 68 SYSTEM_STATUS_NOT_READY 69 }) 70 public @interface SystemStatus {} 71 72 /** No detection types are supported. */ 73 public static final int DETECTION_TYPE_NONE = 0; 74 75 /** Presence detection for occupants in the vehicle. */ 76 public static final int DETECTION_TYPE_PRESENCE = 1 << 0; 77 78 /** Gaze data for occupant in the vehicle. */ 79 public static final int DETECTION_TYPE_GAZE = 1 << 1; 80 81 /** Driver monitoring state for the driver in the vehicle. */ 82 public static final int DETECTION_TYPE_DRIVER_MONITORING = 1 << 2; 83 84 /** 85 * Detection types. 86 * 87 * @hide 88 */ 89 @Retention(SOURCE) 90 @IntDef( 91 flag = true, 92 value = { 93 DETECTION_TYPE_PRESENCE, 94 DETECTION_TYPE_GAZE, 95 DETECTION_TYPE_DRIVER_MONITORING 96 }) 97 public @interface DetectionTypeFlags {} 98 99 public final @SystemStatus int systemStatus; 100 public final @DetectionTypeFlags int detectionType; 101 SystemStatusEvent(@ystemStatus int status, @DetectionTypeFlags int type)102 public SystemStatusEvent(@SystemStatus int status, @DetectionTypeFlags int type) { 103 systemStatus = status; 104 detectionType = type; 105 } 106 SystemStatusEvent()107 public SystemStatusEvent() { 108 systemStatus = SYSTEM_STATUS_NOT_READY; 109 detectionType = DETECTION_TYPE_NONE; 110 } 111 112 @Override 113 @ExcludeFromCodeCoverageGeneratedReport(reason = BOILERPLATE_CODE) describeContents()114 public int describeContents() { 115 return 0; 116 } 117 118 @Override writeToParcel(@onNull Parcel dest, int flags)119 public void writeToParcel(@NonNull Parcel dest, int flags) { 120 dest.writeInt(systemStatus); 121 dest.writeInt(detectionType); 122 } 123 124 @Override toString()125 public String toString() { 126 return "SystemStatusEvent{" 127 + "systemStatus=" 128 + systemStatus 129 + ", detectionType=" 130 + detectionType 131 + "}"; 132 } 133 134 public static final @NonNull Parcelable.Creator<SystemStatusEvent> CREATOR = 135 new Parcelable.Creator<SystemStatusEvent>() { 136 public SystemStatusEvent createFromParcel(Parcel in) { 137 return new SystemStatusEvent(in); 138 } 139 140 public SystemStatusEvent[] newArray(int size) { 141 return new SystemStatusEvent[size]; 142 } 143 }; 144 SystemStatusEvent(Parcel in)145 private SystemStatusEvent(Parcel in) { 146 systemStatus = in.readInt(); 147 detectionType = in.readInt(); 148 } 149 } 150