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