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