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