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.oem; 18 19 import static com.android.car.internal.ExcludeFromCodeCoverageGeneratedReport.BOILERPLATE_CODE; 20 import static com.android.car.internal.util.AnnotationValidations.validate; 21 22 import android.annotation.NonNull; 23 import android.annotation.SystemApi; 24 import android.car.media.CarVolumeGroupInfo; 25 import android.media.AudioAttributes; 26 import android.os.Parcel; 27 import android.os.Parcelable; 28 29 import com.android.car.internal.ExcludeFromCodeCoverageGeneratedReport; 30 import com.android.car.internal.util.DataClass; 31 import com.android.internal.annotations.VisibleForTesting; 32 33 import java.util.ArrayList; 34 import java.util.List; 35 import java.util.Objects; 36 37 /** 38 * Class to encapsulate car volume audio evaluation request 39 * 40 * @hide 41 */ 42 @SystemApi 43 @DataClass( 44 genToString = true, 45 genHiddenConstructor = true, 46 genHiddenConstDefs = true, 47 genBuilder = true, 48 genEqualsHashCode = true) 49 public final class OemCarAudioVolumeRequest implements Parcelable { 50 private final int mAudioZoneId; 51 private final int mCallState; 52 @NonNull 53 private final List<AudioAttributes> mActivePlaybackAttributes; 54 @NonNull 55 private final List<AudioAttributes> mDuckedAudioAttributes; 56 @NonNull 57 private final List<CarVolumeGroupInfo> mCarVolumeGroupInfos; 58 59 60 61 // Code below generated by codegen v1.0.23. 62 // 63 // DO NOT MODIFY! 64 // CHECKSTYLE:OFF Generated code 65 // 66 // To regenerate run: 67 // $ codegen $ANDROID_BUILD_TOP/packages/services/Car/car-lib/src/android/car/oem 68 // /OemCarAudioVolumeRequest.java 69 // Added AddedInOrBefore or ApiRequirement Annotation manually 70 // 71 // To exclude the generated code from IntelliJ auto-formatting enable (one-time): 72 // Settings > Editor > Code Style > Formatter Control 73 //@formatter:off 74 75 76 /** 77 * Creates a new OemCarAudioVolumeRequest 78 * 79 * @hide 80 */ 81 @DataClass.Generated.Member 82 @VisibleForTesting() OemCarAudioVolumeRequest( int audioZoneId, int callState, @NonNull List<AudioAttributes> activePlaybackAttributes, @NonNull List<AudioAttributes> duckedAudioAttributes, @NonNull List<CarVolumeGroupInfo> carVolumeGroupInfos)83 public OemCarAudioVolumeRequest( 84 int audioZoneId, 85 int callState, 86 @NonNull List<AudioAttributes> activePlaybackAttributes, 87 @NonNull List<AudioAttributes> duckedAudioAttributes, 88 @NonNull List<CarVolumeGroupInfo> carVolumeGroupInfos) { 89 this.mAudioZoneId = audioZoneId; 90 this.mCallState = callState; 91 this.mActivePlaybackAttributes = activePlaybackAttributes; 92 validate(NonNull.class, null, mActivePlaybackAttributes); 93 this.mDuckedAudioAttributes = duckedAudioAttributes; 94 validate(NonNull.class, null, mDuckedAudioAttributes); 95 this.mCarVolumeGroupInfos = carVolumeGroupInfos; 96 validate(NonNull.class, null, mCarVolumeGroupInfos); 97 98 // onConstructed(); // You can define this method to get a callback 99 } 100 101 /** 102 * @return the audio zone id where the request belongs 103 */ 104 @DataClass.Generated.Member getAudioZoneId()105 public int getAudioZoneId() { 106 return mAudioZoneId; 107 } 108 109 /** 110 * @return the current phone call state 111 * 112 * <p>Will be one of {@link TelephonyManager.CALL_STATE_IDLE}, 113 * {@link TelephonyManager.CALL_STATE_RINGING}, {@link TelephonyManager.CALL_STATE_OFFHOOK}, 114 */ 115 @DataClass.Generated.Member getCallState()116 public int getCallState() { 117 return mCallState; 118 } 119 120 /** 121 * @return audio attributes which are actively playing in the zone obtain by 122 * {@code #getAudioZoneId()} 123 */ 124 @DataClass.Generated.Member getActivePlaybackAttributes()125 public @NonNull List<AudioAttributes> getActivePlaybackAttributes() { 126 return mActivePlaybackAttributes; 127 } 128 129 /** 130 * @return the current ducked audio attributes 131 */ 132 @DataClass.Generated.Member getDuckedAudioAttributes()133 public @NonNull List<AudioAttributes> getDuckedAudioAttributes() { 134 return mDuckedAudioAttributes; 135 } 136 137 /** 138 * @return the zone's volume infos, which can be used to determine the current state for a 139 * particular volume change 140 */ 141 @DataClass.Generated.Member getCarVolumeGroupInfos()142 public @NonNull List<CarVolumeGroupInfo> getCarVolumeGroupInfos() { 143 return mCarVolumeGroupInfos; 144 } 145 146 @Override 147 @DataClass.Generated.Member toString()148 public String toString() { 149 // You can override field toString logic by defining methods like: 150 // String fieldNameToString() { ... } 151 152 return "OemCarAudioVolumeRequest { " + 153 "audioZoneId = " + mAudioZoneId + ", " + 154 "callState = " + mCallState + ", " + 155 "activePlaybackAttributes = " + mActivePlaybackAttributes + ", " + 156 "duckedAudioAttributes = " + mDuckedAudioAttributes + ", " + 157 "carVolumeGroupInfos = " + mCarVolumeGroupInfos + 158 " }"; 159 } 160 161 @Override 162 @DataClass.Generated.Member equals(@ndroid.annotation.Nullable Object o)163 public boolean equals(@android.annotation.Nullable Object o) { 164 // You can override field equality logic by defining either of the methods like: 165 // boolean fieldNameEquals(OemCarAudioVolumeRequest other) { ... } 166 // boolean fieldNameEquals(FieldType otherValue) { ... } 167 168 if (this == o) return true; 169 if (o == null || getClass() != o.getClass()) return false; 170 @SuppressWarnings("unchecked") 171 OemCarAudioVolumeRequest that = (OemCarAudioVolumeRequest) o; 172 //noinspection PointlessBooleanExpression 173 return true 174 && mAudioZoneId == that.mAudioZoneId 175 && mCallState == that.mCallState 176 && Objects.equals(mActivePlaybackAttributes, that.mActivePlaybackAttributes) 177 && Objects.equals(mDuckedAudioAttributes, that.mDuckedAudioAttributes) 178 && Objects.equals(mCarVolumeGroupInfos, that.mCarVolumeGroupInfos); 179 } 180 181 @Override 182 @DataClass.Generated.Member hashCode()183 public int hashCode() { 184 // You can override field hashCode logic by defining methods like: 185 // int fieldNameHashCode() { ... } 186 187 int _hash = 1; 188 _hash = 31 * _hash + mAudioZoneId; 189 _hash = 31 * _hash + mCallState; 190 _hash = 31 * _hash + Objects.hashCode(mActivePlaybackAttributes); 191 _hash = 31 * _hash + Objects.hashCode(mDuckedAudioAttributes); 192 _hash = 31 * _hash + Objects.hashCode(mCarVolumeGroupInfos); 193 return _hash; 194 } 195 196 // TODO(b/260757994): Remove ApiRequirements for overridden methods 197 @Override 198 @DataClass.Generated.Member writeToParcel(@onNull Parcel dest, int flags)199 public void writeToParcel(@NonNull Parcel dest, int flags) { 200 // You can override field parcelling by defining methods like: 201 // void parcelFieldName(Parcel dest, int flags) { ... } 202 203 dest.writeInt(mAudioZoneId); 204 dest.writeInt(mCallState); 205 dest.writeParcelableList(mActivePlaybackAttributes, flags); 206 dest.writeParcelableList(mDuckedAudioAttributes, flags); 207 dest.writeParcelableList(mCarVolumeGroupInfos, flags); 208 } 209 210 // TODO(b/260757994): Remove ApiRequirements for overridden methods 211 @Override 212 @DataClass.Generated.Member describeContents()213 public int describeContents() { return 0; } 214 215 /** @hide */ 216 @SuppressWarnings({"unchecked", "RedundantCast"}) 217 @DataClass.Generated.Member OemCarAudioVolumeRequest(@onNull Parcel in)218 OemCarAudioVolumeRequest(@NonNull Parcel in) { 219 // You can override field unparcelling by defining methods like: 220 // static FieldType unparcelFieldName(Parcel in) { ... } 221 222 int audioZoneId = in.readInt(); 223 int callState = in.readInt(); 224 List<AudioAttributes> activePlaybackAttributes = new ArrayList<>(); 225 in.readParcelableList(activePlaybackAttributes, AudioAttributes.class.getClassLoader()); 226 List<AudioAttributes> duckedAudioAttributes = new ArrayList<>(); 227 in.readParcelableList(duckedAudioAttributes, AudioAttributes.class.getClassLoader()); 228 List<CarVolumeGroupInfo> carVolumeGroupInfos = new ArrayList<>(); 229 in.readParcelableList(carVolumeGroupInfos, CarVolumeGroupInfo.class.getClassLoader()); 230 231 this.mAudioZoneId = audioZoneId; 232 this.mCallState = callState; 233 this.mActivePlaybackAttributes = activePlaybackAttributes; 234 validate(NonNull.class, null, mActivePlaybackAttributes); 235 this.mDuckedAudioAttributes = duckedAudioAttributes; 236 validate(NonNull.class, null, mDuckedAudioAttributes); 237 this.mCarVolumeGroupInfos = carVolumeGroupInfos; 238 validate(NonNull.class, null, mCarVolumeGroupInfos); 239 240 // onConstructed(); // You can define this method to get a callback 241 } 242 243 @DataClass.Generated.Member 244 public static final @NonNull Parcelable.Creator<OemCarAudioVolumeRequest> CREATOR 245 = new Parcelable.Creator<OemCarAudioVolumeRequest>() { 246 @Override 247 public OemCarAudioVolumeRequest[] newArray(int size) { 248 return new OemCarAudioVolumeRequest[size]; 249 } 250 251 @Override 252 public OemCarAudioVolumeRequest createFromParcel(@NonNull Parcel in) { 253 return new OemCarAudioVolumeRequest(in); 254 } 255 }; 256 257 /** 258 * A builder for {@link OemCarAudioVolumeRequest} 259 */ 260 @SuppressWarnings("WeakerAccess") 261 @DataClass.Generated.Member 262 public static final class Builder { 263 264 private int mAudioZoneId; 265 private int mCallState; 266 private @NonNull List<AudioAttributes> mActivePlaybackAttributes = new ArrayList<>(); 267 private @NonNull List<AudioAttributes> mDuckedAudioAttributes = new ArrayList<>();; 268 private @NonNull List<CarVolumeGroupInfo> mCarVolumeGroupInfos = new ArrayList<>();; 269 270 private long mBuilderFieldsSet = 0L; 271 272 /** 273 * Creates a new Builder. 274 * 275 * @hide 276 */ Builder(int audioZoneId)277 public Builder(int audioZoneId) { 278 mAudioZoneId = audioZoneId; 279 } 280 281 /** 282 * Creates a new Builder based on a current request 283 * 284 * @hide 285 */ Builder(OemCarAudioVolumeRequest volumeRequest)286 public Builder(OemCarAudioVolumeRequest volumeRequest) { 287 mAudioZoneId = volumeRequest.mAudioZoneId; 288 mActivePlaybackAttributes = volumeRequest.mActivePlaybackAttributes; 289 mDuckedAudioAttributes = volumeRequest.mDuckedAudioAttributes; 290 mCarVolumeGroupInfos = volumeRequest.mCarVolumeGroupInfos; 291 } 292 293 @DataClass.Generated.Member setCallState(int value)294 public @NonNull Builder setCallState(int value) { 295 checkNotUsed(); 296 mBuilderFieldsSet |= 0x4; 297 mCallState = value; 298 return this; 299 } 300 301 @DataClass.Generated.Member setActivePlaybackAttributes(@onNull List<AudioAttributes> value)302 public @NonNull Builder setActivePlaybackAttributes(@NonNull List<AudioAttributes> value) { 303 validate(NonNull.class, null, value); 304 checkNotUsed(); 305 mBuilderFieldsSet |= 0x8; 306 mActivePlaybackAttributes = value; 307 return this; 308 } 309 310 /** @see #setActivePlaybackAttributes */ 311 @DataClass.Generated.Member addActivePlaybackAttributes(@onNull AudioAttributes value)312 public @NonNull Builder addActivePlaybackAttributes(@NonNull AudioAttributes value) { 313 // You can refine this method's name by providing item's singular name, e.g.: 314 // @DataClass.PluralOf("item")) mItems = ... 315 validate(NonNull.class, null, value); 316 if (mActivePlaybackAttributes == null) setActivePlaybackAttributes(new ArrayList<>()); 317 mActivePlaybackAttributes.add(value); 318 return this; 319 } 320 321 @DataClass.Generated.Member setDuckedAudioAttributes(@onNull List<AudioAttributes> value)322 public @NonNull Builder setDuckedAudioAttributes(@NonNull List<AudioAttributes> value) { 323 validate(NonNull.class, null, value); 324 checkNotUsed(); 325 mBuilderFieldsSet |= 0x10; 326 mDuckedAudioAttributes = value; 327 return this; 328 } 329 330 /** @see #setDuckedAudioAttributes */ 331 @DataClass.Generated.Member addDuckedAudioAttributes(@onNull AudioAttributes value)332 public @NonNull Builder addDuckedAudioAttributes(@NonNull AudioAttributes value) { 333 // You can refine this method's name by providing item's singular name, e.g.: 334 // @DataClass.PluralOf("item")) mItems = ... 335 validate(NonNull.class, null, value); 336 if (mDuckedAudioAttributes == null) setDuckedAudioAttributes(new ArrayList<>()); 337 mDuckedAudioAttributes.add(value); 338 return this; 339 } 340 341 @DataClass.Generated.Member setCarVolumeGroupInfos(@onNull List<CarVolumeGroupInfo> value)342 public @NonNull Builder setCarVolumeGroupInfos(@NonNull List<CarVolumeGroupInfo> value) { 343 validate(NonNull.class, null, value); 344 checkNotUsed(); 345 mBuilderFieldsSet |= 0x20; 346 mCarVolumeGroupInfos = value; 347 return this; 348 } 349 350 /** @see #setCarVolumeGroupInfos */ 351 @DataClass.Generated.Member addCarVolumeGroupInfos(@onNull CarVolumeGroupInfo value)352 public @NonNull Builder addCarVolumeGroupInfos(@NonNull CarVolumeGroupInfo value) { 353 // You can refine this method's name by providing item's singular name, e.g.: 354 // @DataClass.PluralOf("item")) mItems = ... 355 validate(NonNull.class, null, value); 356 if (mCarVolumeGroupInfos == null) setCarVolumeGroupInfos(new ArrayList<>()); 357 mCarVolumeGroupInfos.add(value); 358 return this; 359 } 360 361 /** Builds the instance. This builder should not be touched after calling this! */ 362 public @NonNull build()363 OemCarAudioVolumeRequest build() { 364 checkNotUsed(); 365 mBuilderFieldsSet |= 0x40; // Mark builder used 366 367 OemCarAudioVolumeRequest o = new OemCarAudioVolumeRequest( 368 mAudioZoneId, 369 mCallState, 370 mActivePlaybackAttributes, 371 mDuckedAudioAttributes, 372 mCarVolumeGroupInfos); 373 return o; 374 } 375 checkNotUsed()376 private void checkNotUsed() { 377 if ((mBuilderFieldsSet & 0x40) != 0) { 378 throw new IllegalStateException( 379 "This Builder should not be reused. Use a new Builder instance instead"); 380 } 381 } 382 } 383 384 @SuppressWarnings("unused") 385 @ExcludeFromCodeCoverageGeneratedReport(reason = BOILERPLATE_CODE) 386 @DataClass.Generated( 387 time = 1669862081880L, 388 codegenVersion = "1.0.23", 389 sourceFile = "packages/services/Car/car-lib/src/android" 390 + "/car/oem/OemCarAudioVolumeRequest.java", 391 inputSignatures = "private final int mAudioZoneId\nprivate final int mCallState\n" 392 + "private final @android.annotation.NonNull " 393 + "java.util.List<android.media.AudioAttributes> mActivePlaybackAttributes\n" 394 + "private final @android.annotation.NonNull " 395 + "java.util.List<android.media.AudioAttributes> mDuckedAudioAttributes\n" 396 + "private final @android.annotation.NonNull " 397 + "java.util.List<android.car.media.CarVolumeGroupInfo> mCarVolumeGroupInfos\n" 398 + "class OemCarAudioVolumeRequest extends java.lang.Object " 399 + "implements [android.os.Parcelable]\n@com.android.car.internal.util" 400 + ".DataClass(genToString=true, genHiddenConstructor=true," 401 + "genHiddenConstDefs=true, genBuilder=true, genEqualsHashCode=true)") 402 @Deprecated __metadata()403 private void __metadata() {} 404 405 406 //@formatter:on 407 // End of generated code 408 409 } 410