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