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