• 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.car.annotation.AddedInOrBefore;
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 import java.util.List;
31 import java.util.Map;
32 
33 /**
34  * Disk I/O overuse configuration for a component.
35  *
36  * @hide
37  */
38 @SystemApi
39 @DataClass(genToString = true, genBuilder = true, genHiddenConstDefs = true)
40 public final class IoOveruseConfiguration implements Parcelable {
41     /**
42      * Component level thresholds.
43      *
44      * <p>These are applied to packages that are not covered by the package specific thresholds or
45      * application category specific thresholds. For third-party component, only component level
46      * thresholds must be provided and other thresholds are not applicable.
47      */
48     private @NonNull PerStateBytes mComponentLevelThresholds;
49 
50     /**
51      * Package specific thresholds only for system and vendor packages.
52      *
53      * NOTE: For packages that share a UID, the package name should be the shared package name
54      * because the I/O usage is aggregated for all packages under the shared UID. The shared
55      * package names should have the prefix 'shared:'.
56      *
57      * <p>System component must provide package specific thresholds only for system packages.
58      * <p>Vendor component must provide package specific thresholds only for vendor packages.
59      */
60     private @NonNull Map<String, PerStateBytes> mPackageSpecificThresholds;
61 
62     /**
63      * Application category specific thresholds.
64      *
65      * <p>The key must be one of the {@link ResourceOveruseConfiguration#ApplicationCategoryType}
66      * constants.
67      *
68      * <p>These are applied when package specific thresholds are not provided for a package and a
69      * package is covered by one of the
70      * {@link ResourceOveruseConfiguration#ApplicationCategoryType}. These thresholds must be
71      * provided only by the vendor component.
72      */
73     private @NonNull Map<String, PerStateBytes> mAppCategorySpecificThresholds;
74 
75     /**
76      * List of system-wide thresholds used to detect overall disk I/O overuse.
77      *
78      * <p>These thresholds must be provided only by the system component.
79      */
80     private @NonNull List<IoOveruseAlertThreshold> mSystemWideThresholds;
81 
82 
83 
84     // Code below generated by codegen v1.0.23.
85     //
86     // DO NOT MODIFY!
87     // CHECKSTYLE:OFF Generated code
88     //
89     // To regenerate run:
90     // $ codegen $ANDROID_BUILD_TOP/packages/services/Car/car-lib/src/android/car/watchdog/IoOveruseConfiguration.java
91     //
92     // To exclude the generated code from IntelliJ auto-formatting enable (one-time):
93     //   Settings > Editor > Code Style > Formatter Control
94     //@formatter:off
95 
96 
97     @DataClass.Generated.Member
IoOveruseConfiguration( @onNull PerStateBytes componentLevelThresholds, @NonNull Map<String,PerStateBytes> packageSpecificThresholds, @NonNull Map<String,PerStateBytes> appCategorySpecificThresholds, @NonNull List<IoOveruseAlertThreshold> systemWideThresholds)98     /* package-private */ IoOveruseConfiguration(
99             @NonNull PerStateBytes componentLevelThresholds,
100             @NonNull Map<String,PerStateBytes> packageSpecificThresholds,
101             @NonNull Map<String,PerStateBytes> appCategorySpecificThresholds,
102             @NonNull List<IoOveruseAlertThreshold> systemWideThresholds) {
103         this.mComponentLevelThresholds = componentLevelThresholds;
104         AnnotationValidations.validate(
105                 NonNull.class, null, mComponentLevelThresholds);
106         this.mPackageSpecificThresholds = packageSpecificThresholds;
107         AnnotationValidations.validate(
108                 NonNull.class, null, mPackageSpecificThresholds);
109         this.mAppCategorySpecificThresholds = appCategorySpecificThresholds;
110         AnnotationValidations.validate(
111                 NonNull.class, null, mAppCategorySpecificThresholds);
112         this.mSystemWideThresholds = systemWideThresholds;
113         AnnotationValidations.validate(
114                 NonNull.class, null, mSystemWideThresholds);
115 
116         // onConstructed(); // You can define this method to get a callback
117     }
118 
119     /**
120      * Component level thresholds.
121      *
122      * <p>These are applied to packages that are not covered by the package specific thresholds or
123      * application category specific thresholds. For third-party component, only component level
124      * thresholds must be provided and other thresholds are not applicable.
125      */
126     @DataClass.Generated.Member
127     @AddedInOrBefore(majorVersion = 33)
getComponentLevelThresholds()128     public @NonNull PerStateBytes getComponentLevelThresholds() {
129         return mComponentLevelThresholds;
130     }
131 
132     /**
133      * Package specific thresholds only for system and vendor packages.
134      *
135      * NOTE: For packages that share a UID, the package name should be the shared package name
136      * because the I/O usage is aggregated for all packages under the shared UID. The shared
137      * package names should have the prefix 'shared:'.
138      *
139      * <p>System component must provide package specific thresholds only for system packages.
140      * <p>Vendor component must provide package specific thresholds only for vendor packages.
141      */
142     @DataClass.Generated.Member
143     @AddedInOrBefore(majorVersion = 33)
getPackageSpecificThresholds()144     public @NonNull Map<String,PerStateBytes> getPackageSpecificThresholds() {
145         return mPackageSpecificThresholds;
146     }
147 
148     /**
149      * Application category specific thresholds.
150      *
151      * <p>The key must be one of the {@link ResourceOveruseConfiguration#ApplicationCategoryType}
152      * constants.
153      *
154      * <p>These are applied when package specific thresholds are not provided for a package and a
155      * package is covered by one of the
156      * {@link ResourceOveruseConfiguration#ApplicationCategoryType}. These thresholds must be
157      * provided only by the vendor component.
158      */
159     @DataClass.Generated.Member
160     @AddedInOrBefore(majorVersion = 33)
getAppCategorySpecificThresholds()161     public @NonNull Map<String,PerStateBytes> getAppCategorySpecificThresholds() {
162         return mAppCategorySpecificThresholds;
163     }
164 
165     /**
166      * List of system-wide thresholds used to detect overall disk I/O overuse.
167      *
168      * <p>These thresholds must be provided only by the system component.
169      */
170     @DataClass.Generated.Member
171     @AddedInOrBefore(majorVersion = 33)
getSystemWideThresholds()172     public @NonNull List<IoOveruseAlertThreshold> getSystemWideThresholds() {
173         return mSystemWideThresholds;
174     }
175 
176     @Override
177     @DataClass.Generated.Member
178     @AddedInOrBefore(majorVersion = 33)
toString()179     public String toString() {
180         // You can override field toString logic by defining methods like:
181         // String fieldNameToString() { ... }
182 
183         return "IoOveruseConfiguration { " +
184                 "componentLevelThresholds = " + mComponentLevelThresholds + ", " +
185                 "packageSpecificThresholds = " + mPackageSpecificThresholds + ", " +
186                 "appCategorySpecificThresholds = " + mAppCategorySpecificThresholds + ", " +
187                 "systemWideThresholds = " + mSystemWideThresholds +
188         " }";
189     }
190 
191     @Override
192     @DataClass.Generated.Member
193     @AddedInOrBefore(majorVersion = 33)
writeToParcel(@onNull android.os.Parcel dest, int flags)194     public void writeToParcel(@NonNull android.os.Parcel dest, int flags) {
195         // You can override field parcelling by defining methods like:
196         // void parcelFieldName(Parcel dest, int flags) { ... }
197 
198         dest.writeTypedObject(mComponentLevelThresholds, flags);
199         dest.writeMap(mPackageSpecificThresholds);
200         dest.writeMap(mAppCategorySpecificThresholds);
201         dest.writeParcelableList(mSystemWideThresholds, flags);
202     }
203 
204     @Override
205     @DataClass.Generated.Member
206     @ExcludeFromCodeCoverageGeneratedReport(reason = BOILERPLATE_CODE)
207     @AddedInOrBefore(majorVersion = 33)
describeContents()208     public int describeContents() { return 0; }
209 
210     /** @hide */
211     @SuppressWarnings({"unchecked", "RedundantCast"})
212     @DataClass.Generated.Member
IoOveruseConfiguration(@onNull android.os.Parcel in)213     /* package-private */ IoOveruseConfiguration(@NonNull android.os.Parcel in) {
214         // You can override field unparcelling by defining methods like:
215         // static FieldType unparcelFieldName(Parcel in) { ... }
216 
217         PerStateBytes componentLevelThresholds = (PerStateBytes) in.readTypedObject(PerStateBytes.CREATOR);
218         Map<String,PerStateBytes> packageSpecificThresholds = new java.util.LinkedHashMap<>();
219         in.readMap(packageSpecificThresholds, PerStateBytes.class.getClassLoader());
220         Map<String,PerStateBytes> appCategorySpecificThresholds = new java.util.LinkedHashMap<>();
221         in.readMap(appCategorySpecificThresholds, PerStateBytes.class.getClassLoader());
222         List<IoOveruseAlertThreshold> systemWideThresholds = new java.util.ArrayList<>();
223         in.readParcelableList(systemWideThresholds, IoOveruseAlertThreshold.class.getClassLoader());
224 
225         this.mComponentLevelThresholds = componentLevelThresholds;
226         AnnotationValidations.validate(
227                 NonNull.class, null, mComponentLevelThresholds);
228         this.mPackageSpecificThresholds = packageSpecificThresholds;
229         AnnotationValidations.validate(
230                 NonNull.class, null, mPackageSpecificThresholds);
231         this.mAppCategorySpecificThresholds = appCategorySpecificThresholds;
232         AnnotationValidations.validate(
233                 NonNull.class, null, mAppCategorySpecificThresholds);
234         this.mSystemWideThresholds = systemWideThresholds;
235         AnnotationValidations.validate(
236                 NonNull.class, null, mSystemWideThresholds);
237 
238         // onConstructed(); // You can define this method to get a callback
239     }
240 
241     @DataClass.Generated.Member
242     @AddedInOrBefore(majorVersion = 33)
243     public static final @NonNull Parcelable.Creator<IoOveruseConfiguration> CREATOR
244             = new Parcelable.Creator<IoOveruseConfiguration>() {
245         @Override
246         public IoOveruseConfiguration[] newArray(int size) {
247             return new IoOveruseConfiguration[size];
248         }
249 
250         @Override
251         public IoOveruseConfiguration createFromParcel(@NonNull android.os.Parcel in) {
252             return new IoOveruseConfiguration(in);
253         }
254     };
255 
256     /**
257      * A builder for {@link IoOveruseConfiguration}
258      */
259     @SuppressWarnings("WeakerAccess")
260     @DataClass.Generated.Member
261     public static final class Builder {
262 
263         private @NonNull PerStateBytes mComponentLevelThresholds;
264         private @NonNull Map<String,PerStateBytes> mPackageSpecificThresholds;
265         private @NonNull Map<String,PerStateBytes> mAppCategorySpecificThresholds;
266         private @NonNull List<IoOveruseAlertThreshold> mSystemWideThresholds;
267 
268         private long mBuilderFieldsSet = 0L;
269 
270         /**
271          * Creates a new Builder.
272          *
273          * @param componentLevelThresholds
274          *   Component level thresholds.
275          *
276          *   <p>These are applied to packages that are not covered by the package specific thresholds or
277          *   application category specific thresholds. For third-party component, only component level
278          *   thresholds must be provided and other thresholds are not applicable.
279          * @param packageSpecificThresholds
280          *   Package specific thresholds only for system and vendor packages.
281          *
282          *   NOTE: For packages that share a UID, the package name should be the shared package name
283          *   because the I/O usage is aggregated for all packages under the shared UID. The shared
284          *   package names should have the prefix 'shared:'.
285          *
286          *   <p>System component must provide package specific thresholds only for system packages.
287          *   <p>Vendor component must provide package specific thresholds only for vendor packages.
288          * @param appCategorySpecificThresholds
289          *   Application category specific thresholds.
290          *
291          *   <p>The key must be one of the {@link ResourceOveruseConfiguration#ApplicationCategoryType}
292          *   constants.
293          *
294          *   <p>These are applied when package specific thresholds are not provided for a package and a
295          *   package is covered by one of the
296          *   {@link ResourceOveruseConfiguration#ApplicationCategoryType}. These thresholds must be
297          *   provided only by the vendor component.
298          * @param systemWideThresholds
299          *   List of system-wide thresholds used to detect overall disk I/O overuse.
300          *
301          *   <p>These thresholds must be provided only by the system component.
302          */
Builder( @onNull PerStateBytes componentLevelThresholds, @NonNull Map<String,PerStateBytes> packageSpecificThresholds, @NonNull Map<String,PerStateBytes> appCategorySpecificThresholds, @NonNull List<IoOveruseAlertThreshold> systemWideThresholds)303         public Builder(
304                 @NonNull PerStateBytes componentLevelThresholds,
305                 @NonNull Map<String,PerStateBytes> packageSpecificThresholds,
306                 @NonNull Map<String,PerStateBytes> appCategorySpecificThresholds,
307                 @NonNull List<IoOveruseAlertThreshold> systemWideThresholds) {
308             mComponentLevelThresholds = componentLevelThresholds;
309             AnnotationValidations.validate(
310                     NonNull.class, null, mComponentLevelThresholds);
311             mPackageSpecificThresholds = packageSpecificThresholds;
312             AnnotationValidations.validate(
313                     NonNull.class, null, mPackageSpecificThresholds);
314             mAppCategorySpecificThresholds = appCategorySpecificThresholds;
315             AnnotationValidations.validate(
316                     NonNull.class, null, mAppCategorySpecificThresholds);
317             mSystemWideThresholds = systemWideThresholds;
318             AnnotationValidations.validate(
319                     NonNull.class, null, mSystemWideThresholds);
320         }
321 
322         /**
323          * Component level thresholds.
324          *
325          * <p>These are applied to packages that are not covered by the package specific thresholds or
326          * application category specific thresholds. For third-party component, only component level
327          * thresholds must be provided and other thresholds are not applicable.
328          */
329         @DataClass.Generated.Member
330         @AddedInOrBefore(majorVersion = 33)
setComponentLevelThresholds(@onNull PerStateBytes value)331         public @NonNull Builder setComponentLevelThresholds(@NonNull PerStateBytes value) {
332             checkNotUsed();
333             mBuilderFieldsSet |= 0x1;
334             mComponentLevelThresholds = value;
335             return this;
336         }
337 
338         /**
339          * Package specific thresholds only for system and vendor packages.
340          *
341          * NOTE: For packages that share a UID, the package name should be the shared package name
342          * because the I/O usage is aggregated for all packages under the shared UID. The shared
343          * package names should have the prefix 'shared:'.
344          *
345          * <p>System component must provide package specific thresholds only for system packages.
346          * <p>Vendor component must provide package specific thresholds only for vendor packages.
347          */
348         @DataClass.Generated.Member
349         @AddedInOrBefore(majorVersion = 33)
setPackageSpecificThresholds(@onNull Map<String,PerStateBytes> value)350         public @NonNull Builder setPackageSpecificThresholds(@NonNull Map<String,PerStateBytes> value) {
351             checkNotUsed();
352             mBuilderFieldsSet |= 0x2;
353             mPackageSpecificThresholds = value;
354             return this;
355         }
356 
357         /** @see #setPackageSpecificThresholds */
358         @DataClass.Generated.Member
359         @AddedInOrBefore(majorVersion = 33)
addPackageSpecificThresholds(@onNull String key, @NonNull PerStateBytes value)360         public @NonNull Builder addPackageSpecificThresholds(@NonNull String key, @NonNull PerStateBytes value) {
361             // You can refine this method's name by providing item's singular name, e.g.:
362             // @DataClass.PluralOf("item")) mItems = ...
363 
364             if (mPackageSpecificThresholds == null) setPackageSpecificThresholds(new java.util.LinkedHashMap());
365             mPackageSpecificThresholds.put(key, value);
366             return this;
367         }
368 
369         /**
370          * Application category specific thresholds.
371          *
372          * <p>The key must be one of the {@link ResourceOveruseConfiguration#ApplicationCategoryType}
373          * constants.
374          *
375          * <p>These are applied when package specific thresholds are not provided for a package and a
376          * package is covered by one of the
377          * {@link ResourceOveruseConfiguration#ApplicationCategoryType}. These thresholds must be
378          * provided only by the vendor component.
379          */
380         @DataClass.Generated.Member
381         @AddedInOrBefore(majorVersion = 33)
setAppCategorySpecificThresholds(@onNull Map<String,PerStateBytes> value)382         public @NonNull Builder setAppCategorySpecificThresholds(@NonNull Map<String,PerStateBytes> value) {
383             checkNotUsed();
384             mBuilderFieldsSet |= 0x4;
385             mAppCategorySpecificThresholds = value;
386             return this;
387         }
388 
389         /** @see #setAppCategorySpecificThresholds */
390         @DataClass.Generated.Member
391         @AddedInOrBefore(majorVersion = 33)
addAppCategorySpecificThresholds(@onNull String key, @NonNull PerStateBytes value)392         public @NonNull Builder addAppCategorySpecificThresholds(@NonNull String key, @NonNull PerStateBytes value) {
393             // You can refine this method's name by providing item's singular name, e.g.:
394             // @DataClass.PluralOf("item")) mItems = ...
395 
396             if (mAppCategorySpecificThresholds == null) setAppCategorySpecificThresholds(new java.util.LinkedHashMap());
397             mAppCategorySpecificThresholds.put(key, value);
398             return this;
399         }
400 
401         /**
402          * List of system-wide thresholds used to detect overall disk I/O overuse.
403          *
404          * <p>These thresholds must be provided only by the system component.
405          */
406         @DataClass.Generated.Member
407         @AddedInOrBefore(majorVersion = 33)
setSystemWideThresholds(@onNull List<IoOveruseAlertThreshold> value)408         public @NonNull Builder setSystemWideThresholds(@NonNull List<IoOveruseAlertThreshold> value) {
409             checkNotUsed();
410             mBuilderFieldsSet |= 0x8;
411             mSystemWideThresholds = value;
412             return this;
413         }
414 
415         /** @see #setSystemWideThresholds */
416         @DataClass.Generated.Member
417         @AddedInOrBefore(majorVersion = 33)
addSystemWideThresholds(@onNull IoOveruseAlertThreshold value)418         public @NonNull Builder addSystemWideThresholds(@NonNull IoOveruseAlertThreshold value) {
419             // You can refine this method's name by providing item's singular name, e.g.:
420             // @DataClass.PluralOf("item")) mItems = ...
421 
422             if (mSystemWideThresholds == null) setSystemWideThresholds(new java.util.ArrayList<>());
423             mSystemWideThresholds.add(value);
424             return this;
425         }
426 
427         /** Builds the instance. This builder should not be touched after calling this! */
428         @AddedInOrBefore(majorVersion = 33)
build()429         public @NonNull IoOveruseConfiguration build() {
430             checkNotUsed();
431             mBuilderFieldsSet |= 0x10; // Mark builder used
432 
433             IoOveruseConfiguration o = new IoOveruseConfiguration(
434                     mComponentLevelThresholds,
435                     mPackageSpecificThresholds,
436                     mAppCategorySpecificThresholds,
437                     mSystemWideThresholds);
438             return o;
439         }
440 
checkNotUsed()441         private void checkNotUsed() {
442             if ((mBuilderFieldsSet & 0x10) != 0) {
443                 throw new IllegalStateException(
444                         "This Builder should not be reused. Use a new Builder instance instead");
445             }
446         }
447     }
448 
449     @DataClass.Generated(
450             time = 1628099281770L,
451             codegenVersion = "1.0.23",
452             sourceFile = "packages/services/Car/car-lib/src/android/car/watchdog/IoOveruseConfiguration.java",
453             inputSignatures = "private @android.annotation.NonNull android.car.watchdog.PerStateBytes mComponentLevelThresholds\nprivate @android.annotation.NonNull java.util.Map<java.lang.String,android.car.watchdog.PerStateBytes> mPackageSpecificThresholds\nprivate @android.annotation.NonNull java.util.Map<java.lang.String,android.car.watchdog.PerStateBytes> mAppCategorySpecificThresholds\nprivate @android.annotation.NonNull java.util.List<android.car.watchdog.IoOveruseAlertThreshold> mSystemWideThresholds\nclass IoOveruseConfiguration extends java.lang.Object implements [android.os.Parcelable]\n@com.android.car.internal.util.DataClass(genToString=true, genBuilder=true, genHiddenConstDefs=true)")
454     @Deprecated
455     @ExcludeFromCodeCoverageGeneratedReport(reason = BOILERPLATE_CODE)
__metadata()456     private void __metadata() {}
457 
458 
459     //@formatter:on
460     // End of generated code
461 
462 }
463