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

Commit b3def971 authored by Norman Bintang's avatar Norman Bintang Committed by Android (Google) Code Review
Browse files

Merge changes Ie2da23cb,I03da5e26,I7ad68eb7 into main

* changes:
  audio: Add volume alias for PC with single volume
  audio: Do not unmute on volume down for PC
  audio: Add PLATFORM_PC in AudioSystem
parents d1a8f9db e926dedf
Loading
Loading
Loading
Loading
+8 −0
Original line number Diff line number Diff line
@@ -26,6 +26,7 @@ import android.bluetooth.BluetoothLeAudioCodecConfig;
import android.compat.annotation.UnsupportedAppUsage;
import android.content.Context;
import android.content.pm.PackageManager;
import android.media.audio.Flags;
import android.media.audio.common.AidlConversion;
import android.media.audiofx.AudioEffect;
import android.media.audiopolicy.AudioMix;
@@ -2657,6 +2658,8 @@ public class AudioSystem
    public static final int PLATFORM_TELEVISION = 2;
    /** @hide The platform is automotive */
    public static final int PLATFORM_AUTOMOTIVE = 3;
    /** @hide The platform is pc */
    public static final int PLATFORM_PC = 4;

    /**
     * @hide
@@ -2664,6 +2667,8 @@ public class AudioSystem
     * <ul>
     * <li>{@link #PLATFORM_VOICE}</li>
     * <li>{@link #PLATFORM_TELEVISION}</li>
     * <li>{@link #PLATFORM_AUTOMOTIVE}</li>
     * <li>{@link #PLATFORM_PC}</li>
     * <li>{@link #PLATFORM_DEFAULT}</li>
     * </ul>
     */
@@ -2674,6 +2679,9 @@ public class AudioSystem
            return PLATFORM_VOICE;
        } else if (context.getPackageManager().hasSystemFeature(PackageManager.FEATURE_LEANBACK)) {
            return PLATFORM_TELEVISION;
        } else if (Flags.enablePlatformPcType()
                       && context.getPackageManager().hasSystemFeature(PackageManager.FEATURE_PC)) {
            return PLATFORM_PC;
        } else {
            return PLATFORM_DEFAULT;
        }
+28 −5
Original line number Diff line number Diff line
@@ -425,6 +425,10 @@ public class AudioService extends IAudioService.Stub
        return mPlatformType == AudioSystem.PLATFORM_AUTOMOTIVE;
    }
    /*package*/ boolean isPlatformPc() {
        return mPlatformType == AudioSystem.PLATFORM_PC;
    }
    /** The controller for the volume UI. */
    private final VolumeController mVolumeController = new VolumeController();
@@ -655,8 +659,9 @@ public class AudioService extends IAudioService.Stub
     * Some streams alias to different streams according to device category (phone or tablet) or
     * use case (in call vs off call...). See updateStreamVolumeAlias() for more details.
     *  sStreamVolumeAlias contains STREAM_VOLUME_ALIAS_VOICE aliases for a voice capable device
     *  (phone), STREAM_VOLUME_ALIAS_TELEVISION for a television or set-top box and
     *  STREAM_VOLUME_ALIAS_DEFAULT for other devices (e.g. tablets).*/
     *  (phone), STREAM_VOLUME_ALIAS_TELEVISION for a television or set-top box,
     *  STREAM_VOLUME_ALIAS_PC_SINGLE_VOLUME for a desktop/laptop that enables config_single_volume
     *  and STREAM_VOLUME_ALIAS_DEFAULT for other devices (e.g. tablets).*/
    private final int[] STREAM_VOLUME_ALIAS_VOICE = new int[] {
        AudioSystem.STREAM_VOICE_CALL,      // STREAM_VOICE_CALL
        AudioSystem.STREAM_RING,            // STREAM_SYSTEM
@@ -685,6 +690,20 @@ public class AudioService extends IAudioService.Stub
        AudioSystem.STREAM_MUSIC,       // STREAM_ACCESSIBILITY
        AudioSystem.STREAM_MUSIC        // STREAM_ASSISTANT
    };
    private final int[] STREAM_VOLUME_ALIAS_PC_SINGLE_VOLUME = new int[] {
        AudioSystem.STREAM_MUSIC,           // STREAM_VOICE_CALL
        AudioSystem.STREAM_MUSIC,           // STREAM_SYSTEM
        AudioSystem.STREAM_MUSIC,           // STREAM_RING
        AudioSystem.STREAM_MUSIC,           // STREAM_MUSIC
        AudioSystem.STREAM_MUSIC,           // STREAM_ALARM
        AudioSystem.STREAM_MUSIC,           // STREAM_NOTIFICATION
        AudioSystem.STREAM_BLUETOOTH_SCO,   // STREAM_BLUETOOTH_SCO
        AudioSystem.STREAM_MUSIC,           // STREAM_SYSTEM_ENFORCED
        AudioSystem.STREAM_MUSIC,           // STREAM_DTMF
        AudioSystem.STREAM_MUSIC,           // STREAM_TTS
        AudioSystem.STREAM_ACCESSIBILITY,   // STREAM_ACCESSIBILITY
        AudioSystem.STREAM_MUSIC            // STREAM_ASSISTANT
    };
    /**
     * Using Volume groups configuration allows to control volume per attributes
     * and group definition may differ from stream aliases.
@@ -2860,7 +2879,11 @@ public class AudioService extends IAudioService.Stub
                AudioSystem.STREAM_ASSISTANT : AudioSystem.STREAM_MUSIC;
        if (mIsSingleVolume) {
            if (isPlatformPc()) {
                initStreamVolumeAlias(STREAM_VOLUME_ALIAS_PC_SINGLE_VOLUME);
            } else {
                initStreamVolumeAlias(STREAM_VOLUME_ALIAS_TELEVISION);
            }
            dtmfStreamAlias = AudioSystem.STREAM_MUSIC;
        } else if (mUseVolumeGroupAliases) {
            initStreamVolumeAlias(STREAM_VOLUME_ALIAS_NONE);
@@ -4276,7 +4299,7 @@ public class AudioService extends IAudioService.Stub
                        // unmute immediately for volume up
                        muteAliasStreams(streamTypeAlias, false);
                    } else if (direction == AudioManager.ADJUST_LOWER) {
                        if (mIsSingleVolume) {
                        if (mIsSingleVolume && !isPlatformPc()) {
                            sendMsg(mAudioHandler, MSG_UNMUTE_STREAM_ON_SINGLE_VOL_DEVICE,
                                    SENDMSG_QUEUE, streamTypeAlias, flags, null,
                                    UNMUTE_STREAM_DELAY);
@@ -13010,7 +13033,7 @@ public class AudioService extends IAudioService.Stub
    private void updateA11yVolumeAlias(boolean a11VolEnabled) {
        if (DEBUG_VOL) Log.d(TAG, "Accessibility volume enabled = " + a11VolEnabled);
        if (mIsSingleVolume) {
        if (mIsSingleVolume && !isPlatformPc()) {
            if (DEBUG_VOL) Log.d(TAG, "Accessibility volume is not set on single volume device");
            return;
        }