1 /* 2 * Copyright (C) 2024 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.annotation.IntDef; 20 21 import com.android.internal.util.Preconditions; 22 23 final class CarActivationVolumeConfig { 24 25 /** 26 * Activation volume type invoked for the first time after boot or switching 27 * {@link CarAudioZoneConfig} or user. 28 */ 29 static final int ACTIVATION_VOLUME_ON_BOOT = 1; 30 /** 31 * Activation volume type invoked when the source (represented bu uid) of the newly active 32 * {@link android.media.AudioPlaybackConfiguration} for each {@link CarVolumeGroup} is changed 33 */ 34 static final int ACTIVATION_VOLUME_ON_SOURCE_CHANGED = 1 << 1; 35 /** 36 * Activation volume type invoked for every newly active 37 * {@link android.media.AudioPlaybackConfiguration} for each {@link CarVolumeGroup} 38 */ 39 static final int ACTIVATION_VOLUME_ON_PLAYBACK_CHANGED = 1 << 2; 40 41 private final int mInvocationType; 42 private final int mMinActivationVolumePercentage; 43 private final int mMaxActivationVolumePercentage; 44 45 @IntDef(flag = true, value = { 46 ACTIVATION_VOLUME_ON_BOOT, 47 ACTIVATION_VOLUME_ON_SOURCE_CHANGED, 48 ACTIVATION_VOLUME_ON_PLAYBACK_CHANGED 49 }) 50 @interface ActivationVolumeInvocationType {} 51 CarActivationVolumeConfig(int invocationType, int minActivationVolumePercentage, int maxActivationVolumePercentage)52 CarActivationVolumeConfig(int invocationType, int minActivationVolumePercentage, 53 int maxActivationVolumePercentage) { 54 Preconditions.checkArgument(minActivationVolumePercentage < maxActivationVolumePercentage, 55 "Min activation volume percentage can not be higher than max"); 56 mInvocationType = invocationType; 57 mMinActivationVolumePercentage = minActivationVolumePercentage; 58 mMaxActivationVolumePercentage = maxActivationVolumePercentage; 59 } 60 61 int getInvocationType() { 62 return mInvocationType; 63 } 64 65 int getMinActivationVolumePercentage() { 66 return mMinActivationVolumePercentage; 67 } 68 69 int getMaxActivationVolumePercentage() { 70 return mMaxActivationVolumePercentage; 71 } 72 } 73