1 /* 2 * Copyright (C) 2020 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.hardware.power; 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.car.internal.util.AnnotationValidations; 26 import com.android.car.internal.util.DataClass; 27 28 /** 29 * Filter to receive power policy changes that a listener is interested in. 30 * 31 * For the record: When running codegen, auto-generated constructor of {@link Builder} which takes 32 * one argument should be removed manually, so that we can use the default constructor. 33 */ 34 @DataClass(genBuilder = true) 35 public final class CarPowerPolicyFilter implements Parcelable { 36 /** 37 * List of components of interest. Components are one of 38 * {@code android.frameworks.automotive.powerpolicy.PowerComponent}. 39 */ 40 private @NonNull int[] mComponents = new int[]{}; 41 42 43 44 // Code below generated by codegen v1.0.23. 45 // 46 // DO NOT MODIFY! 47 // CHECKSTYLE:OFF Generated code 48 // 49 // To regenerate run: 50 // $ codegen $ANDROID_BUILD_TOP/packages/services/Car/car-lib/src/android/car/hardware/power/CarPowerPolicyFilter.java 51 // Added AddedInOrBefore or ApiRequirement Annotation manually 52 // 53 // To exclude the generated code from IntelliJ auto-formatting enable (one-time): 54 // Settings > Editor > Code Style > Formatter Control 55 //@formatter:off 56 57 58 @DataClass.Generated.Member CarPowerPolicyFilter( @onNull int[] components)59 /* package-private */ CarPowerPolicyFilter( 60 @NonNull int[] components) { 61 this.mComponents = components; 62 AnnotationValidations.validate( 63 NonNull.class, null, mComponents); 64 65 // onConstructed(); // You can define this method to get a callback 66 } 67 68 /** 69 * List of components of interest. Components are one of 70 * {@code android.frameworks.automotive.powerpolicy.PowerComponent}. 71 */ 72 @DataClass.Generated.Member getComponents()73 public @NonNull int[] getComponents() { 74 return mComponents; 75 } 76 77 @Override 78 @DataClass.Generated.Member writeToParcel(@onNull android.os.Parcel dest, int flags)79 public void writeToParcel(@NonNull android.os.Parcel dest, int flags) { 80 // You can override field parcelling by defining methods like: 81 // void parcelFieldName(Parcel dest, int flags) { ... } 82 83 dest.writeIntArray(mComponents); 84 } 85 86 @Override 87 @DataClass.Generated.Member 88 @ExcludeFromCodeCoverageGeneratedReport(reason = BOILERPLATE_CODE) describeContents()89 public int describeContents() { return 0; } 90 91 /** @hide */ 92 @SuppressWarnings({"unchecked", "RedundantCast"}) 93 @DataClass.Generated.Member CarPowerPolicyFilter(@onNull android.os.Parcel in)94 /* package-private */ CarPowerPolicyFilter(@NonNull android.os.Parcel in) { 95 // You can override field unparcelling by defining methods like: 96 // static FieldType unparcelFieldName(Parcel in) { ... } 97 98 int[] components = in.createIntArray(); 99 100 this.mComponents = components; 101 AnnotationValidations.validate( 102 NonNull.class, null, mComponents); 103 104 // onConstructed(); // You can define this method to get a callback 105 } 106 107 @DataClass.Generated.Member 108 public static final @NonNull Parcelable.Creator<CarPowerPolicyFilter> CREATOR 109 = new Parcelable.Creator<CarPowerPolicyFilter>() { 110 @Override 111 public CarPowerPolicyFilter[] newArray(int size) { 112 return new CarPowerPolicyFilter[size]; 113 } 114 115 @Override 116 public CarPowerPolicyFilter createFromParcel(@NonNull android.os.Parcel in) { 117 return new CarPowerPolicyFilter(in); 118 } 119 }; 120 121 /** 122 * A builder for {@link CarPowerPolicyFilter} 123 */ 124 @SuppressWarnings("WeakerAccess") 125 @DataClass.Generated.Member 126 public static final class Builder { 127 128 private @NonNull int[] mComponents; 129 130 private long mBuilderFieldsSet = 0L; 131 Builder()132 public Builder() { 133 } 134 135 /** 136 * List of components of interest. Components are one of 137 * {@code android.frameworks.automotive.powerpolicy.PowerComponent}. 138 */ 139 @DataClass.Generated.Member setComponents(@onNull int... value)140 public @NonNull Builder setComponents(@NonNull int... value) { 141 checkNotUsed(); 142 mBuilderFieldsSet |= 0x1; 143 mComponents = value; 144 return this; 145 } 146 147 /** Builds the instance. This builder should not be touched after calling this! */ build()148 public @NonNull CarPowerPolicyFilter build() { 149 checkNotUsed(); 150 mBuilderFieldsSet |= 0x2; // Mark builder used 151 152 if ((mBuilderFieldsSet & 0x1) == 0) { 153 mComponents = new int[] {}; 154 } 155 CarPowerPolicyFilter o = new CarPowerPolicyFilter( 156 mComponents); 157 return o; 158 } 159 checkNotUsed()160 private void checkNotUsed() { 161 if ((mBuilderFieldsSet & 0x2) != 0) { 162 throw new IllegalStateException( 163 "This Builder should not be reused. Use a new Builder instance instead"); 164 } 165 } 166 } 167 168 @DataClass.Generated( 169 time = 1628099142505L, 170 codegenVersion = "1.0.23", 171 sourceFile = "packages/services/Car/car-lib/src/android/car/hardware/power/CarPowerPolicyFilter.java", 172 inputSignatures = "private @android.annotation.NonNull int[] mComponents\nclass CarPowerPolicyFilter extends java.lang.Object implements [android.os.Parcelable]\n@com.android.car.internal.util.DataClass(genBuilder=true)") 173 @Deprecated 174 @ExcludeFromCodeCoverageGeneratedReport(reason = BOILERPLATE_CODE) __metadata()175 private void __metadata() {} 176 177 178 //@formatter:on 179 // End of generated code 180 181 } 182