Merge "PIP: Use long press HOME for PIP on Android TV (2/2)"
This commit is contained in:
committed by
Android (Google) Code Review
commit
11a27b19d1
@@ -2537,6 +2537,16 @@ public class Intent implements Parcelable, Cloneable {
|
||||
@SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
|
||||
public static final String ACTION_MEDIA_BUTTON = "android.intent.action.MEDIA_BUTTON";
|
||||
|
||||
/**
|
||||
* Broadcast Action: The "Picture-in-picture (PIP) Button" was pressed.
|
||||
* Includes a single extra field, {@link #EXTRA_KEY_EVENT}, containing the key event that
|
||||
* caused the broadcast.
|
||||
* @hide
|
||||
*/
|
||||
@SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
|
||||
public static final String ACTION_PICTURE_IN_PICTURE_BUTTON =
|
||||
"android.intent.action.PICTURE_IN_PICTURE_BUTTON";
|
||||
|
||||
/**
|
||||
* Broadcast Action: The "Camera Button" was pressed. Includes a single
|
||||
* extra field, {@link #EXTRA_KEY_EVENT}, containing the key event that
|
||||
|
||||
@@ -220,6 +220,8 @@
|
||||
<protected-broadcast android:name="android.intent.action.MEDIA_UNMOUNTABLE" />
|
||||
<protected-broadcast android:name="android.intent.action.MEDIA_EJECT" />
|
||||
|
||||
<protected-broadcast android:name="android.intent.action.PICTURE_IN_PICTURE_BUTTON" />
|
||||
|
||||
<protected-broadcast android:name="android.net.conn.CAPTIVE_PORTAL" />
|
||||
<protected-broadcast android:name="android.net.conn.CONNECTIVITY_CHANGE" />
|
||||
<!-- @deprecated. Only {@link android.net.ConnectivityManager.CONNECTIVITY_ACTION} is sent. -->
|
||||
|
||||
@@ -981,6 +981,7 @@
|
||||
0 - Nothing
|
||||
1 - Recent apps view in SystemUI
|
||||
2 - Launch assist intent
|
||||
3 - Start picture-in-picture (PIP) or launch PIP UI
|
||||
This needs to match the constants in
|
||||
policy/src/com/android/internal/policy/impl/PhoneWindowManager.java
|
||||
-->
|
||||
|
||||
@@ -183,6 +183,8 @@ public class PhoneWindowManager implements WindowManagerPolicy {
|
||||
static final int LONG_PRESS_HOME_NOTHING = 0;
|
||||
static final int LONG_PRESS_HOME_RECENT_SYSTEM_UI = 1;
|
||||
static final int LONG_PRESS_HOME_ASSIST = 2;
|
||||
static final int LONG_PRESS_HOME_PICTURE_IN_PICTURE = 3;
|
||||
static final int LAST_LONG_PRESS_HOME_BEHAVIOR = LONG_PRESS_HOME_PICTURE_IN_PICTURE;
|
||||
|
||||
static final int DOUBLE_TAP_HOME_NOTHING = 0;
|
||||
static final int DOUBLE_TAP_HOME_RECENT_SYSTEM_UI = 1;
|
||||
@@ -1313,16 +1315,26 @@ public class PhoneWindowManager implements WindowManagerPolicy {
|
||||
}
|
||||
}
|
||||
|
||||
private void handleLongPressOnHome(int deviceId) {
|
||||
if (mLongPressOnHomeBehavior != LONG_PRESS_HOME_NOTHING) {
|
||||
mHomeConsumed = true;
|
||||
performHapticFeedbackLw(null, HapticFeedbackConstants.LONG_PRESS, false);
|
||||
private void handleLongPressOnHome(int deviceId, KeyEvent event) {
|
||||
if (mLongPressOnHomeBehavior == LONG_PRESS_HOME_NOTHING) {
|
||||
return;
|
||||
}
|
||||
mHomeConsumed = true;
|
||||
performHapticFeedbackLw(null, HapticFeedbackConstants.LONG_PRESS, false);
|
||||
|
||||
if (mLongPressOnHomeBehavior == LONG_PRESS_HOME_RECENT_SYSTEM_UI) {
|
||||
switch (mLongPressOnHomeBehavior) {
|
||||
case LONG_PRESS_HOME_RECENT_SYSTEM_UI:
|
||||
toggleRecentApps();
|
||||
} else if (mLongPressOnHomeBehavior == LONG_PRESS_HOME_ASSIST) {
|
||||
break;
|
||||
case LONG_PRESS_HOME_ASSIST:
|
||||
launchAssistAction(null, deviceId);
|
||||
}
|
||||
break;
|
||||
case LONG_PRESS_HOME_PICTURE_IN_PICTURE:
|
||||
handlePipKey(event);
|
||||
break;
|
||||
default:
|
||||
Log.w(TAG, "Not defined home long press behavior: " + mLongPressOnHomeBehavior);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1333,6 +1345,13 @@ public class PhoneWindowManager implements WindowManagerPolicy {
|
||||
}
|
||||
}
|
||||
|
||||
private void handlePipKey(KeyEvent event) {
|
||||
if (DEBUG_INPUT) Log.d(TAG, "handlePipKey event=" + event);
|
||||
Intent intent = new Intent(Intent.ACTION_PICTURE_IN_PICTURE_BUTTON);
|
||||
intent.putExtra(Intent.EXTRA_KEY_EVENT, event);
|
||||
mContext.sendBroadcastAsUser(intent, UserHandle.ALL);
|
||||
}
|
||||
|
||||
private final Runnable mHomeDoubleTapTimeoutRunnable = new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
@@ -1625,7 +1644,7 @@ public class PhoneWindowManager implements WindowManagerPolicy {
|
||||
mLongPressOnHomeBehavior = mContext.getResources().getInteger(
|
||||
com.android.internal.R.integer.config_longPressOnHomeBehavior);
|
||||
if (mLongPressOnHomeBehavior < LONG_PRESS_HOME_NOTHING ||
|
||||
mLongPressOnHomeBehavior > LONG_PRESS_HOME_ASSIST) {
|
||||
mLongPressOnHomeBehavior > LAST_LONG_PRESS_HOME_BEHAVIOR) {
|
||||
mLongPressOnHomeBehavior = LONG_PRESS_HOME_NOTHING;
|
||||
}
|
||||
|
||||
@@ -2851,7 +2870,7 @@ public class PhoneWindowManager implements WindowManagerPolicy {
|
||||
}
|
||||
} else if ((event.getFlags() & KeyEvent.FLAG_LONG_PRESS) != 0) {
|
||||
if (!keyguardOn) {
|
||||
handleLongPressOnHome(event.getDeviceId());
|
||||
handleLongPressOnHome(event.getDeviceId(), event);
|
||||
}
|
||||
}
|
||||
return -1;
|
||||
|
||||
Reference in New Issue
Block a user