Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit b23d8238 authored by Sundeep Gopalaswamy's avatar Sundeep Gopalaswamy
Browse files

Read minimum volume for alarm from config

Bug: 304358183
Test: Check if alarm min volume can be zero
Change-Id: I9a78ba842e4ebf3bed51fb3e61c9e144cb0e9adf
parent 645d85f6
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -2246,6 +2246,9 @@
    <!-- The default volume for the ring stream -->
    <integer name="config_audio_ring_vol_default">5</integer>

    <!-- The default min volume for the alarm stream -->
    <integer name="config_audio_alarm_min_vol">1</integer>

    <!-- The default value for whether head tracking for
         spatial audio is enabled for a newly connected audio device -->
    <bool name="config_spatial_audio_head_tracking_enabled_default">false</bool>
+1 −0
Original line number Diff line number Diff line
@@ -287,6 +287,7 @@
  <java-symbol type="integer" name="config_audio_notif_vol_steps" />
  <java-symbol type="integer" name="config_audio_ring_vol_default" />
  <java-symbol type="integer" name="config_audio_ring_vol_steps" />
  <java-symbol type="integer" name="config_audio_alarm_min_vol" />
  <java-symbol type="bool" name="config_spatial_audio_head_tracking_enabled_default" />
  <java-symbol type="bool" name="config_avoidGfxAccel" />
  <java-symbol type="bool" name="config_bluetooth_address_validation" />
+14 −0
Original line number Diff line number Diff line
@@ -38,6 +38,7 @@ import static android.provider.Settings.Secure.VOLUME_HUSH_MUTE;
import static android.provider.Settings.Secure.VOLUME_HUSH_OFF;
import static android.provider.Settings.Secure.VOLUME_HUSH_VIBRATE;
import static com.android.media.audio.Flags.alarmMinVolumeZero;
import static com.android.media.audio.Flags.bluetoothMacAddressAnonymization;
import static com.android.media.audio.Flags.disablePrescaleAbsoluteVolume;
import static com.android.server.audio.SoundDoseHelper.ACTION_CHECK_MUSIC_ACTIVE;
@@ -1191,6 +1192,19 @@ public class AudioService extends IAudioService.Stub
            MAX_STREAM_VOLUME[AudioSystem.STREAM_ALARM] = maxAlarmVolume;
        }
        if (alarmMinVolumeZero()) {
            try {
                int minAlarmVolume = mContext.getResources().getInteger(
                        com.android.internal.R.integer.config_audio_alarm_min_vol);
                if (minAlarmVolume <= MAX_STREAM_VOLUME[AudioSystem.STREAM_ALARM]) {
                    MIN_STREAM_VOLUME[AudioSystem.STREAM_ALARM] = minAlarmVolume;
                } else {
                    Log.e(TAG, "Error min alarm volume greater than max alarm volume");
                }
            } catch (Resources.NotFoundException e) {
                Log.e(TAG, "Error querying for alarm min volume ", e);
            }
        }
        int defaultAlarmVolume = SystemProperties.getInt("ro.config.alarm_vol_default", -1);
        if (defaultAlarmVolume != -1 &&
                defaultAlarmVolume <= MAX_STREAM_VOLUME[AudioSystem.STREAM_ALARM]) {