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.os.Parcelable; 23 24 import com.android.car.internal.ExcludeFromCodeCoverageGeneratedReport; 25 import com.android.internal.util.DataClass; 26 27 /** 28 * Disk I/O overuse stats for a package. 29 */ 30 @DataClass(genToString = true, genHiddenBuilder = true) 31 public final class IoOveruseStats implements Parcelable { 32 /** 33 * Start time, in epoch seconds, for the below stats. 34 */ 35 private long mStartTime; 36 37 /** 38 * Duration, in seconds, for the below stats. 39 */ 40 private long mDurationInSeconds; 41 42 /** 43 * Total times the package has written to disk beyond the allowed write bytes during the given 44 * period. 45 */ 46 private long mTotalOveruses = 0; 47 48 /** 49 * Total times the package was killed during the given period due to disk I/O overuse. 50 */ 51 private long mTotalTimesKilled = 0; 52 53 /** 54 * Aggregated number of bytes written to disk by the package during the given period. 55 */ 56 private long mTotalBytesWritten = 0; 57 58 /** 59 * Package may be killed on disk I/O overuse. 60 * 61 * <p>Disk I/O overuse is triggered on exceeding {@link #mRemainingWriteBytes}. 62 */ 63 private boolean mKillableOnOveruse = false; 64 65 /** 66 * Number of write bytes remaining in each application or system state. 67 * 68 * <p>On exceeding these limit in at least one system or application state, the package may be 69 * killed if {@link #mKillableOnOveruse} is {@code true}. 70 * 71 * <p>The above period does not apply to this field. 72 */ 73 private @NonNull PerStateBytes mRemainingWriteBytes = new PerStateBytes(0L, 0L, 0L); 74 75 76 77 // Code below generated by codegen v1.0.22. 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/IoOveruseStats.java 84 // 85 // To exclude the generated code from IntelliJ auto-formatting enable (one-time): 86 // Settings > Editor > Code Style > Formatter Control 87 //@formatter:off 88 89 90 @DataClass.Generated.Member IoOveruseStats( long startTime, long durationInSeconds, long totalOveruses, long totalTimesKilled, long totalBytesWritten, boolean killableOnOveruse, @NonNull PerStateBytes remainingWriteBytes)91 /* package-private */ IoOveruseStats( 92 long startTime, 93 long durationInSeconds, 94 long totalOveruses, 95 long totalTimesKilled, 96 long totalBytesWritten, 97 boolean killableOnOveruse, 98 @NonNull PerStateBytes remainingWriteBytes) { 99 this.mStartTime = startTime; 100 this.mDurationInSeconds = durationInSeconds; 101 this.mTotalOveruses = totalOveruses; 102 this.mTotalTimesKilled = totalTimesKilled; 103 this.mTotalBytesWritten = totalBytesWritten; 104 this.mKillableOnOveruse = killableOnOveruse; 105 this.mRemainingWriteBytes = remainingWriteBytes; 106 com.android.internal.util.AnnotationValidations.validate( 107 NonNull.class, null, mRemainingWriteBytes); 108 109 // onConstructed(); // You can define this method to get a callback 110 } 111 112 /** 113 * Start time, in epoch seconds, for the below stats. 114 */ 115 @DataClass.Generated.Member getStartTime()116 public long getStartTime() { 117 return mStartTime; 118 } 119 120 /** 121 * Duration, in seconds, for the below stats. 122 */ 123 @DataClass.Generated.Member getDurationInSeconds()124 public long getDurationInSeconds() { 125 return mDurationInSeconds; 126 } 127 128 /** 129 * Total times the package has written to disk beyond the allowed write bytes during the given 130 * period. 131 */ 132 @DataClass.Generated.Member getTotalOveruses()133 public long getTotalOveruses() { 134 return mTotalOveruses; 135 } 136 137 /** 138 * Total times the package was killed during the given period due to disk I/O overuse. 139 */ 140 @DataClass.Generated.Member getTotalTimesKilled()141 public long getTotalTimesKilled() { 142 return mTotalTimesKilled; 143 } 144 145 /** 146 * Aggregated number of bytes written to disk by the package during the given period. 147 */ 148 @DataClass.Generated.Member getTotalBytesWritten()149 public long getTotalBytesWritten() { 150 return mTotalBytesWritten; 151 } 152 153 /** 154 * Package may be killed on disk I/O overuse. 155 * 156 * <p>Disk I/O overuse is triggered on exceeding {@link #mRemainingWriteBytes}. 157 */ 158 @DataClass.Generated.Member isKillableOnOveruse()159 public boolean isKillableOnOveruse() { 160 return mKillableOnOveruse; 161 } 162 163 /** 164 * Number of write bytes remaining in each application or system state. 165 * 166 * <p>On exceeding these limit in at least one system or application state, the package may be 167 * killed if {@link #mKillableOnOveruse} is {@code true}. 168 * 169 * <p>The above period does not apply to this field. 170 */ 171 @DataClass.Generated.Member getRemainingWriteBytes()172 public @NonNull PerStateBytes getRemainingWriteBytes() { 173 return mRemainingWriteBytes; 174 } 175 176 @Override 177 @DataClass.Generated.Member toString()178 public String toString() { 179 // You can override field toString logic by defining methods like: 180 // String fieldNameToString() { ... } 181 182 return "IoOveruseStats { " + 183 "startTime = " + mStartTime + ", " + 184 "durationInSeconds = " + mDurationInSeconds + ", " + 185 "totalOveruses = " + mTotalOveruses + ", " + 186 "totalTimesKilled = " + mTotalTimesKilled + ", " + 187 "totalBytesWritten = " + mTotalBytesWritten + ", " + 188 "killableOnOveruse = " + mKillableOnOveruse + ", " + 189 "remainingWriteBytes = " + mRemainingWriteBytes + 190 " }"; 191 } 192 193 @Override 194 @DataClass.Generated.Member writeToParcel(@onNull android.os.Parcel dest, int flags)195 public void writeToParcel(@NonNull android.os.Parcel dest, int flags) { 196 // You can override field parcelling by defining methods like: 197 // void parcelFieldName(Parcel dest, int flags) { ... } 198 199 byte flg = 0; 200 if (mKillableOnOveruse) flg |= 0x20; 201 dest.writeByte(flg); 202 dest.writeLong(mStartTime); 203 dest.writeLong(mDurationInSeconds); 204 dest.writeLong(mTotalOveruses); 205 dest.writeLong(mTotalTimesKilled); 206 dest.writeLong(mTotalBytesWritten); 207 dest.writeTypedObject(mRemainingWriteBytes, flags); 208 } 209 210 @Override 211 @DataClass.Generated.Member describeContents()212 public int describeContents() { return 0; } 213 214 /** @hide */ 215 @SuppressWarnings({"unchecked", "RedundantCast"}) 216 @DataClass.Generated.Member IoOveruseStats(@onNull android.os.Parcel in)217 /* package-private */ IoOveruseStats(@NonNull android.os.Parcel in) { 218 // You can override field unparcelling by defining methods like: 219 // static FieldType unparcelFieldName(Parcel in) { ... } 220 221 byte flg = in.readByte(); 222 boolean killableOnOveruse = (flg & 0x20) != 0; 223 long startTime = in.readLong(); 224 long durationInSeconds = in.readLong(); 225 long totalOveruses = in.readLong(); 226 long totalTimesKilled = in.readLong(); 227 long totalBytesWritten = in.readLong(); 228 PerStateBytes remainingWriteBytes = (PerStateBytes) in.readTypedObject(PerStateBytes.CREATOR); 229 230 this.mStartTime = startTime; 231 this.mDurationInSeconds = durationInSeconds; 232 this.mTotalOveruses = totalOveruses; 233 this.mTotalTimesKilled = totalTimesKilled; 234 this.mTotalBytesWritten = totalBytesWritten; 235 this.mKillableOnOveruse = killableOnOveruse; 236 this.mRemainingWriteBytes = remainingWriteBytes; 237 com.android.internal.util.AnnotationValidations.validate( 238 NonNull.class, null, mRemainingWriteBytes); 239 240 // onConstructed(); // You can define this method to get a callback 241 } 242 243 @DataClass.Generated.Member 244 public static final @NonNull Parcelable.Creator<IoOveruseStats> CREATOR 245 = new Parcelable.Creator<IoOveruseStats>() { 246 @Override 247 public IoOveruseStats[] newArray(int size) { 248 return new IoOveruseStats[size]; 249 } 250 251 @Override 252 public IoOveruseStats createFromParcel(@NonNull android.os.Parcel in) { 253 return new IoOveruseStats(in); 254 } 255 }; 256 257 /** 258 * A builder for {@link IoOveruseStats} 259 * @hide 260 */ 261 @SuppressWarnings("WeakerAccess") 262 @DataClass.Generated.Member 263 public static final class Builder { 264 265 private long mStartTime; 266 private long mDurationInSeconds; 267 private long mTotalOveruses; 268 private long mTotalTimesKilled; 269 private long mTotalBytesWritten; 270 private boolean mKillableOnOveruse; 271 private @NonNull PerStateBytes mRemainingWriteBytes; 272 273 private long mBuilderFieldsSet = 0L; 274 275 /** 276 * Creates a new Builder. 277 * 278 * @param startTime 279 * Start time, in epoch seconds, for the below stats. 280 * @param durationInSeconds 281 * Duration, in seconds, for the below stats. 282 */ Builder( long startTime, long durationInSeconds)283 public Builder( 284 long startTime, 285 long durationInSeconds) { 286 mStartTime = startTime; 287 mDurationInSeconds = durationInSeconds; 288 } 289 290 /** 291 * Start time, in epoch seconds, for the below stats. 292 */ 293 @DataClass.Generated.Member setStartTime(long value)294 public @NonNull Builder setStartTime(long value) { 295 checkNotUsed(); 296 mBuilderFieldsSet |= 0x1; 297 mStartTime = value; 298 return this; 299 } 300 301 /** 302 * Duration, in seconds, for the below stats. 303 */ 304 @DataClass.Generated.Member setDurationInSeconds(long value)305 public @NonNull Builder setDurationInSeconds(long value) { 306 checkNotUsed(); 307 mBuilderFieldsSet |= 0x2; 308 mDurationInSeconds = value; 309 return this; 310 } 311 312 /** 313 * Total times the package has written to disk beyond the allowed write bytes during the given 314 * period. 315 */ 316 @DataClass.Generated.Member setTotalOveruses(long value)317 public @NonNull Builder setTotalOveruses(long value) { 318 checkNotUsed(); 319 mBuilderFieldsSet |= 0x4; 320 mTotalOveruses = value; 321 return this; 322 } 323 324 /** 325 * Total times the package was killed during the given period due to disk I/O overuse. 326 */ 327 @DataClass.Generated.Member setTotalTimesKilled(long value)328 public @NonNull Builder setTotalTimesKilled(long value) { 329 checkNotUsed(); 330 mBuilderFieldsSet |= 0x8; 331 mTotalTimesKilled = value; 332 return this; 333 } 334 335 /** 336 * Aggregated number of bytes written to disk by the package during the given period. 337 */ 338 @DataClass.Generated.Member setTotalBytesWritten(long value)339 public @NonNull Builder setTotalBytesWritten(long value) { 340 checkNotUsed(); 341 mBuilderFieldsSet |= 0x10; 342 mTotalBytesWritten = value; 343 return this; 344 } 345 346 /** 347 * Package may be killed on disk I/O overuse. 348 * 349 * <p>Disk I/O overuse is triggered on exceeding {@link #mRemainingWriteBytes}. 350 */ 351 @DataClass.Generated.Member setKillableOnOveruse(boolean value)352 public @NonNull Builder setKillableOnOveruse(boolean value) { 353 checkNotUsed(); 354 mBuilderFieldsSet |= 0x20; 355 mKillableOnOveruse = value; 356 return this; 357 } 358 359 /** 360 * Number of write bytes remaining in each application or system state. 361 * 362 * <p>On exceeding these limit in at least one system or application state, the package may be 363 * killed if {@link #mKillableOnOveruse} is {@code true}. 364 * 365 * <p>The above period does not apply to this field. 366 */ 367 @DataClass.Generated.Member setRemainingWriteBytes(@onNull PerStateBytes value)368 public @NonNull Builder setRemainingWriteBytes(@NonNull PerStateBytes value) { 369 checkNotUsed(); 370 mBuilderFieldsSet |= 0x40; 371 mRemainingWriteBytes = value; 372 return this; 373 } 374 375 /** Builds the instance. This builder should not be touched after calling this! */ build()376 public @NonNull IoOveruseStats build() { 377 checkNotUsed(); 378 mBuilderFieldsSet |= 0x80; // Mark builder used 379 380 if ((mBuilderFieldsSet & 0x4) == 0) { 381 mTotalOveruses = 0; 382 } 383 if ((mBuilderFieldsSet & 0x8) == 0) { 384 mTotalTimesKilled = 0; 385 } 386 if ((mBuilderFieldsSet & 0x10) == 0) { 387 mTotalBytesWritten = 0; 388 } 389 if ((mBuilderFieldsSet & 0x20) == 0) { 390 mKillableOnOveruse = false; 391 } 392 if ((mBuilderFieldsSet & 0x40) == 0) { 393 mRemainingWriteBytes = new PerStateBytes(0L, 0L, 0L); 394 } 395 IoOveruseStats o = new IoOveruseStats( 396 mStartTime, 397 mDurationInSeconds, 398 mTotalOveruses, 399 mTotalTimesKilled, 400 mTotalBytesWritten, 401 mKillableOnOveruse, 402 mRemainingWriteBytes); 403 return o; 404 } 405 checkNotUsed()406 private void checkNotUsed() { 407 if ((mBuilderFieldsSet & 0x80) != 0) { 408 throw new IllegalStateException( 409 "This Builder should not be reused. Use a new Builder instance instead"); 410 } 411 } 412 } 413 414 @DataClass.Generated( 415 time = 1615396980193L, 416 codegenVersion = "1.0.22", 417 sourceFile = "packages/services/Car/car-lib/src/android/car/watchdog/IoOveruseStats.java", 418 inputSignatures = "private long mStartTime\nprivate long mDurationInSeconds\nprivate long mTotalOveruses\nprivate long mTotalTimesKilled\nprivate long mTotalBytesWritten\nprivate boolean mKillableOnOveruse\nprivate @android.annotation.NonNull android.car.watchdog.PerStateBytes mRemainingWriteBytes\nclass IoOveruseStats extends java.lang.Object implements [android.os.Parcelable]\n@com.android.internal.util.DataClass(genToString=true, genHiddenBuilder=true)") 419 @Deprecated 420 @ExcludeFromCodeCoverageGeneratedReport(reason = BOILERPLATE_CODE) __metadata()421 private void __metadata() {} 422 423 424 //@formatter:on 425 // End of generated code 426 427 } 428