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.SystemApi; 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 import java.util.List; 30 import java.util.Map; 31 32 /** 33 * Disk I/O overuse configuration for a component. 34 * 35 * @hide 36 */ 37 @SystemApi 38 @DataClass(genToString = true, genBuilder = true, genHiddenConstDefs = true) 39 public final class IoOveruseConfiguration implements Parcelable { 40 /** 41 * Component level thresholds. 42 * 43 * <p>These are applied to packages that are not covered by the package specific thresholds or 44 * application category specific thresholds. For third-party component, only component level 45 * thresholds must be provided and other thresholds are not applicable. 46 */ 47 private @NonNull PerStateBytes mComponentLevelThresholds; 48 49 /** 50 * Package specific thresholds only for system and vendor packages. 51 * 52 * NOTE: For packages that share a UID, the package name should be the shared package name 53 * because the I/O usage is aggregated for all packages under the shared UID. The shared 54 * package names should have the prefix 'shared:'. 55 * 56 * <p>System component must provide package specific thresholds only for system packages. 57 * <p>Vendor component must provide package specific thresholds only for vendor packages. 58 */ 59 private @NonNull Map<String, PerStateBytes> mPackageSpecificThresholds; 60 61 /** 62 * Application category specific thresholds. 63 * 64 * <p>The key must be one of the {@link ResourceOveruseConfiguration#ApplicationCategoryType} 65 * constants. 66 * 67 * <p>These are applied when package specific thresholds are not provided for a package and a 68 * package is covered by one of the 69 * {@link ResourceOveruseConfiguration#ApplicationCategoryType}. These thresholds must be 70 * provided only by the vendor component. 71 */ 72 private @NonNull Map<String, PerStateBytes> mAppCategorySpecificThresholds; 73 74 /** 75 * List of system-wide thresholds used to detect overall disk I/O overuse. 76 * 77 * <p>These thresholds must be provided only by the system component. 78 */ 79 private @NonNull List<IoOveruseAlertThreshold> mSystemWideThresholds; 80 81 82 83 // Code below generated by codegen v1.0.23. 84 // 85 // DO NOT MODIFY! 86 // CHECKSTYLE:OFF Generated code 87 // 88 // To regenerate run: 89 // $ codegen $ANDROID_BUILD_TOP/packages/services/Car/car-lib/src/android/car/watchdog/IoOveruseConfiguration.java 90 // 91 // To exclude the generated code from IntelliJ auto-formatting enable (one-time): 92 // Settings > Editor > Code Style > Formatter Control 93 //@formatter:off 94 95 96 @DataClass.Generated.Member IoOveruseConfiguration( @onNull PerStateBytes componentLevelThresholds, @NonNull Map<String,PerStateBytes> packageSpecificThresholds, @NonNull Map<String,PerStateBytes> appCategorySpecificThresholds, @NonNull List<IoOveruseAlertThreshold> systemWideThresholds)97 /* package-private */ IoOveruseConfiguration( 98 @NonNull PerStateBytes componentLevelThresholds, 99 @NonNull Map<String,PerStateBytes> packageSpecificThresholds, 100 @NonNull Map<String,PerStateBytes> appCategorySpecificThresholds, 101 @NonNull List<IoOveruseAlertThreshold> systemWideThresholds) { 102 this.mComponentLevelThresholds = componentLevelThresholds; 103 AnnotationValidations.validate( 104 NonNull.class, null, mComponentLevelThresholds); 105 this.mPackageSpecificThresholds = packageSpecificThresholds; 106 AnnotationValidations.validate( 107 NonNull.class, null, mPackageSpecificThresholds); 108 this.mAppCategorySpecificThresholds = appCategorySpecificThresholds; 109 AnnotationValidations.validate( 110 NonNull.class, null, mAppCategorySpecificThresholds); 111 this.mSystemWideThresholds = systemWideThresholds; 112 AnnotationValidations.validate( 113 NonNull.class, null, mSystemWideThresholds); 114 115 // onConstructed(); // You can define this method to get a callback 116 } 117 118 /** 119 * Component level thresholds. 120 * 121 * <p>These are applied to packages that are not covered by the package specific thresholds or 122 * application category specific thresholds. For third-party component, only component level 123 * thresholds must be provided and other thresholds are not applicable. 124 */ 125 @DataClass.Generated.Member getComponentLevelThresholds()126 public @NonNull PerStateBytes getComponentLevelThresholds() { 127 return mComponentLevelThresholds; 128 } 129 130 /** 131 * Package specific thresholds only for system and vendor packages. 132 * 133 * NOTE: For packages that share a UID, the package name should be the shared package name 134 * because the I/O usage is aggregated for all packages under the shared UID. The shared 135 * package names should have the prefix 'shared:'. 136 * 137 * <p>System component must provide package specific thresholds only for system packages. 138 * <p>Vendor component must provide package specific thresholds only for vendor packages. 139 */ 140 @DataClass.Generated.Member getPackageSpecificThresholds()141 public @NonNull Map<String,PerStateBytes> getPackageSpecificThresholds() { 142 return mPackageSpecificThresholds; 143 } 144 145 /** 146 * Application category specific thresholds. 147 * 148 * <p>The key must be one of the {@link ResourceOveruseConfiguration#ApplicationCategoryType} 149 * constants. 150 * 151 * <p>These are applied when package specific thresholds are not provided for a package and a 152 * package is covered by one of the 153 * {@link ResourceOveruseConfiguration#ApplicationCategoryType}. These thresholds must be 154 * provided only by the vendor component. 155 */ 156 @DataClass.Generated.Member getAppCategorySpecificThresholds()157 public @NonNull Map<String,PerStateBytes> getAppCategorySpecificThresholds() { 158 return mAppCategorySpecificThresholds; 159 } 160 161 /** 162 * List of system-wide thresholds used to detect overall disk I/O overuse. 163 * 164 * <p>These thresholds must be provided only by the system component. 165 */ 166 @DataClass.Generated.Member getSystemWideThresholds()167 public @NonNull List<IoOveruseAlertThreshold> getSystemWideThresholds() { 168 return mSystemWideThresholds; 169 } 170 171 @Override 172 @DataClass.Generated.Member toString()173 public String toString() { 174 // You can override field toString logic by defining methods like: 175 // String fieldNameToString() { ... } 176 177 return "IoOveruseConfiguration { " + 178 "componentLevelThresholds = " + mComponentLevelThresholds + ", " + 179 "packageSpecificThresholds = " + mPackageSpecificThresholds + ", " + 180 "appCategorySpecificThresholds = " + mAppCategorySpecificThresholds + ", " + 181 "systemWideThresholds = " + mSystemWideThresholds + 182 " }"; 183 } 184 185 @Override 186 @DataClass.Generated.Member writeToParcel(@onNull android.os.Parcel dest, int flags)187 public void writeToParcel(@NonNull android.os.Parcel dest, int flags) { 188 // You can override field parcelling by defining methods like: 189 // void parcelFieldName(Parcel dest, int flags) { ... } 190 191 dest.writeTypedObject(mComponentLevelThresholds, flags); 192 dest.writeMap(mPackageSpecificThresholds); 193 dest.writeMap(mAppCategorySpecificThresholds); 194 dest.writeParcelableList(mSystemWideThresholds, flags); 195 } 196 197 @Override 198 @DataClass.Generated.Member 199 @ExcludeFromCodeCoverageGeneratedReport(reason = BOILERPLATE_CODE) describeContents()200 public int describeContents() { return 0; } 201 202 /** @hide */ 203 @SuppressWarnings({"unchecked", "RedundantCast"}) 204 @DataClass.Generated.Member IoOveruseConfiguration(@onNull android.os.Parcel in)205 /* package-private */ IoOveruseConfiguration(@NonNull android.os.Parcel in) { 206 // You can override field unparcelling by defining methods like: 207 // static FieldType unparcelFieldName(Parcel in) { ... } 208 209 PerStateBytes componentLevelThresholds = (PerStateBytes) in.readTypedObject(PerStateBytes.CREATOR); 210 Map<String,PerStateBytes> packageSpecificThresholds = new java.util.LinkedHashMap<>(); 211 in.readMap(packageSpecificThresholds, PerStateBytes.class.getClassLoader()); 212 Map<String,PerStateBytes> appCategorySpecificThresholds = new java.util.LinkedHashMap<>(); 213 in.readMap(appCategorySpecificThresholds, PerStateBytes.class.getClassLoader()); 214 List<IoOveruseAlertThreshold> systemWideThresholds = new java.util.ArrayList<>(); 215 in.readParcelableList(systemWideThresholds, IoOveruseAlertThreshold.class.getClassLoader()); 216 217 this.mComponentLevelThresholds = componentLevelThresholds; 218 AnnotationValidations.validate( 219 NonNull.class, null, mComponentLevelThresholds); 220 this.mPackageSpecificThresholds = packageSpecificThresholds; 221 AnnotationValidations.validate( 222 NonNull.class, null, mPackageSpecificThresholds); 223 this.mAppCategorySpecificThresholds = appCategorySpecificThresholds; 224 AnnotationValidations.validate( 225 NonNull.class, null, mAppCategorySpecificThresholds); 226 this.mSystemWideThresholds = systemWideThresholds; 227 AnnotationValidations.validate( 228 NonNull.class, null, mSystemWideThresholds); 229 230 // onConstructed(); // You can define this method to get a callback 231 } 232 233 @DataClass.Generated.Member 234 public static final @NonNull Parcelable.Creator<IoOveruseConfiguration> CREATOR 235 = new Parcelable.Creator<IoOveruseConfiguration>() { 236 @Override 237 public IoOveruseConfiguration[] newArray(int size) { 238 return new IoOveruseConfiguration[size]; 239 } 240 241 @Override 242 public IoOveruseConfiguration createFromParcel(@NonNull android.os.Parcel in) { 243 return new IoOveruseConfiguration(in); 244 } 245 }; 246 247 /** 248 * A builder for {@link IoOveruseConfiguration} 249 */ 250 @SuppressWarnings("WeakerAccess") 251 @DataClass.Generated.Member 252 public static final class Builder { 253 254 private @NonNull PerStateBytes mComponentLevelThresholds; 255 private @NonNull Map<String,PerStateBytes> mPackageSpecificThresholds; 256 private @NonNull Map<String,PerStateBytes> mAppCategorySpecificThresholds; 257 private @NonNull List<IoOveruseAlertThreshold> mSystemWideThresholds; 258 259 private long mBuilderFieldsSet = 0L; 260 261 /** 262 * Creates a new Builder. 263 * 264 * @param componentLevelThresholds 265 * Component level thresholds. 266 * 267 * <p>These are applied to packages that are not covered by the package specific thresholds or 268 * application category specific thresholds. For third-party component, only component level 269 * thresholds must be provided and other thresholds are not applicable. 270 * @param packageSpecificThresholds 271 * Package specific thresholds only for system and vendor packages. 272 * 273 * NOTE: For packages that share a UID, the package name should be the shared package name 274 * because the I/O usage is aggregated for all packages under the shared UID. The shared 275 * package names should have the prefix 'shared:'. 276 * 277 * <p>System component must provide package specific thresholds only for system packages. 278 * <p>Vendor component must provide package specific thresholds only for vendor packages. 279 * @param appCategorySpecificThresholds 280 * Application category specific thresholds. 281 * 282 * <p>The key must be one of the {@link ResourceOveruseConfiguration#ApplicationCategoryType} 283 * constants. 284 * 285 * <p>These are applied when package specific thresholds are not provided for a package and a 286 * package is covered by one of the 287 * {@link ResourceOveruseConfiguration#ApplicationCategoryType}. These thresholds must be 288 * provided only by the vendor component. 289 * @param systemWideThresholds 290 * List of system-wide thresholds used to detect overall disk I/O overuse. 291 * 292 * <p>These thresholds must be provided only by the system component. 293 */ Builder( @onNull PerStateBytes componentLevelThresholds, @NonNull Map<String,PerStateBytes> packageSpecificThresholds, @NonNull Map<String,PerStateBytes> appCategorySpecificThresholds, @NonNull List<IoOveruseAlertThreshold> systemWideThresholds)294 public Builder( 295 @NonNull PerStateBytes componentLevelThresholds, 296 @NonNull Map<String,PerStateBytes> packageSpecificThresholds, 297 @NonNull Map<String,PerStateBytes> appCategorySpecificThresholds, 298 @NonNull List<IoOveruseAlertThreshold> systemWideThresholds) { 299 mComponentLevelThresholds = componentLevelThresholds; 300 AnnotationValidations.validate( 301 NonNull.class, null, mComponentLevelThresholds); 302 mPackageSpecificThresholds = packageSpecificThresholds; 303 AnnotationValidations.validate( 304 NonNull.class, null, mPackageSpecificThresholds); 305 mAppCategorySpecificThresholds = appCategorySpecificThresholds; 306 AnnotationValidations.validate( 307 NonNull.class, null, mAppCategorySpecificThresholds); 308 mSystemWideThresholds = systemWideThresholds; 309 AnnotationValidations.validate( 310 NonNull.class, null, mSystemWideThresholds); 311 } 312 313 /** 314 * Component level thresholds. 315 * 316 * <p>These are applied to packages that are not covered by the package specific thresholds or 317 * application category specific thresholds. For third-party component, only component level 318 * thresholds must be provided and other thresholds are not applicable. 319 */ 320 @DataClass.Generated.Member setComponentLevelThresholds(@onNull PerStateBytes value)321 public @NonNull Builder setComponentLevelThresholds(@NonNull PerStateBytes value) { 322 checkNotUsed(); 323 mBuilderFieldsSet |= 0x1; 324 mComponentLevelThresholds = value; 325 return this; 326 } 327 328 /** 329 * Package specific thresholds only for system and vendor packages. 330 * 331 * NOTE: For packages that share a UID, the package name should be the shared package name 332 * because the I/O usage is aggregated for all packages under the shared UID. The shared 333 * package names should have the prefix 'shared:'. 334 * 335 * <p>System component must provide package specific thresholds only for system packages. 336 * <p>Vendor component must provide package specific thresholds only for vendor packages. 337 */ 338 @DataClass.Generated.Member setPackageSpecificThresholds(@onNull Map<String,PerStateBytes> value)339 public @NonNull Builder setPackageSpecificThresholds(@NonNull Map<String,PerStateBytes> value) { 340 checkNotUsed(); 341 mBuilderFieldsSet |= 0x2; 342 mPackageSpecificThresholds = value; 343 return this; 344 } 345 346 /** @see #setPackageSpecificThresholds */ 347 @DataClass.Generated.Member addPackageSpecificThresholds(@onNull String key, @NonNull PerStateBytes value)348 public @NonNull Builder addPackageSpecificThresholds(@NonNull String key, @NonNull PerStateBytes value) { 349 // You can refine this method's name by providing item's singular name, e.g.: 350 // @DataClass.PluralOf("item")) mItems = ... 351 352 if (mPackageSpecificThresholds == null) setPackageSpecificThresholds(new java.util.LinkedHashMap()); 353 mPackageSpecificThresholds.put(key, value); 354 return this; 355 } 356 357 /** 358 * Application category specific thresholds. 359 * 360 * <p>The key must be one of the {@link ResourceOveruseConfiguration#ApplicationCategoryType} 361 * constants. 362 * 363 * <p>These are applied when package specific thresholds are not provided for a package and a 364 * package is covered by one of the 365 * {@link ResourceOveruseConfiguration#ApplicationCategoryType}. These thresholds must be 366 * provided only by the vendor component. 367 */ 368 @DataClass.Generated.Member setAppCategorySpecificThresholds(@onNull Map<String,PerStateBytes> value)369 public @NonNull Builder setAppCategorySpecificThresholds(@NonNull Map<String,PerStateBytes> value) { 370 checkNotUsed(); 371 mBuilderFieldsSet |= 0x4; 372 mAppCategorySpecificThresholds = value; 373 return this; 374 } 375 376 /** @see #setAppCategorySpecificThresholds */ 377 @DataClass.Generated.Member addAppCategorySpecificThresholds(@onNull String key, @NonNull PerStateBytes value)378 public @NonNull Builder addAppCategorySpecificThresholds(@NonNull String key, @NonNull PerStateBytes value) { 379 // You can refine this method's name by providing item's singular name, e.g.: 380 // @DataClass.PluralOf("item")) mItems = ... 381 382 if (mAppCategorySpecificThresholds == null) setAppCategorySpecificThresholds(new java.util.LinkedHashMap()); 383 mAppCategorySpecificThresholds.put(key, value); 384 return this; 385 } 386 387 /** 388 * List of system-wide thresholds used to detect overall disk I/O overuse. 389 * 390 * <p>These thresholds must be provided only by the system component. 391 */ 392 @DataClass.Generated.Member setSystemWideThresholds(@onNull List<IoOveruseAlertThreshold> value)393 public @NonNull Builder setSystemWideThresholds(@NonNull List<IoOveruseAlertThreshold> value) { 394 checkNotUsed(); 395 mBuilderFieldsSet |= 0x8; 396 mSystemWideThresholds = value; 397 return this; 398 } 399 400 /** @see #setSystemWideThresholds */ 401 @DataClass.Generated.Member addSystemWideThresholds(@onNull IoOveruseAlertThreshold value)402 public @NonNull Builder addSystemWideThresholds(@NonNull IoOveruseAlertThreshold value) { 403 // You can refine this method's name by providing item's singular name, e.g.: 404 // @DataClass.PluralOf("item")) mItems = ... 405 406 if (mSystemWideThresholds == null) setSystemWideThresholds(new java.util.ArrayList<>()); 407 mSystemWideThresholds.add(value); 408 return this; 409 } 410 411 /** Builds the instance. This builder should not be touched after calling this! */ build()412 public @NonNull IoOveruseConfiguration build() { 413 checkNotUsed(); 414 mBuilderFieldsSet |= 0x10; // Mark builder used 415 416 IoOveruseConfiguration o = new IoOveruseConfiguration( 417 mComponentLevelThresholds, 418 mPackageSpecificThresholds, 419 mAppCategorySpecificThresholds, 420 mSystemWideThresholds); 421 return o; 422 } 423 checkNotUsed()424 private void checkNotUsed() { 425 if ((mBuilderFieldsSet & 0x10) != 0) { 426 throw new IllegalStateException( 427 "This Builder should not be reused. Use a new Builder instance instead"); 428 } 429 } 430 } 431 432 @DataClass.Generated( 433 time = 1721754505645L, 434 codegenVersion = "1.0.23", 435 sourceFile = "packages/services/Car/car-lib/src/android/car/watchdog/IoOveruseConfiguration.java", 436 inputSignatures = "private @android.annotation.NonNull android.car.watchdog.PerStateBytes mComponentLevelThresholds\nprivate @android.annotation.NonNull java.util.Map<java.lang.String,android.car.watchdog.PerStateBytes> mPackageSpecificThresholds\nprivate @android.annotation.NonNull java.util.Map<java.lang.String,android.car.watchdog.PerStateBytes> mAppCategorySpecificThresholds\nprivate @android.annotation.NonNull java.util.List<android.car.watchdog.IoOveruseAlertThreshold> mSystemWideThresholds\nclass IoOveruseConfiguration extends java.lang.Object implements [android.os.Parcelable]\n@com.android.car.internal.util.DataClass(genToString=true, genBuilder=true, genHiddenConstDefs=true)") 437 @Deprecated 438 @ExcludeFromCodeCoverageGeneratedReport(reason = BOILERPLATE_CODE) __metadata()439 private void __metadata() {} 440 441 442 //@formatter:on 443 // End of generated code 444 445 } 446