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