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

Commit 5da72b5b authored by Winson Chung's avatar Winson Chung
Browse files

Handle volume key events while in overview

- Normally this gets dispatched to an app's phone window to notify
  the media session manager, but because the recents input consumer
  routes to the launcher window bypassing phone window, the event
  never gets processed.

Fixes: 185520916
Test: Open overview from an app, ensure volume dialog still shows
Change-Id: I8784a6211e56f320b8b9d688fa0568c583652725
parent 739420bc
Loading
Loading
Loading
Loading
+13 −0
Original line number Diff line number Diff line
@@ -18,6 +18,8 @@ package com.android.quickstep.inputconsumers;
import static com.android.quickstep.util.NavigationModeFeatureFlag.LIVE_TILE;
import static com.android.systemui.shared.system.ActivityManagerWrapper.CLOSE_SYSTEM_WINDOWS_REASON_RECENTS;

import android.media.AudioManager;
import android.media.session.MediaSessionManager;
import android.view.KeyEvent;
import android.view.MotionEvent;

@@ -101,6 +103,17 @@ public class OverviewInputConsumer<S extends BaseState<S>, T extends StatefulAct
    @Override
    public void onKeyEvent(KeyEvent ev) {
        if (LIVE_TILE.get()) {
            switch (ev.getKeyCode()) {
                case KeyEvent.KEYCODE_VOLUME_DOWN:
                case KeyEvent.KEYCODE_VOLUME_UP:
                case KeyEvent.KEYCODE_VOLUME_MUTE:
                    MediaSessionManager mgr = mActivity.getSystemService(MediaSessionManager.class);
                    mgr.dispatchVolumeKeyEventAsSystemService(ev,
                            AudioManager.USE_DEFAULT_STREAM_TYPE);
                    break;
                default:
                    break;
            }
            mActivity.dispatchKeyEvent(ev);
        }
    }