1 /* 2 * Copyright (C) 2022 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.os; 18 19 import static com.android.car.internal.ExcludeFromCodeCoverageGeneratedReport.BOILERPLATE_CODE; 20 21 import android.car.annotation.ExperimentalFeature; 22 import android.os.Parcelable; 23 24 import com.android.car.internal.ExcludeFromCodeCoverageGeneratedReport; 25 import com.android.car.internal.util.DataClass; 26 27 /** 28 * CPU availability information. 29 * 30 * @hide 31 */ 32 @ExperimentalFeature 33 @DataClass(genToString = true, genHiddenBuilder = true) 34 @ExcludeFromCodeCoverageGeneratedReport(reason = BOILERPLATE_CODE) 35 public final class CpuAvailabilityInfo implements Parcelable { 36 /** Returns the CPUSET, whose availability info is recorded in this object. 37 * 38 * <p>The returned CPUSET value is one of the CPUSET_* constants from 39 * {@link CpuAvailabilityMonitoringConfig} 40 */ 41 private int mCpuset; 42 43 /** Returns the current average CPU availability percent. */ 44 private int mAverageAvailabilityPercent; 45 46 /** Returns true, when the listener has timed out. Otherwise, returns false. */ 47 private boolean mTimeout = false; 48 49 50 51 // Code below generated by codegen v1.0.23. 52 // 53 // DO NOT MODIFY! 54 // CHECKSTYLE:OFF Generated code 55 // 56 // To regenerate run: 57 // $ codegen $ANDROID_BUILD_TOP/packages/services/Car/car-lib/src/android/car/os/CpuAvailabilityInfo.java 58 // Added AddedInOrBefore or ApiRequirement Annotation manually 59 // 60 // To exclude the generated code from IntelliJ auto-formatting enable (one-time): 61 // Settings > Editor > Code Style > Formatter Control 62 //@formatter:off 63 64 65 @DataClass.Generated.Member CpuAvailabilityInfo( int cpuset, int averageAvailabilityPercent, boolean timeout)66 /* package-private */ CpuAvailabilityInfo( 67 int cpuset, 68 int averageAvailabilityPercent, 69 boolean timeout) { 70 this.mCpuset = cpuset; 71 this.mAverageAvailabilityPercent = averageAvailabilityPercent; 72 this.mTimeout = timeout; 73 74 // onConstructed(); // You can define this method to get a callback 75 } 76 77 /** 78 * Returns the CPUSET, whose availability info is recorded in this object. 79 * 80 * <p>The returned CPUSET value is one of the CPUSET_* constants from 81 * {@link CpuAvailabilityMonitoringConfig} 82 */ 83 @DataClass.Generated.Member getCpuset()84 public int getCpuset() { 85 return mCpuset; 86 } 87 88 /** 89 * Returns the current average CPU availability percent. 90 */ 91 @DataClass.Generated.Member getAverageAvailabilityPercent()92 public int getAverageAvailabilityPercent() { 93 return mAverageAvailabilityPercent; 94 } 95 96 /** 97 * Returns true, when the listener has timed out. Otherwise, returns false. 98 */ 99 @DataClass.Generated.Member isTimeout()100 public boolean isTimeout() { 101 return mTimeout; 102 } 103 104 @Override 105 @DataClass.Generated.Member toString()106 public String toString() { 107 // You can override field toString logic by defining methods like: 108 // String fieldNameToString() { ... } 109 110 return "CpuAvailabilityInfo { " + 111 "cpuset = " + mCpuset + ", " + 112 "averageAvailabilityPercent = " + mAverageAvailabilityPercent + ", " + 113 "timeout = " + mTimeout + 114 " }"; 115 } 116 117 @Override 118 @DataClass.Generated.Member writeToParcel(@ndroid.annotation.NonNull android.os.Parcel dest, int flags)119 public void writeToParcel(@android.annotation.NonNull android.os.Parcel dest, int flags) { 120 // You can override field parcelling by defining methods like: 121 // void parcelFieldName(Parcel dest, int flags) { ... } 122 123 byte flg = 0; 124 if (mTimeout) flg |= 0x4; 125 dest.writeByte(flg); 126 dest.writeInt(mCpuset); 127 dest.writeInt(mAverageAvailabilityPercent); 128 } 129 130 @Override 131 @DataClass.Generated.Member describeContents()132 public int describeContents() { return 0; } 133 134 /** @hide */ 135 @SuppressWarnings({"unchecked", "RedundantCast"}) 136 @DataClass.Generated.Member CpuAvailabilityInfo(@ndroid.annotation.NonNull android.os.Parcel in)137 /* package-private */ CpuAvailabilityInfo(@android.annotation.NonNull android.os.Parcel in) { 138 // You can override field unparcelling by defining methods like: 139 // static FieldType unparcelFieldName(Parcel in) { ... } 140 141 byte flg = in.readByte(); 142 boolean timeout = (flg & 0x4) != 0; 143 int cpuset = in.readInt(); 144 int averageAvailabilityPercent = in.readInt(); 145 146 this.mCpuset = cpuset; 147 this.mAverageAvailabilityPercent = averageAvailabilityPercent; 148 this.mTimeout = timeout; 149 150 // onConstructed(); // You can define this method to get a callback 151 } 152 153 @DataClass.Generated.Member 154 public static final @android.annotation.NonNull Parcelable.Creator<CpuAvailabilityInfo> CREATOR 155 = new Parcelable.Creator<CpuAvailabilityInfo>() { 156 @Override 157 public CpuAvailabilityInfo[] newArray(int size) { 158 return new CpuAvailabilityInfo[size]; 159 } 160 161 @Override 162 public CpuAvailabilityInfo createFromParcel(@android.annotation.NonNull android.os.Parcel in) { 163 return new CpuAvailabilityInfo(in); 164 } 165 }; 166 167 /** 168 * A builder for {@link CpuAvailabilityInfo} 169 * @hide 170 */ 171 @SuppressWarnings("WeakerAccess") 172 @DataClass.Generated.Member 173 public static final class Builder { 174 175 private int mCpuset; 176 private int mAverageAvailabilityPercent; 177 private boolean mTimeout; 178 179 private long mBuilderFieldsSet = 0L; 180 181 /** 182 * Creates a new Builder. 183 * 184 * @param cpuset 185 * Returns the CPUSET, whose availability info is recorded in this object. 186 * 187 * <p>The returned CPUSET value is one of the CPUSET_* constants from 188 * {@link CpuAvailabilityMonitoringConfig} 189 * @param averageAvailabilityPercent 190 * Returns the current average CPU availability percent. 191 */ Builder( int cpuset, int averageAvailabilityPercent)192 public Builder( 193 int cpuset, 194 int averageAvailabilityPercent) { 195 mCpuset = cpuset; 196 mAverageAvailabilityPercent = averageAvailabilityPercent; 197 } 198 199 /** 200 * Returns the CPUSET, whose availability info is recorded in this object. 201 * 202 * <p>The returned CPUSET value is one of the CPUSET_* constants from 203 * {@link CpuAvailabilityMonitoringConfig} 204 */ 205 @DataClass.Generated.Member setCpuset(int value)206 public @android.annotation.NonNull Builder setCpuset(int value) { 207 checkNotUsed(); 208 mBuilderFieldsSet |= 0x1; 209 mCpuset = value; 210 return this; 211 } 212 213 /** 214 * Returns the current average CPU availability percent. 215 */ 216 @DataClass.Generated.Member setAverageAvailabilityPercent(int value)217 public @android.annotation.NonNull Builder setAverageAvailabilityPercent(int value) { 218 checkNotUsed(); 219 mBuilderFieldsSet |= 0x2; 220 mAverageAvailabilityPercent = value; 221 return this; 222 } 223 224 /** 225 * Returns true, when the listener has timed out. Otherwise, returns false. 226 */ 227 @DataClass.Generated.Member setTimeout(boolean value)228 public @android.annotation.NonNull Builder setTimeout(boolean value) { 229 checkNotUsed(); 230 mBuilderFieldsSet |= 0x4; 231 mTimeout = value; 232 return this; 233 } 234 235 /** Builds the instance. This builder should not be touched after calling this! */ build()236 public @android.annotation.NonNull CpuAvailabilityInfo build() { 237 checkNotUsed(); 238 mBuilderFieldsSet |= 0x8; // Mark builder used 239 240 if ((mBuilderFieldsSet & 0x4) == 0) { 241 mTimeout = false; 242 } 243 CpuAvailabilityInfo o = new CpuAvailabilityInfo( 244 mCpuset, 245 mAverageAvailabilityPercent, 246 mTimeout); 247 return o; 248 } 249 checkNotUsed()250 private void checkNotUsed() { 251 if ((mBuilderFieldsSet & 0x8) != 0) { 252 throw new IllegalStateException( 253 "This Builder should not be reused. Use a new Builder instance instead"); 254 } 255 } 256 } 257 258 @DataClass.Generated( 259 time = 1644001449539L, 260 codegenVersion = "1.0.23", 261 sourceFile = "packages/services/Car/car-lib/src/android/car/os/CpuAvailabilityInfo.java", 262 inputSignatures = "private int mCpuset\nprivate int mAverageAvailabilityPercent\nprivate boolean mTimeout\nclass CpuAvailabilityInfo extends java.lang.Object implements [android.os.Parcelable]\n@com.android.car.internal.util.DataClass(genToString=true, genHiddenBuilder=true)") 263 @Deprecated __metadata()264 private void __metadata() {} 265 266 267 //@formatter:on 268 // End of generated code 269 270 } 271