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.watchdog;
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.annotation.UserIdInt;
24 import android.os.Parcelable;
25 
26 import com.android.car.internal.ExcludeFromCodeCoverageGeneratedReport;
27 import com.android.car.internal.util.AnnotationValidations;
28 import com.android.car.internal.util.DataClass;
29 
30 /**
31  * Killable state for a package.
32  *
33  * @hide
34  */
35 @SystemApi
36 @DataClass(genToString = true, genHiddenConstructor = true, genHiddenConstDefs = true)
37 public final class PackageKillableState implements Parcelable {
38     /**
39      * A package is killable.
40      */
41     @KillableState
42     public static final int KILLABLE_STATE_YES = 1;
43 
44     /**
45      * A package is not killable.
46      */
47     @KillableState
48     public static final int KILLABLE_STATE_NO = 2;
49 
50     /**
51      * A package is never killable i.e., it's setting cannot be updated.
52      */
53     @KillableState
54     public static final int KILLABLE_STATE_NEVER = 3;
55 
56     /**
57      * Name of the package.
58      */
59     private @NonNull String mPackageName;
60 
61     /**
62      * Id of the user.
63      */
64     private @UserIdInt int mUserId;
65 
66     /**
67      * Killable state of the user's package.
68      */
69     private @KillableState int mKillableState;
70 
71 
72 
73     // Code below generated by codegen v1.0.23.
74     //
75     // DO NOT MODIFY!
76     // CHECKSTYLE:OFF Generated code
77     //
78     // To regenerate run:
79     // $ codegen $ANDROID_BUILD_TOP/packages/services/Car/car-lib/src/android/car/watchdog/PackageKillableState.java
80     // Added AddedInOrBefore or ApiRequirement Annotation manually
81     //
82     // To exclude the generated code from IntelliJ auto-formatting enable (one-time):
83     //   Settings > Editor > Code Style > Formatter Control
84     //@formatter:off
85 
86 
87     /** @hide */
88     @android.annotation.IntDef(prefix = "KILLABLE_STATE_", value = {
89         KILLABLE_STATE_YES,
90         KILLABLE_STATE_NO,
91         KILLABLE_STATE_NEVER
92     })
93     @java.lang.annotation.Retention(java.lang.annotation.RetentionPolicy.SOURCE)
94     @DataClass.Generated.Member
95     public @interface KillableState {}
96 
97     /** @hide */
98     @DataClass.Generated.Member
killableStateToString(@illableState int value)99     public static String killableStateToString(@KillableState int value) {
100         switch (value) {
101             case KILLABLE_STATE_YES:
102                     return "KILLABLE_STATE_YES";
103             case KILLABLE_STATE_NO:
104                     return "KILLABLE_STATE_NO";
105             case KILLABLE_STATE_NEVER:
106                     return "KILLABLE_STATE_NEVER";
107             default: return Integer.toHexString(value);
108         }
109     }
110 
111     /**
112      * Creates a new PackageKillableState.
113      *
114      * @param packageName
115      *   Name of the package.
116      * @param userId
117      *   Id of the user.
118      * @param killableState
119      *   Killable state of the user's package.
120      * @hide
121      */
122     @DataClass.Generated.Member
PackageKillableState( @onNull String packageName, @UserIdInt int userId, @KillableState int killableState)123     public PackageKillableState(
124             @NonNull String packageName,
125             @UserIdInt int userId,
126             @KillableState int killableState) {
127         this.mPackageName = packageName;
128         AnnotationValidations.validate(
129                 NonNull.class, null, mPackageName);
130         this.mUserId = userId;
131         AnnotationValidations.validate(
132                 UserIdInt.class, null, mUserId);
133         this.mKillableState = killableState;
134 
135         if (!(mKillableState == KILLABLE_STATE_YES)
136                 && !(mKillableState == KILLABLE_STATE_NO)
137                 && !(mKillableState == KILLABLE_STATE_NEVER)) {
138             throw new java.lang.IllegalArgumentException(
139                     "killableState was " + mKillableState + " but must be one of: "
140                             + "KILLABLE_STATE_YES(" + KILLABLE_STATE_YES + "), "
141                             + "KILLABLE_STATE_NO(" + KILLABLE_STATE_NO + "), "
142                             + "KILLABLE_STATE_NEVER(" + KILLABLE_STATE_NEVER + ")");
143         }
144 
145 
146         // onConstructed(); // You can define this method to get a callback
147     }
148 
149     /**
150      * Name of the package.
151      */
152     @DataClass.Generated.Member
getPackageName()153     public @NonNull String getPackageName() {
154         return mPackageName;
155     }
156 
157     /**
158      * Id of the user.
159      */
160     @DataClass.Generated.Member
getUserId()161     public @UserIdInt int getUserId() {
162         return mUserId;
163     }
164 
165     /**
166      * Killable state of the user's package.
167      */
168     @DataClass.Generated.Member
getKillableState()169     public @KillableState int getKillableState() {
170         return mKillableState;
171     }
172 
173     @Override
174     @DataClass.Generated.Member
toString()175     public String toString() {
176         // You can override field toString logic by defining methods like:
177         // String fieldNameToString() { ... }
178 
179         return "PackageKillableState { " +
180                 "packageName = " + mPackageName + ", " +
181                 "userId = " + mUserId + ", " +
182                 "killableState = " + killableStateToString(mKillableState) +
183         " }";
184     }
185 
186     @Override
187     @DataClass.Generated.Member
writeToParcel(@onNull android.os.Parcel dest, int flags)188     public void writeToParcel(@NonNull android.os.Parcel dest, int flags) {
189         // You can override field parcelling by defining methods like:
190         // void parcelFieldName(Parcel dest, int flags) { ... }
191 
192         dest.writeString(mPackageName);
193         dest.writeInt(mUserId);
194         dest.writeInt(mKillableState);
195     }
196 
197     @Override
198     @DataClass.Generated.Member
199     @ExcludeFromCodeCoverageGeneratedReport(reason = BOILERPLATE_CODE)
describeContents()200     public int describeContents() { return 0; }
201 
202     /** @hide */
203     @SuppressWarnings({"unchecked", "RedundantCast"})
204     @DataClass.Generated.Member
PackageKillableState(@onNull android.os.Parcel in)205     /* package-private */ PackageKillableState(@NonNull android.os.Parcel in) {
206         // You can override field unparcelling by defining methods like:
207         // static FieldType unparcelFieldName(Parcel in) { ... }
208 
209         String packageName = in.readString();
210         int userId = in.readInt();
211         int killableState = in.readInt();
212 
213         this.mPackageName = packageName;
214         AnnotationValidations.validate(
215                 NonNull.class, null, mPackageName);
216         this.mUserId = userId;
217         AnnotationValidations.validate(
218                 UserIdInt.class, null, mUserId);
219         this.mKillableState = killableState;
220 
221         if (!(mKillableState == KILLABLE_STATE_YES)
222                 && !(mKillableState == KILLABLE_STATE_NO)
223                 && !(mKillableState == KILLABLE_STATE_NEVER)) {
224             throw new java.lang.IllegalArgumentException(
225                     "killableState was " + mKillableState + " but must be one of: "
226                             + "KILLABLE_STATE_YES(" + KILLABLE_STATE_YES + "), "
227                             + "KILLABLE_STATE_NO(" + KILLABLE_STATE_NO + "), "
228                             + "KILLABLE_STATE_NEVER(" + KILLABLE_STATE_NEVER + ")");
229         }
230 
231 
232         // onConstructed(); // You can define this method to get a callback
233     }
234 
235     @DataClass.Generated.Member
236     public static final @NonNull Parcelable.Creator<PackageKillableState> CREATOR
237             = new Parcelable.Creator<PackageKillableState>() {
238         @Override
239         public PackageKillableState[] newArray(int size) {
240             return new PackageKillableState[size];
241         }
242 
243         @Override
244         public PackageKillableState createFromParcel(@NonNull android.os.Parcel in) {
245             return new PackageKillableState(in);
246         }
247     };
248 
249     @DataClass.Generated(
250             time = 1673057615349L,
251             codegenVersion = "1.0.23",
252             sourceFile = "packages/services/Car/car-lib/src/android/car/watchdog/PackageKillableState.java",
253             inputSignatures = "public static final @android.car.watchdog.PackageKillableState.KillableState @android.car.annotation.AddedInOrBefore int KILLABLE_STATE_YES\npublic static final @android.car.watchdog.PackageKillableState.KillableState @android.car.annotation.AddedInOrBefore int KILLABLE_STATE_NO\npublic static final @android.car.watchdog.PackageKillableState.KillableState @android.car.annotation.AddedInOrBefore int KILLABLE_STATE_NEVER\nprivate @android.annotation.NonNull java.lang.String mPackageName\nprivate @android.annotation.UserIdInt int mUserId\nprivate @android.car.watchdog.PackageKillableState.KillableState int mKillableState\nclass PackageKillableState extends java.lang.Object implements [android.os.Parcelable]\n@com.android.car.internal.util.DataClass(genToString=true, genHiddenConstructor=true, genHiddenConstDefs=true)")
254     @Deprecated
255     @ExcludeFromCodeCoverageGeneratedReport(reason = BOILERPLATE_CODE)
__metadata()256     private void __metadata() {}
257 
258 
259     //@formatter:on
260     // End of generated code
261 
262 }
263