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