Add option to show TV PiP menu on Home double tap.

Introduces a 300ms delay for single Home presses when enabled, though
only when the pip is visible.

Bug: 200008785
Test: manual
Change-Id: Ie036dfce17d816085bc6758f531a676290bbb877
This commit is contained in:
Jacqueline Bronger
2021-09-17 12:59:50 +00:00
parent 481026d372
commit 3474ec168c
2 changed files with 35 additions and 11 deletions

View File

@@ -1314,6 +1314,7 @@
<!-- Control the behavior when the user double-taps the home button.
0 - Nothing
1 - Recent apps view in SystemUI
2 - Picture-in-picture menu
This needs to match the constants in
policy/src/com/android/internal/policy/impl/PhoneWindowManager.java
-->

View File

@@ -296,6 +296,7 @@ public class PhoneWindowManager implements WindowManagerPolicy {
// must match: config_doubleTapOnHomeBehavior in config.xml
static final int DOUBLE_TAP_HOME_NOTHING = 0;
static final int DOUBLE_TAP_HOME_RECENT_SYSTEM_UI = 1;
static final int DOUBLE_TAP_HOME_PIP_MENU = 2;
static final int SHORT_PRESS_WINDOW_NOTHING = 0;
static final int SHORT_PRESS_WINDOW_PICTURE_IN_PICTURE = 1;
@@ -1742,11 +1743,15 @@ public class PhoneWindowManager implements WindowManagerPolicy {
// Delay handling home if a double-tap is possible.
if (mDoubleTapOnHomeBehavior != DOUBLE_TAP_HOME_NOTHING) {
mHandler.removeCallbacks(mHomeDoubleTapTimeoutRunnable); // just in case
mHomeDoubleTapPending = true;
mHandler.postDelayed(mHomeDoubleTapTimeoutRunnable,
ViewConfiguration.getDoubleTapTimeout());
return -1;
// For the picture-in-picture menu, only add the delay if a pip is there.
if (mDoubleTapOnHomeBehavior != DOUBLE_TAP_HOME_PIP_MENU
|| mPictureInPictureVisible) {
mHandler.removeCallbacks(mHomeDoubleTapTimeoutRunnable); // just in case
mHomeDoubleTapPending = true;
mHandler.postDelayed(mHomeDoubleTapTimeoutRunnable,
ViewConfiguration.getDoubleTapTimeout());
return -1;
}
}
// Post to main thread to avoid blocking input pipeline.
@@ -1779,7 +1784,7 @@ public class PhoneWindowManager implements WindowManagerPolicy {
if (mHomeDoubleTapPending) {
mHomeDoubleTapPending = false;
mHandler.removeCallbacks(mHomeDoubleTapTimeoutRunnable);
handleDoubleTapOnHome();
mHandler.post(this::handleDoubleTapOnHome);
// TODO(multi-display): Remove display id check once we support recents on
// multi-display
} else if (mDoubleTapOnHomeBehavior == DOUBLE_TAP_HOME_RECENT_SYSTEM_UI
@@ -1797,13 +1802,29 @@ public class PhoneWindowManager implements WindowManagerPolicy {
}
private void handleDoubleTapOnHome() {
if (mDoubleTapOnHomeBehavior == DOUBLE_TAP_HOME_RECENT_SYSTEM_UI) {
mHomeConsumed = true;
toggleRecentApps();
if (mHomeConsumed) {
return;
}
switch (mDoubleTapOnHomeBehavior) {
case DOUBLE_TAP_HOME_RECENT_SYSTEM_UI:
mHomeConsumed = true;
toggleRecentApps();
break;
case DOUBLE_TAP_HOME_PIP_MENU:
mHomeConsumed = true;
showPictureInPictureMenuInternal();
break;
default:
Log.w(TAG, "No action or undefined behavior for double tap home: "
+ mDoubleTapOnHomeBehavior);
break;
}
}
private void handleLongPressOnHome(int deviceId, long eventTime) {
if (mHomeConsumed) {
return;
}
if (mLongPressOnHomeBehavior == LONG_PRESS_HOME_NOTHING) {
return;
}
@@ -2360,8 +2381,8 @@ public class PhoneWindowManager implements WindowManagerPolicy {
mDoubleTapOnHomeBehavior = res.getInteger(
com.android.internal.R.integer.config_doubleTapOnHomeBehavior);
if (mDoubleTapOnHomeBehavior < DOUBLE_TAP_HOME_NOTHING ||
mDoubleTapOnHomeBehavior > DOUBLE_TAP_HOME_RECENT_SYSTEM_UI) {
mDoubleTapOnHomeBehavior = LONG_PRESS_HOME_NOTHING;
mDoubleTapOnHomeBehavior > DOUBLE_TAP_HOME_PIP_MENU) {
mDoubleTapOnHomeBehavior = DOUBLE_TAP_HOME_NOTHING;
}
mShortPressOnWindowBehavior = SHORT_PRESS_WINDOW_NOTHING;
@@ -5742,6 +5763,8 @@ public class PhoneWindowManager implements WindowManagerPolicy {
return "DOUBLE_TAP_HOME_NOTHING";
case DOUBLE_TAP_HOME_RECENT_SYSTEM_UI:
return "DOUBLE_TAP_HOME_RECENT_SYSTEM_UI";
case DOUBLE_TAP_HOME_PIP_MENU:
return "DOUBLE_TAP_HOME_PIP_MENU";
default:
return Integer.toString(behavior);
}