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 com.android.car.audio; 18 19 import android.hardware.automotive.audiocontrol.AudioGainConfigInfo; 20 21 import java.util.Objects; 22 23 /** 24 * Audio Gain Config Information for a given Device based on its address. 25 */ 26 public class CarAudioGainConfigInfo { 27 private final AudioGainConfigInfo mAudioGainConfigInfo; 28 29 /** 30 * Constructor of the car audio gain info configuration based on the {@link 31 * AudioGainConfigInfo}. 32 * 33 * @param audioGainConfigInfo {@link AudioGainConfigInfo} to convert. 34 * @return new car audio gain info 35 */ CarAudioGainConfigInfo(AudioGainConfigInfo audioGainConfigInfo)36 public CarAudioGainConfigInfo(AudioGainConfigInfo audioGainConfigInfo) { 37 mAudioGainConfigInfo = audioGainConfigInfo; 38 } 39 getAudioGainConfigInfo()40 public AudioGainConfigInfo getAudioGainConfigInfo() { 41 return mAudioGainConfigInfo; 42 } 43 getZoneId()44 public int getZoneId() { 45 return mAudioGainConfigInfo.zoneId; 46 } 47 getDeviceAddress()48 public String getDeviceAddress() { 49 return mAudioGainConfigInfo.devicePortAddress; 50 } 51 getVolumeIndex()52 public int getVolumeIndex() { 53 return mAudioGainConfigInfo.volumeIndex; 54 } 55 56 /** Returns the string representation of the car audio gain configuration */ toString()57 public String toString() { 58 return "zone: " 59 + getZoneId() 60 + ", address: " 61 + getDeviceAddress() 62 + ", Volume Index: " 63 + getVolumeIndex(); 64 } 65 66 @Override equals(Object o)67 public boolean equals(Object o) { 68 if (this == o) { 69 return true; 70 } 71 if (!(o instanceof CarAudioGainConfigInfo)) { 72 return false; 73 } 74 CarAudioGainConfigInfo other = (CarAudioGainConfigInfo) o; 75 return getZoneId() == other.getZoneId() 76 && getDeviceAddress().equals(other.getDeviceAddress()) 77 && getVolumeIndex() == other.getVolumeIndex(); 78 } 79 80 @Override hashCode()81 public int hashCode() { 82 return Objects.hash(getZoneId(), getDeviceAddress(), getVolumeIndex()); 83 } 84 } 85