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 // 87 // To exclude the generated code from IntelliJ auto-formatting enable (one-time): 88 // Settings > Editor > Code Style > Formatter Control 89 //@formatter:off 90 91 92 @DataClass.Generated.Member IoOveruseStats( long startTime, long durationInSeconds, long totalOveruses, long totalTimesKilled, long totalBytesWritten, boolean killableOnOveruse, @NonNull PerStateBytes remainingWriteBytes)93 /* package-private */ IoOveruseStats( 94 long startTime, 95 long durationInSeconds, 96 long totalOveruses, 97 long totalTimesKilled, 98 long totalBytesWritten, 99 boolean killableOnOveruse, 100 @NonNull PerStateBytes remainingWriteBytes) { 101 this.mStartTime = startTime; 102 this.mDurationInSeconds = durationInSeconds; 103 this.mTotalOveruses = totalOveruses; 104 this.mTotalTimesKilled = totalTimesKilled; 105 this.mTotalBytesWritten = totalBytesWritten; 106 this.mKillableOnOveruse = killableOnOveruse; 107 this.mRemainingWriteBytes = remainingWriteBytes; 108 AnnotationValidations.validate( 109 NonNull.class, null, mRemainingWriteBytes); 110 111 // onConstructed(); // You can define this method to get a callback 112 } 113 114 /** 115 * Start time, in epoch seconds, for the below stats. 116 */ 117 @DataClass.Generated.Member 118 @AddedInOrBefore(majorVersion = 33) getStartTime()119 public long getStartTime() { 120 return mStartTime; 121 } 122 123 /** 124 * Duration, in seconds, for the below stats. 125 */ 126 @DataClass.Generated.Member 127 @AddedInOrBefore(majorVersion = 33) getDurationInSeconds()128 public long getDurationInSeconds() { 129 return mDurationInSeconds; 130 } 131 132 /** 133 * Total times the package has written to disk beyond the allowed write bytes during the given 134 * period. 135 */ 136 @DataClass.Generated.Member 137 @AddedInOrBefore(majorVersion = 33) getTotalOveruses()138 public long getTotalOveruses() { 139 return mTotalOveruses; 140 } 141 142 /** 143 * Total times the package was killed during the given period due to disk I/O overuse. 144 */ 145 @DataClass.Generated.Member 146 @AddedInOrBefore(majorVersion = 33) getTotalTimesKilled()147 public long getTotalTimesKilled() { 148 return mTotalTimesKilled; 149 } 150 151 /** 152 * Aggregated number of bytes written to disk by the package during the given period. 153 */ 154 @DataClass.Generated.Member 155 @AddedInOrBefore(majorVersion = 33) getTotalBytesWritten()156 public long getTotalBytesWritten() { 157 return mTotalBytesWritten; 158 } 159 160 /** 161 * Package may be killed on disk I/O overuse. 162 * 163 * <p>Disk I/O overuse is triggered on exceeding {@link #mRemainingWriteBytes}. 164 */ 165 @DataClass.Generated.Member 166 @AddedInOrBefore(majorVersion = 33) isKillableOnOveruse()167 public boolean isKillableOnOveruse() { 168 return mKillableOnOveruse; 169 } 170 171 /** 172 * Number of write bytes remaining in each application or system state. 173 * 174 * <p>On exceeding these limit in at least one system or application state, the package may be 175 * killed if {@link #mKillableOnOveruse} is {@code true}. 176 * 177 * <p>The above period does not apply to this field. 178 */ 179 @DataClass.Generated.Member 180 @AddedInOrBefore(majorVersion = 33) getRemainingWriteBytes()181 public @NonNull PerStateBytes getRemainingWriteBytes() { 182 return mRemainingWriteBytes; 183 } 184 185 @Override 186 @DataClass.Generated.Member 187 @AddedInOrBefore(majorVersion = 33) 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