From 5da72b5be8be62accab75adc284051f6445d5c43 Mon Sep 17 00:00:00 2001 From: Winson Chung Date: Thu, 6 May 2021 15:08:44 -0700 Subject: [PATCH] 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 --- .../inputconsumers/OverviewInputConsumer.java | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/quickstep/src/com/android/quickstep/inputconsumers/OverviewInputConsumer.java b/quickstep/src/com/android/quickstep/inputconsumers/OverviewInputConsumer.java index fa9e0ec1ab..4af63386e0 100644 --- a/quickstep/src/com/android/quickstep/inputconsumers/OverviewInputConsumer.java +++ b/quickstep/src/com/android/quickstep/inputconsumers/OverviewInputConsumer.java @@ -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, 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); } }