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