PIP: Send KEYCODE_WINDOW to app first if PIP isn't exist
Bug: 27954955 Change-Id: I517e378d5c1672ac0eb87bdf4375b7d733276e58
This commit is contained in:
@@ -3068,6 +3068,13 @@ public class View implements Drawable.Callback, KeyEvent.Callback,
|
||||
*/
|
||||
public static final int RECENT_APPS_VISIBLE = 0x00004000;
|
||||
|
||||
/**
|
||||
* @hide
|
||||
*
|
||||
* Whether the TV's picture-in-picture is visible or not.
|
||||
*/
|
||||
public static final int TV_PICTURE_IN_PICTURE_VISIBLE = 0x00010000;
|
||||
|
||||
/**
|
||||
* @hide
|
||||
*
|
||||
|
||||
@@ -24,6 +24,7 @@ import android.annotation.NonNull;
|
||||
import android.annotation.Nullable;
|
||||
import android.annotation.StyleRes;
|
||||
import android.annotation.SystemApi;
|
||||
import android.app.ActivityManagerNative;
|
||||
import android.content.Context;
|
||||
import android.content.res.Configuration;
|
||||
import android.content.res.Resources;
|
||||
@@ -1255,6 +1256,18 @@ public abstract class Window {
|
||||
return getDecorView().findViewById(id);
|
||||
}
|
||||
|
||||
/**
|
||||
* Puts the activity in picture-in-picture mode.
|
||||
* @see android.R.attr#supportsPictureInPicture
|
||||
* @hide
|
||||
*/
|
||||
protected void enterPictureInPictureMode() {
|
||||
try {
|
||||
ActivityManagerNative.getDefault().enterPictureInPictureMode(mAppToken);
|
||||
} catch (IllegalArgumentException|RemoteException e) {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Convenience for
|
||||
* {@link #setContentView(View, android.view.ViewGroup.LayoutParams)}
|
||||
|
||||
@@ -2002,6 +2002,13 @@ public class PhoneWindow extends Window implements MenuBuilder.Callback {
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
case KeyEvent.KEYCODE_WINDOW: {
|
||||
if (!event.isCanceled()) {
|
||||
enterPictureInPictureMode();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
|
||||
@@ -105,14 +105,9 @@ oneway interface IStatusBar
|
||||
void onCameraLaunchGestureDetected(int source);
|
||||
|
||||
/**
|
||||
* Request picture-in-picture.
|
||||
*
|
||||
* <p>
|
||||
* This is called when an user presses picture-in-picture key or equivalent.
|
||||
* TV device may start picture-in-picture from foreground activity if there's none.
|
||||
* Picture-in-picture overlay menu will be shown instead otherwise.
|
||||
* Shows the TV's picture-in-picture menu if an activity is in picture-in-picture mode.
|
||||
*/
|
||||
void requestTvPictureInPicture();
|
||||
void showTvPictureInPictureMenu();
|
||||
|
||||
void addQsTile(in ComponentName tile);
|
||||
void remQsTile(in ComponentName tile);
|
||||
|
||||
Reference in New Issue
Block a user