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

Commit 09b6c215 authored by Chris Kuiper's avatar Chris Kuiper Committed by Ari Hausman-Cohen
Browse files

audioservice: add more properties for volume steps and default volumes

This adds logic to properly handle:

1) ro.config.alarm_vol_steps and ro.config.system_vol_steps properties to
   overwrite the max stream volumes for STREAM_ALARM and STREAM_SYSTEM.

2) ro.config.alarm_vol_default and ro.config.system_vol_default properties to
   overwrite the default volume levels used after FDR.

Bug: b/71605702
Test: build image that sets the new properties and verified proper usage.

Change-Id: I8f423456c006596d87addd7156bcef2503e45486
(cherry picked from commit 49eba612207c677fbae9f99265fe59bbd1e3d57c)
(cherry picked from commit 5c31b1f3853d4391aef573369f56d292a7ad3e10)
parent b5837d14
Loading
Loading
Loading
Loading
+30 −0
Original line number Diff line number Diff line
@@ -727,6 +727,36 @@ public class AudioService extends IAudioService.Stub
            }
        }

        int maxAlarmVolume = SystemProperties.getInt("ro.config.alarm_vol_steps", -1);
        if (maxAlarmVolume != -1) {
            MAX_STREAM_VOLUME[AudioSystem.STREAM_ALARM] = maxAlarmVolume;
        }

        int defaultAlarmVolume = SystemProperties.getInt("ro.config.alarm_vol_default", -1);
        if (defaultAlarmVolume != -1 &&
                defaultAlarmVolume <= MAX_STREAM_VOLUME[AudioSystem.STREAM_ALARM]) {
            AudioSystem.DEFAULT_STREAM_VOLUME[AudioSystem.STREAM_ALARM] = defaultAlarmVolume;
        } else {
            // Default is 6 out of 7 (default maximum), so scale accordingly.
            AudioSystem.DEFAULT_STREAM_VOLUME[AudioSystem.STREAM_ALARM] =
                        6 * MAX_STREAM_VOLUME[AudioSystem.STREAM_ALARM] / 7;
        }

        int maxSystemVolume = SystemProperties.getInt("ro.config.system_vol_steps", -1);
        if (maxSystemVolume != -1) {
            MAX_STREAM_VOLUME[AudioSystem.STREAM_SYSTEM] = maxSystemVolume;
        }

        int defaultSystemVolume = SystemProperties.getInt("ro.config.system_vol_default", -1);
        if (defaultSystemVolume != -1 &&
                defaultSystemVolume <= MAX_STREAM_VOLUME[AudioSystem.STREAM_SYSTEM]) {
            AudioSystem.DEFAULT_STREAM_VOLUME[AudioSystem.STREAM_SYSTEM] = defaultSystemVolume;
        } else {
            // Default is to use maximum.
            AudioSystem.DEFAULT_STREAM_VOLUME[AudioSystem.STREAM_SYSTEM] =
                        MAX_STREAM_VOLUME[AudioSystem.STREAM_SYSTEM];
        }

        sSoundEffectVolumeDb = context.getResources().getInteger(
                com.android.internal.R.integer.config_soundEffectVolumeDb);