Merge "Update PiP action even if menu is not visible" into sc-dev

This commit is contained in:
Hongwei Wang
2021-04-07 16:56:09 +00:00
committed by Android (Google) Code Review
3 changed files with 17 additions and 24 deletions

View File

@@ -16,13 +16,9 @@
package com.android.wm.shell.pip.phone; package com.android.wm.shell.pip.phone;
import static android.app.WindowConfiguration.ACTIVITY_TYPE_UNDEFINED;
import static android.app.WindowConfiguration.WINDOWING_MODE_PINNED;
import static android.view.WindowManager.SHELL_ROOT_LAYER_PIP; import static android.view.WindowManager.SHELL_ROOT_LAYER_PIP;
import android.annotation.Nullable; import android.annotation.Nullable;
import android.app.ActivityTaskManager;
import android.app.ActivityTaskManager.RootTaskInfo;
import android.app.RemoteAction; import android.app.RemoteAction;
import android.content.Context; import android.content.Context;
import android.content.pm.ParceledListSlice; import android.content.pm.ParceledListSlice;
@@ -43,6 +39,7 @@ import android.view.WindowManagerGlobal;
import com.android.wm.shell.common.ShellExecutor; import com.android.wm.shell.common.ShellExecutor;
import com.android.wm.shell.common.SystemWindows; import com.android.wm.shell.common.SystemWindows;
import com.android.wm.shell.pip.PipBoundsState;
import com.android.wm.shell.pip.PipMediaController; import com.android.wm.shell.pip.PipMediaController;
import com.android.wm.shell.pip.PipMediaController.ActionListener; import com.android.wm.shell.pip.PipMediaController.ActionListener;
import com.android.wm.shell.pip.PipMenuController; import com.android.wm.shell.pip.PipMenuController;
@@ -99,6 +96,7 @@ public class PhonePipMenuController implements PipMenuController {
private final RectF mTmpSourceRectF = new RectF(); private final RectF mTmpSourceRectF = new RectF();
private final RectF mTmpDestinationRectF = new RectF(); private final RectF mTmpDestinationRectF = new RectF();
private final Context mContext; private final Context mContext;
private final PipBoundsState mPipBoundsState;
private final PipMediaController mMediaController; private final PipMediaController mMediaController;
private final ShellExecutor mMainExecutor; private final ShellExecutor mMainExecutor;
private final Handler mMainHandler; private final Handler mMainHandler;
@@ -134,10 +132,11 @@ public class PhonePipMenuController implements PipMenuController {
} }
}; };
public PhonePipMenuController(Context context, PipMediaController mediaController, public PhonePipMenuController(Context context, PipBoundsState pipBoundsState,
SystemWindows systemWindows, ShellExecutor mainExecutor, PipMediaController mediaController, SystemWindows systemWindows,
Handler mainHandler) { ShellExecutor mainExecutor, Handler mainHandler) {
mContext = context; mContext = context;
mPipBoundsState = pipBoundsState;
mMediaController = mediaController; mMediaController = mediaController;
mSystemWindows = systemWindows; mSystemWindows = systemWindows;
mMainExecutor = mainExecutor; mMainExecutor = mainExecutor;
@@ -466,20 +465,11 @@ public class PhonePipMenuController implements PipMenuController {
* Updates the PiP menu with the best set of actions provided. * Updates the PiP menu with the best set of actions provided.
*/ */
private void updateMenuActions() { private void updateMenuActions() {
if (isMenuVisible()) { if (mPipMenuView != null) {
// Fetch the pinned stack bounds final ParceledListSlice<RemoteAction> menuActions = resolveMenuActions();
Rect stackBounds = null; if (menuActions != null) {
try { mPipMenuView.setActions(mPipBoundsState.getBounds(), menuActions.getList());
RootTaskInfo pinnedTaskInfo = ActivityTaskManager.getService().getRootTaskInfo(
WINDOWING_MODE_PINNED, ACTIVITY_TYPE_UNDEFINED);
if (pinnedTaskInfo != null) {
stackBounds = pinnedTaskInfo.bounds;
}
} catch (RemoteException e) {
Log.e(TAG, "Error showing PIP menu", e);
} }
mPipMenuView.setActions(stackBounds, resolveMenuActions().getList());
} }
} }

View File

@@ -374,7 +374,9 @@ public class PipMenuView extends FrameLayout {
void setActions(Rect stackBounds, List<RemoteAction> actions) { void setActions(Rect stackBounds, List<RemoteAction> actions) {
mActions.clear(); mActions.clear();
mActions.addAll(actions); mActions.addAll(actions);
updateActionViews(stackBounds); if (mMenuState == MENU_STATE_FULL) {
updateActionViews(stackBounds);
}
} }
private void updateActionViews(Rect stackBounds) { private void updateActionViews(Rect stackBounds) {

View File

@@ -157,11 +157,12 @@ public class WMShellModule {
@WMSingleton @WMSingleton
@Provides @Provides
static PhonePipMenuController providesPipPhoneMenuController(Context context, static PhonePipMenuController providesPipPhoneMenuController(Context context,
PipMediaController pipMediaController, SystemWindows systemWindows, PipBoundsState pipBoundsState, PipMediaController pipMediaController,
SystemWindows systemWindows,
@ShellMainThread ShellExecutor mainExecutor, @ShellMainThread ShellExecutor mainExecutor,
@ShellMainThread Handler mainHandler) { @ShellMainThread Handler mainHandler) {
return new PhonePipMenuController(context, pipMediaController, systemWindows, return new PhonePipMenuController(context, pipBoundsState, pipMediaController,
mainExecutor, mainHandler); systemWindows, mainExecutor, mainHandler);
} }
@WMSingleton @WMSingleton