• 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.Nullable;
23 import android.os.Parcelable;
24 import android.os.UserHandle;
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  * Resource overuse stats for a package.
32  */
33 @DataClass(genToString = true, genHiddenBuilder = true)
34 public final class ResourceOveruseStats implements Parcelable {
35     /**
36      * Name of the package, whose stats are recorded in the below fields.
37      *
38      * NOTE: For packages that share a UID, the package name will be the shared package name because
39      *       the stats are aggregated for all packages under the shared UID.
40      */
41     private @NonNull String mPackageName;
42 
43     /**
44      * User handle, whose stats are recorded in the below fields.
45      */
46     private @NonNull UserHandle mUserHandle;
47 
48     /**
49      * I/O overuse stats for the package.
50      *
51      * If the package didn't opt-in to receive I/O overuse stats or the package doesn't have
52      * I/O overuse stats, this value will be null.
53      */
54     private @Nullable IoOveruseStats mIoOveruseStats = null;
55 
56 
57 
58 
59     // Code below generated by codegen v1.0.23.
60     //
61     // DO NOT MODIFY!
62     // CHECKSTYLE:OFF Generated code
63     //
64     // To regenerate run:
65     // $ codegen $ANDROID_BUILD_TOP/packages/services/Car/car-lib/src/android/car/watchdog/ResourceOveruseStats.java
66     //
67     // To exclude the generated code from IntelliJ auto-formatting enable (one-time):
68     //   Settings > Editor > Code Style > Formatter Control
69     //@formatter:off
70 
71 
72     @DataClass.Generated.Member
ResourceOveruseStats( @onNull String packageName, @NonNull UserHandle userHandle, @Nullable IoOveruseStats ioOveruseStats)73     /* package-private */ ResourceOveruseStats(
74             @NonNull String packageName,
75             @NonNull UserHandle userHandle,
76             @Nullable IoOveruseStats ioOveruseStats) {
77         this.mPackageName = packageName;
78         AnnotationValidations.validate(
79                 NonNull.class, null, mPackageName);
80         this.mUserHandle = userHandle;
81         AnnotationValidations.validate(
82                 NonNull.class, null, mUserHandle);
83         this.mIoOveruseStats = ioOveruseStats;
84 
85         // onConstructed(); // You can define this method to get a callback
86     }
87 
88     /**
89      * Name of the package, whose stats are recorded in the below fields.
90      *
91      * NOTE: For packages that share a UID, the package name will be the shared package name because
92      *       the stats are aggregated for all packages under the shared UID.
93      */
94     @DataClass.Generated.Member
getPackageName()95     public @NonNull String getPackageName() {
96         return mPackageName;
97     }
98 
99     /**
100      * User handle, whose stats are recorded in the below fields.
101      */
102     @DataClass.Generated.Member
getUserHandle()103     public @NonNull UserHandle getUserHandle() {
104         return mUserHandle;
105     }
106 
107     /**
108      * I/O overuse stats for the package.
109      *
110      * If the package didn't opt-in to receive I/O overuse stats or the package doesn't have
111      * I/O overuse stats, this value will be null.
112      */
113     @DataClass.Generated.Member
getIoOveruseStats()114     public @Nullable IoOveruseStats getIoOveruseStats() {
115         return mIoOveruseStats;
116     }
117 
118     @Override
119     @DataClass.Generated.Member
toString()120     public String toString() {
121         // You can override field toString logic by defining methods like:
122         // String fieldNameToString() { ... }
123 
124         return "ResourceOveruseStats { " +
125                 "packageName = " + mPackageName + ", " +
126                 "userHandle = " + mUserHandle + ", " +
127                 "ioOveruseStats = " + mIoOveruseStats +
128         " }";
129     }
130 
131     @Override
132     @DataClass.Generated.Member
writeToParcel(@onNull android.os.Parcel dest, int flags)133     public void writeToParcel(@NonNull android.os.Parcel dest, int flags) {
134         // You can override field parcelling by defining methods like:
135         // void parcelFieldName(Parcel dest, int flags) { ... }
136 
137         byte flg = 0;
138         if (mIoOveruseStats != null) flg |= 0x4;
139         dest.writeByte(flg);
140         dest.writeString(mPackageName);
141         dest.writeTypedObject(mUserHandle, flags);
142         if (mIoOveruseStats != null) dest.writeTypedObject(mIoOveruseStats, flags);
143     }
144 
145     @Override
146     @DataClass.Generated.Member
147     @ExcludeFromCodeCoverageGeneratedReport(reason = BOILERPLATE_CODE)
describeContents()148     public int describeContents() { return 0; }
149 
150     /** @hide */
151     @SuppressWarnings({"unchecked", "RedundantCast"})
152     @DataClass.Generated.Member
ResourceOveruseStats(@onNull android.os.Parcel in)153     /* package-private */ ResourceOveruseStats(@NonNull android.os.Parcel in) {
154         // You can override field unparcelling by defining methods like:
155         // static FieldType unparcelFieldName(Parcel in) { ... }
156 
157         byte flg = in.readByte();
158         String packageName = in.readString();
159         UserHandle userHandle = (UserHandle) in.readTypedObject(UserHandle.CREATOR);
160         IoOveruseStats ioOveruseStats = (flg & 0x4) == 0 ? null : (IoOveruseStats) in.readTypedObject(IoOveruseStats.CREATOR);
161 
162         this.mPackageName = packageName;
163         AnnotationValidations.validate(
164                 NonNull.class, null, mPackageName);
165         this.mUserHandle = userHandle;
166         AnnotationValidations.validate(
167                 NonNull.class, null, mUserHandle);
168         this.mIoOveruseStats = ioOveruseStats;
169 
170         // onConstructed(); // You can define this method to get a callback
171     }
172 
173     @DataClass.Generated.Member
174     public static final @NonNull Parcelable.Creator<ResourceOveruseStats> CREATOR
175             = new Parcelable.Creator<ResourceOveruseStats>() {
176         @Override
177         public ResourceOveruseStats[] newArray(int size) {
178             return new ResourceOveruseStats[size];
179         }
180 
181         @Override
182         public ResourceOveruseStats createFromParcel(@NonNull android.os.Parcel in) {
183             return new ResourceOveruseStats(in);
184         }
185     };
186 
187     /**
188      * A builder for {@link ResourceOveruseStats}
189      * @hide
190      */
191     @SuppressWarnings("WeakerAccess")
192     @DataClass.Generated.Member
193     public static final class Builder {
194 
195         private @NonNull String mPackageName;
196         private @NonNull UserHandle mUserHandle;
197         private @Nullable IoOveruseStats mIoOveruseStats;
198 
199         private long mBuilderFieldsSet = 0L;
200 
201         /**
202          * Creates a new Builder.
203          *
204          * @param packageName
205          *   Name of the package, whose stats are recorded in the below fields.
206          *
207          *   NOTE: For packages that share a UID, the package name will be the shared package name because
208          *         the stats are aggregated for all packages under the shared UID.
209          * @param userHandle
210          *   User handle, whose stats are recorded in the below fields.
211          */
Builder( @onNull String packageName, @NonNull UserHandle userHandle)212         public Builder(
213                 @NonNull String packageName,
214                 @NonNull UserHandle userHandle) {
215             mPackageName = packageName;
216             AnnotationValidations.validate(
217                     NonNull.class, null, mPackageName);
218             mUserHandle = userHandle;
219             AnnotationValidations.validate(
220                     NonNull.class, null, mUserHandle);
221         }
222 
223         /**
224          * Name of the package, whose stats are recorded in the below fields.
225          *
226          * NOTE: For packages that share a UID, the package name will be the shared package name because
227          *       the stats are aggregated for all packages under the shared UID.
228          */
229         @DataClass.Generated.Member
setPackageName(@onNull String value)230         public @NonNull Builder setPackageName(@NonNull String value) {
231             checkNotUsed();
232             mBuilderFieldsSet |= 0x1;
233             mPackageName = value;
234             return this;
235         }
236 
237         /**
238          * User handle, whose stats are recorded in the below fields.
239          */
240         @DataClass.Generated.Member
setUserHandle(@onNull UserHandle value)241         public @NonNull Builder setUserHandle(@NonNull UserHandle value) {
242             checkNotUsed();
243             mBuilderFieldsSet |= 0x2;
244             mUserHandle = value;
245             return this;
246         }
247 
248         /**
249          * I/O overuse stats for the package.
250          *
251          * If the package didn't opt-in to receive I/O overuse stats or the package doesn't have
252          * I/O overuse stats, this value will be null.
253          */
254         @DataClass.Generated.Member
setIoOveruseStats(@onNull IoOveruseStats value)255         public @NonNull Builder setIoOveruseStats(@NonNull IoOveruseStats value) {
256             checkNotUsed();
257             mBuilderFieldsSet |= 0x4;
258             mIoOveruseStats = value;
259             return this;
260         }
261 
262         /** Builds the instance. This builder should not be touched after calling this! */
build()263         public @NonNull ResourceOveruseStats build() {
264             checkNotUsed();
265             mBuilderFieldsSet |= 0x8; // Mark builder used
266 
267             if ((mBuilderFieldsSet & 0x4) == 0) {
268                 mIoOveruseStats = null;
269             }
270             ResourceOveruseStats o = new ResourceOveruseStats(
271                     mPackageName,
272                     mUserHandle,
273                     mIoOveruseStats);
274             return o;
275         }
276 
checkNotUsed()277         private void checkNotUsed() {
278             if ((mBuilderFieldsSet & 0x8) != 0) {
279                 throw new IllegalStateException(
280                         "This Builder should not be reused. Use a new Builder instance instead");
281             }
282         }
283     }
284 
285     @DataClass.Generated(
286             time = 1721756572114L,
287             codegenVersion = "1.0.23",
288             sourceFile = "packages/services/Car/car-lib/src/android/car/watchdog/ResourceOveruseStats.java",
289             inputSignatures = "private @android.annotation.NonNull java.lang.String mPackageName\nprivate @android.annotation.NonNull android.os.UserHandle mUserHandle\nprivate @android.annotation.Nullable android.car.watchdog.IoOveruseStats mIoOveruseStats\nclass ResourceOveruseStats extends java.lang.Object implements [android.os.Parcelable]\n@com.android.car.internal.util.DataClass(genToString=true, genHiddenBuilder=true)")
290     @Deprecated
291     @ExcludeFromCodeCoverageGeneratedReport(reason = BOILERPLATE_CODE)
__metadata()292     private void __metadata() {}
293 
294 
295     //@formatter:on
296     // End of generated code
297 
298 }
299