1 /*
2  * Copyright (C) 2021 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.evs;
18 
19 import android.annotation.NonNull;
20 import android.annotation.SystemApi;
21 import android.car.Car;
22 import android.car.annotation.RequiredFeature;
23 import android.car.evs.CarEvsManager.CarEvsServiceState;
24 import android.car.evs.CarEvsManager.CarEvsServiceType;
25 import android.os.Parcel;
26 import android.os.Parcelable;
27 
28 /**
29  * Describes current status of CarEvsService with its current state and service type.
30  *
31  * @hide
32  */
33 @SystemApi
34 @RequiredFeature(Car.CAR_EVS_SERVICE)
35 public final class CarEvsStatus implements Parcelable {
36     public static final @NonNull Parcelable.Creator<CarEvsStatus> CREATOR =
37             new Parcelable.Creator<CarEvsStatus>() {
38                 @NonNull
39                 @Override
40                 public CarEvsStatus createFromParcel(final Parcel in) {
41                     return new CarEvsStatus(in);
42                 }
43 
44                 @NonNull
45                 @Override
46                 public CarEvsStatus[] newArray(final int size) {
47                     return new CarEvsStatus[size];
48                 }
49             };
50 
51     private final @CarEvsServiceType int mServiceType;
52     private final @CarEvsServiceState int mState;
53 
54     /**
55      * Creates a {@link CarEvsStatus} with a current state and type of CarEvsService.
56      *
57      * @param type {@link android.car.evs.CarEvsManager.CarEvsServiceType}
58      * @param state {@link android.car.evs.CarEvsManager.CarEvsServiceState}
59      */
CarEvsStatus(@arEvsServiceType int type, @CarEvsServiceState int state)60     public CarEvsStatus(@CarEvsServiceType int type, @CarEvsServiceState int state) {
61         mServiceType = type;
62         mState = state;
63     }
64 
65     /** Parcelable methods */
CarEvsStatus(final Parcel in)66     private CarEvsStatus(final Parcel in) {
67         mServiceType = in.readInt();
68         mState = in.readInt();
69     }
70 
71     @Override
describeContents()72     public int describeContents() {
73         return 0;
74     }
75 
76     @Override
writeToParcel(@onNull final Parcel dest, final int flags)77     public void writeToParcel(@NonNull final Parcel dest, final int flags) {
78         dest.writeInt(mServiceType);
79         dest.writeInt(mState);
80     }
81 
82     @Override
toString()83     public String toString() {
84         return "CarEvsStatus: mServiceType = " + mServiceType + " + mState + " + mState;
85     }
86 
87     /**
88      * Returns a current state of CarEvsService
89      *
90      * @return {@link android.car.evs.CarEvsManager.CarEvsServiceState}
91      */
getState()92     public @CarEvsServiceState int getState() {
93         return mState;
94     }
95 
96     /**
97      * Returns a type of what CarEvsService currently provides
98      *
99      * @return {@link android.car.evs.CarEvsManager.CarEvsServiceType}
100      */
getServiceType()101     public @CarEvsServiceType int getServiceType() {
102         return mServiceType;
103     }
104 }
105