Merge "Ensure we show the PiP menu in response to KEYCODE_WINDOW." into oc-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
2af994ec03
@@ -271,7 +271,7 @@ interface IWindowManager
|
||||
/**
|
||||
* Called by System UI to notify of changes to the visibility of PIP.
|
||||
*/
|
||||
oneway void setTvPipVisibility(boolean visible);
|
||||
oneway void setPipVisibility(boolean visible);
|
||||
|
||||
/**
|
||||
* Device has a software navigation bar (separate from the status bar).
|
||||
|
||||
@@ -1517,7 +1517,7 @@ public interface WindowManagerPolicy {
|
||||
/**
|
||||
* Called by System UI to notify of changes to the visibility of PIP.
|
||||
*/
|
||||
public void setTvPipVisibilityLw(boolean visible);
|
||||
void setPipVisibilityLw(boolean visible);
|
||||
|
||||
/**
|
||||
* Specifies whether there is an on-screen navigation bar separate from the status bar.
|
||||
|
||||
@@ -102,9 +102,9 @@ oneway interface IStatusBar
|
||||
void onCameraLaunchGestureDetected(int source);
|
||||
|
||||
/**
|
||||
* Shows the TV's picture-in-picture menu if an activity is in picture-in-picture mode.
|
||||
* Shows the picture-in-picture menu if an activity is in picture-in-picture mode.
|
||||
*/
|
||||
void showTvPictureInPictureMenu();
|
||||
void showPictureInPictureMenu();
|
||||
|
||||
/**
|
||||
* Shows the global actions menu.
|
||||
|
||||
@@ -22,6 +22,7 @@ import java.io.PrintWriter;
|
||||
|
||||
public interface BasePipManager {
|
||||
void initialize(Context context);
|
||||
void showPictureInPictureMenu();
|
||||
void onConfigurationChanged();
|
||||
void dump(PrintWriter pw);
|
||||
}
|
||||
|
||||
@@ -24,6 +24,7 @@ import android.content.res.Configuration;
|
||||
|
||||
import com.android.systemui.SystemUI;
|
||||
import com.android.systemui.recents.misc.SystemServicesProxy;
|
||||
import com.android.systemui.statusbar.CommandQueue;
|
||||
|
||||
import java.io.FileDescriptor;
|
||||
import java.io.PrintWriter;
|
||||
@@ -31,7 +32,7 @@ import java.io.PrintWriter;
|
||||
/**
|
||||
* Controls the picture-in-picture window.
|
||||
*/
|
||||
public class PipUI extends SystemUI {
|
||||
public class PipUI extends SystemUI implements CommandQueue.Callbacks {
|
||||
|
||||
private BasePipManager mPipManager;
|
||||
|
||||
@@ -55,6 +56,13 @@ public class PipUI extends SystemUI {
|
||||
? com.android.systemui.pip.tv.PipManager.getInstance()
|
||||
: com.android.systemui.pip.phone.PipManager.getInstance();
|
||||
mPipManager.initialize(mContext);
|
||||
|
||||
getComponent(CommandQueue.class).addCallbacks(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void showPictureInPictureMenu() {
|
||||
mPipManager.showPictureInPictureMenu();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -35,6 +35,7 @@ import android.view.WindowManagerGlobal;
|
||||
import com.android.systemui.pip.BasePipManager;
|
||||
import com.android.systemui.recents.misc.SystemServicesProxy;
|
||||
import com.android.systemui.recents.misc.SystemServicesProxy.TaskStackListener;
|
||||
import com.android.systemui.statusbar.CommandQueue;
|
||||
|
||||
import java.io.PrintWriter;
|
||||
|
||||
@@ -73,6 +74,8 @@ public class PipManager implements BasePipManager {
|
||||
mMediaController.onActivityPinned();
|
||||
mMenuController.onActivityPinned();
|
||||
mNotificationController.onActivityPinned(packageName);
|
||||
|
||||
SystemServicesProxy.getInstance(mContext).setPipVisibility(true);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -81,7 +84,11 @@ public class PipManager implements BasePipManager {
|
||||
return;
|
||||
}
|
||||
|
||||
mNotificationController.onActivityUnpinned();
|
||||
ComponentName topPipActivity = PipUtils.getTopPinnedActivity(mContext,
|
||||
mActivityManager);
|
||||
mNotificationController.onActivityUnpinned(topPipActivity);
|
||||
|
||||
SystemServicesProxy.getInstance(mContext).setPipVisibility(topPipActivity != null);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -94,6 +101,7 @@ public class PipManager implements BasePipManager {
|
||||
public void onPinnedStackAnimationEnded() {
|
||||
// Re-enable touches after the animation completes
|
||||
mTouchHandler.setTouchEnabled(true);
|
||||
mTouchHandler.onPinnedStackAnimationEnded();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -183,6 +191,13 @@ public class PipManager implements BasePipManager {
|
||||
mTouchHandler.onConfigurationChanged();
|
||||
}
|
||||
|
||||
/**
|
||||
* Sent from KEYCODE_WINDOW handler in PhoneWindowManager, to request the menu to be shown.
|
||||
*/
|
||||
public void showPictureInPictureMenu() {
|
||||
mTouchHandler.showPictureInPictureMenu();
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets an instance of {@link PipManager}.
|
||||
*/
|
||||
|
||||
@@ -110,11 +110,10 @@ public class PipNotificationController {
|
||||
registerAppOpsListener(packageName);
|
||||
}
|
||||
|
||||
public void onActivityUnpinned() {
|
||||
public void onActivityUnpinned(ComponentName topPipActivity) {
|
||||
// Unregister for changes to the previously PiP'ed package
|
||||
unregisterAppOpsListener();
|
||||
|
||||
ComponentName topPipActivity = PipUtils.getTopPinnedActivity(mContext, mActivityManager);
|
||||
if (topPipActivity != null) {
|
||||
onActivityPinned(topPipActivity.getPackageName());
|
||||
} else {
|
||||
|
||||
@@ -188,6 +188,14 @@ public class PipTouchHandler implements TunerService.Tunable {
|
||||
mTouchState.setAllowTouches(enabled);
|
||||
}
|
||||
|
||||
public void showPictureInPictureMenu() {
|
||||
// Only show the menu if the user isn't currently interacting with the PiP
|
||||
if (!mTouchState.isUserInteracting()) {
|
||||
mMenuController.showMenu(mMotionHelper.getBounds(), mMovementBounds,
|
||||
false /* allowMenuTimeout */);
|
||||
}
|
||||
}
|
||||
|
||||
public void onActivityPinned() {
|
||||
// Reset some states once we are pinned
|
||||
if (mIsMenuVisible) {
|
||||
@@ -199,6 +207,11 @@ public class PipTouchHandler implements TunerService.Tunable {
|
||||
mDismissViewController.destroyDismissTarget();
|
||||
}
|
||||
|
||||
public void onPinnedStackAnimationEnded() {
|
||||
// Always synchronize the motion helper bounds once PiP animations finish
|
||||
mMotionHelper.synchronizePinnedStackBounds();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onTuningChanged(String key, String newValue) {
|
||||
if (newValue == null) {
|
||||
|
||||
@@ -35,11 +35,9 @@ import android.os.Debug;
|
||||
import android.os.Handler;
|
||||
import android.os.RemoteException;
|
||||
import android.os.SystemProperties;
|
||||
import android.os.UserHandle;
|
||||
import android.text.TextUtils;
|
||||
import android.util.Log;
|
||||
import android.util.Pair;
|
||||
import android.view.Display;
|
||||
import android.view.IPinnedStackController;
|
||||
import android.view.IPinnedStackListener;
|
||||
import android.view.IWindowManager;
|
||||
@@ -281,7 +279,7 @@ public class PipManager implements BasePipManager {
|
||||
/**
|
||||
* Shows the picture-in-picture menu if an activity is in picture-in-picture mode.
|
||||
*/
|
||||
public void showTvPictureInPictureMenu() {
|
||||
public void showPictureInPictureMenu() {
|
||||
if (mState == STATE_PIP_OVERLAY) {
|
||||
resizePinnedStack(STATE_PIP_MENU);
|
||||
}
|
||||
@@ -721,7 +719,7 @@ public class PipManager implements BasePipManager {
|
||||
}
|
||||
|
||||
private void updatePipVisibility(final boolean visible) {
|
||||
SystemServicesProxy.getInstance(mContext).setTvPipVisibility(visible);
|
||||
SystemServicesProxy.getInstance(mContext).setPipVisibility(visible);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -1215,9 +1215,9 @@ public class SystemServicesProxy {
|
||||
/**
|
||||
* Updates the visibility of the picture-in-picture.
|
||||
*/
|
||||
public void setTvPipVisibility(boolean visible) {
|
||||
public void setPipVisibility(boolean visible) {
|
||||
try {
|
||||
mIwm.setTvPipVisibility(visible);
|
||||
mIwm.setPipVisibility(visible);
|
||||
} catch (RemoteException e) {
|
||||
Log.e(TAG, "Unable to reach window manager", e);
|
||||
}
|
||||
|
||||
@@ -70,7 +70,7 @@ public class CommandQueue extends IStatusBar.Stub {
|
||||
private static final int MSG_START_ASSIST = 23 << MSG_SHIFT;
|
||||
private static final int MSG_CAMERA_LAUNCH_GESTURE = 24 << MSG_SHIFT;
|
||||
private static final int MSG_TOGGLE_KEYBOARD_SHORTCUTS = 25 << MSG_SHIFT;
|
||||
private static final int MSG_SHOW_TV_PICTURE_IN_PICTURE_MENU = 26 << MSG_SHIFT;
|
||||
private static final int MSG_SHOW_PICTURE_IN_PICTURE_MENU = 26 << MSG_SHIFT;
|
||||
private static final int MSG_ADD_QS_TILE = 27 << MSG_SHIFT;
|
||||
private static final int MSG_REMOVE_QS_TILE = 28 << MSG_SHIFT;
|
||||
private static final int MSG_CLICK_QS_TILE = 29 << MSG_SHIFT;
|
||||
@@ -128,7 +128,7 @@ public class CommandQueue extends IStatusBar.Stub {
|
||||
default void showAssistDisclosure() { }
|
||||
default void startAssist(Bundle args) { }
|
||||
default void onCameraLaunchGestureDetected(int source) { }
|
||||
default void showTvPictureInPictureMenu() { }
|
||||
default void showPictureInPictureMenu() { }
|
||||
|
||||
default void addQsTile(ComponentName tile) { }
|
||||
default void remQsTile(ComponentName tile) { }
|
||||
@@ -307,10 +307,10 @@ public class CommandQueue extends IStatusBar.Stub {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void showTvPictureInPictureMenu() {
|
||||
public void showPictureInPictureMenu() {
|
||||
synchronized (mLock) {
|
||||
mHandler.removeMessages(MSG_SHOW_TV_PICTURE_IN_PICTURE_MENU);
|
||||
mHandler.obtainMessage(MSG_SHOW_TV_PICTURE_IN_PICTURE_MENU).sendToTarget();
|
||||
mHandler.removeMessages(MSG_SHOW_PICTURE_IN_PICTURE_MENU);
|
||||
mHandler.obtainMessage(MSG_SHOW_PICTURE_IN_PICTURE_MENU).sendToTarget();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -570,9 +570,9 @@ public class CommandQueue extends IStatusBar.Stub {
|
||||
mCallbacks.get(i).onCameraLaunchGestureDetected(msg.arg1);
|
||||
}
|
||||
break;
|
||||
case MSG_SHOW_TV_PICTURE_IN_PICTURE_MENU:
|
||||
case MSG_SHOW_PICTURE_IN_PICTURE_MENU:
|
||||
for (int i = 0; i < mCallbacks.size(); i++) {
|
||||
mCallbacks.get(i).showTvPictureInPictureMenu();
|
||||
mCallbacks.get(i).showPictureInPictureMenu();
|
||||
}
|
||||
break;
|
||||
case MSG_ADD_QS_TILE:
|
||||
|
||||
@@ -138,6 +138,7 @@ import com.android.systemui.doze.DozeLog;
|
||||
import com.android.systemui.fragments.FragmentHostManager;
|
||||
import com.android.systemui.fragments.PluginFragmentListener;
|
||||
import com.android.systemui.keyguard.KeyguardViewMediator;
|
||||
import com.android.systemui.pip.phone.PipManager;
|
||||
import com.android.systemui.plugins.qs.QS;
|
||||
import com.android.systemui.plugins.ActivityStarter;
|
||||
import com.android.systemui.plugins.statusbar.NotificationSwipeActionHelper.SnoozeOption;
|
||||
@@ -4947,11 +4948,6 @@ public class StatusBar extends SystemUI implements DemoMode,
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void showTvPictureInPictureMenu() {
|
||||
// no-op.
|
||||
}
|
||||
|
||||
public void notifyFpAuthModeChanged() {
|
||||
updateDozing();
|
||||
}
|
||||
|
||||
@@ -16,13 +16,11 @@
|
||||
|
||||
package com.android.systemui.statusbar.tv;
|
||||
|
||||
import android.content.ComponentName;
|
||||
import android.content.Context;
|
||||
import android.graphics.Rect;
|
||||
import android.os.IBinder;
|
||||
import android.os.RemoteException;
|
||||
import android.os.ServiceManager;
|
||||
import android.service.notification.NotificationListenerService.RankingMap;
|
||||
|
||||
import com.android.internal.statusbar.IStatusBarService;
|
||||
import com.android.internal.statusbar.StatusBarIcon;
|
||||
@@ -41,11 +39,6 @@ public class TvStatusBar extends SystemUI implements Callbacks {
|
||||
|
||||
private IStatusBarService mBarService;
|
||||
|
||||
@Override
|
||||
public void showTvPictureInPictureMenu() {
|
||||
PipManager.getInstance().showTvPictureInPictureMenu();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void start() {
|
||||
putComponent(TvStatusBar.class, this);
|
||||
|
||||
@@ -229,10 +229,10 @@ public class CommandQueueTest extends SysuiTestCase {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testShowTvPipMenu() {
|
||||
mCommandQueue.showTvPictureInPictureMenu();
|
||||
public void testShowPipMenu() {
|
||||
mCommandQueue.showPictureInPictureMenu();
|
||||
waitForIdleSync();
|
||||
verify(mCallbacks).showTvPictureInPictureMenu();
|
||||
verify(mCallbacks).showPictureInPictureMenu();
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@@ -508,7 +508,7 @@ public class PhoneWindowManager implements WindowManagerPolicy {
|
||||
volatile boolean mCameraGestureTriggeredDuringGoingToSleep;
|
||||
volatile boolean mGoingToSleep;
|
||||
volatile boolean mRecentsVisible;
|
||||
volatile boolean mTvPictureInPictureVisible;
|
||||
volatile boolean mPictureInPictureVisible;
|
||||
// Written by vr manager thread, only read in this class
|
||||
volatile boolean mPersistentVrModeEnabled;
|
||||
|
||||
@@ -813,7 +813,7 @@ public class PhoneWindowManager implements WindowManagerPolicy {
|
||||
private static final int MSG_POWER_LONG_PRESS = 14;
|
||||
private static final int MSG_UPDATE_DREAMING_SLEEP_TOKEN = 15;
|
||||
private static final int MSG_REQUEST_TRANSIENT_BARS = 16;
|
||||
private static final int MSG_SHOW_TV_PICTURE_IN_PICTURE_MENU = 17;
|
||||
private static final int MSG_SHOW_PICTURE_IN_PICTURE_MENU = 17;
|
||||
private static final int MSG_BACK_LONG_PRESS = 18;
|
||||
private static final int MSG_DISPOSE_INPUT_CONSUMER = 19;
|
||||
private static final int MSG_BACK_DELAYED_PRESS = 20;
|
||||
@@ -880,8 +880,8 @@ public class PhoneWindowManager implements WindowManagerPolicy {
|
||||
requestTransientBars(targetBar);
|
||||
}
|
||||
break;
|
||||
case MSG_SHOW_TV_PICTURE_IN_PICTURE_MENU:
|
||||
showTvPictureInPictureMenuInternal();
|
||||
case MSG_SHOW_PICTURE_IN_PICTURE_MENU:
|
||||
showPictureInPictureMenuInternal();
|
||||
break;
|
||||
case MSG_BACK_LONG_PRESS:
|
||||
backLongPress();
|
||||
@@ -1726,18 +1726,18 @@ public class PhoneWindowManager implements WindowManagerPolicy {
|
||||
}
|
||||
}
|
||||
|
||||
private void showTvPictureInPictureMenu(KeyEvent event) {
|
||||
if (DEBUG_INPUT) Log.d(TAG, "showTvPictureInPictureMenu event=" + event);
|
||||
mHandler.removeMessages(MSG_SHOW_TV_PICTURE_IN_PICTURE_MENU);
|
||||
Message msg = mHandler.obtainMessage(MSG_SHOW_TV_PICTURE_IN_PICTURE_MENU);
|
||||
private void showPictureInPictureMenu(KeyEvent event) {
|
||||
if (DEBUG_INPUT) Log.d(TAG, "showPictureInPictureMenu event=" + event);
|
||||
mHandler.removeMessages(MSG_SHOW_PICTURE_IN_PICTURE_MENU);
|
||||
Message msg = mHandler.obtainMessage(MSG_SHOW_PICTURE_IN_PICTURE_MENU);
|
||||
msg.setAsynchronous(true);
|
||||
msg.sendToTarget();
|
||||
}
|
||||
|
||||
private void showTvPictureInPictureMenuInternal() {
|
||||
private void showPictureInPictureMenuInternal() {
|
||||
StatusBarManagerInternal statusbar = getStatusBarManagerInternal();
|
||||
if (statusbar != null) {
|
||||
statusbar.showTvPictureInPictureMenu();
|
||||
statusbar.showPictureInPictureMenu();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4115,8 +4115,8 @@ public class PhoneWindowManager implements WindowManagerPolicy {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setTvPipVisibilityLw(boolean visible) {
|
||||
mTvPictureInPictureVisible = visible;
|
||||
public void setPipVisibilityLw(boolean visible) {
|
||||
mPictureInPictureVisible = visible;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -6049,13 +6049,12 @@ public class PhoneWindowManager implements WindowManagerPolicy {
|
||||
}
|
||||
case KeyEvent.KEYCODE_WINDOW: {
|
||||
if (mShortPressWindowBehavior == SHORT_PRESS_WINDOW_PICTURE_IN_PICTURE) {
|
||||
if (mTvPictureInPictureVisible) {
|
||||
// Consumes the key only if picture-in-picture is visible
|
||||
// to show picture-in-picture control menu.
|
||||
// This gives a chance to the foreground activity
|
||||
// to customize PIP key behavior.
|
||||
if (mPictureInPictureVisible) {
|
||||
// Consumes the key only if picture-in-picture is visible to show
|
||||
// picture-in-picture control menu. This gives a chance to the foreground
|
||||
// activity to customize PIP key behavior.
|
||||
if (!down) {
|
||||
showTvPictureInPictureMenu(event);
|
||||
showPictureInPictureMenu(event);
|
||||
}
|
||||
result &= ~ACTION_PASS_TO_USER;
|
||||
}
|
||||
|
||||
@@ -38,9 +38,9 @@ public interface StatusBarManagerInternal {
|
||||
void toggleKeyboardShortcutsMenu(int deviceId);
|
||||
|
||||
/**
|
||||
* Show TV picture-in-picture menu.
|
||||
* Show picture-in-picture menu.
|
||||
*/
|
||||
void showTvPictureInPictureMenu();
|
||||
void showPictureInPictureMenu();
|
||||
|
||||
void setWindowState(int window, int state);
|
||||
|
||||
|
||||
@@ -266,10 +266,10 @@ public class StatusBarManagerService extends IStatusBarService.Stub {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void showTvPictureInPictureMenu() {
|
||||
public void showPictureInPictureMenu() {
|
||||
if (mBar != null) {
|
||||
try {
|
||||
mBar.showTvPictureInPictureMenu();
|
||||
mBar.showPictureInPictureMenu();
|
||||
} catch (RemoteException ex) {}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6040,7 +6040,7 @@ public class WindowManagerService extends IWindowManager.Stub
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setTvPipVisibility(boolean visible) {
|
||||
public void setPipVisibility(boolean visible) {
|
||||
if (mContext.checkCallingOrSelfPermission(android.Manifest.permission.STATUS_BAR)
|
||||
!= PackageManager.PERMISSION_GRANTED) {
|
||||
throw new SecurityException("Caller does not hold permission "
|
||||
@@ -6048,7 +6048,7 @@ public class WindowManagerService extends IWindowManager.Stub
|
||||
}
|
||||
|
||||
synchronized (mWindowMap) {
|
||||
mPolicy.setTvPipVisibilityLw(visible);
|
||||
mPolicy.setPipVisibilityLw(visible);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -625,7 +625,7 @@ class TestWindowManagerPolicy implements WindowManagerPolicy {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setTvPipVisibilityLw(boolean visible) {
|
||||
public void setPipVisibilityLw(boolean visible) {
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -376,7 +376,7 @@ public class IWindowManagerImpl implements IWindowManager {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setTvPipVisibility(boolean visible) {
|
||||
public void setPipVisibility(boolean visible) {
|
||||
// TODO Auto-generated method stub
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user