PIP: Send KEYCODE_WINDOW to app first if PIP isn't exist

Bug: 27954955
Change-Id: I517e378d5c1672ac0eb87bdf4375b7d733276e58
This commit is contained in:
Jaewan Kim
2016-04-20 21:17:58 +09:00
parent af8be42b9f
commit f0fd218382
11 changed files with 96 additions and 62 deletions

View File

@@ -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
*

View File

@@ -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)}

View File

@@ -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;

View File

@@ -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);