Merge changes Iebd8d368,Ibdf24604 into rvc-dev
* changes: Expand logging in PipManager Log debug messages in PipMenuActivity
This commit is contained in:
committed by
Android (Google) Code Review
commit
67e6a453f7
@@ -334,6 +334,8 @@ public class PipManager implements BasePipManager, PipTaskOrganizer.PipTransitio
|
|||||||
* Shows the 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.
|
||||||
*/
|
*/
|
||||||
public void showPictureInPictureMenu() {
|
public void showPictureInPictureMenu() {
|
||||||
|
if (DEBUG) Log.d(TAG, "showPictureInPictureMenu(), current state=" + getStateDescription());
|
||||||
|
|
||||||
if (getState() == STATE_PIP) {
|
if (getState() == STATE_PIP) {
|
||||||
resizePinnedStack(STATE_PIP_MENU);
|
resizePinnedStack(STATE_PIP_MENU);
|
||||||
}
|
}
|
||||||
@@ -343,10 +345,18 @@ public class PipManager implements BasePipManager, PipTaskOrganizer.PipTransitio
|
|||||||
* Closes PIP (PIPed activity and PIP system UI).
|
* Closes PIP (PIPed activity and PIP system UI).
|
||||||
*/
|
*/
|
||||||
public void closePip() {
|
public void closePip() {
|
||||||
|
if (DEBUG) Log.d(TAG, "closePip(), current state=" + getStateDescription());
|
||||||
|
|
||||||
closePipInternal(true);
|
closePipInternal(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void closePipInternal(boolean removePipStack) {
|
private void closePipInternal(boolean removePipStack) {
|
||||||
|
if (DEBUG) {
|
||||||
|
Log.d(TAG,
|
||||||
|
"closePipInternal() removePipStack=" + removePipStack + ", current state="
|
||||||
|
+ getStateDescription());
|
||||||
|
}
|
||||||
|
|
||||||
mState = STATE_NO_PIP;
|
mState = STATE_NO_PIP;
|
||||||
mPipTaskId = TASK_ID_NO_PIP;
|
mPipTaskId = TASK_ID_NO_PIP;
|
||||||
mPipMediaController = null;
|
mPipMediaController = null;
|
||||||
@@ -371,6 +381,8 @@ public class PipManager implements BasePipManager, PipTaskOrganizer.PipTransitio
|
|||||||
* Moves the PIPed activity to the fullscreen and closes PIP system UI.
|
* Moves the PIPed activity to the fullscreen and closes PIP system UI.
|
||||||
*/
|
*/
|
||||||
void movePipToFullscreen() {
|
void movePipToFullscreen() {
|
||||||
|
if (DEBUG) Log.d(TAG, "movePipToFullscreen(), current state=" + getStateDescription());
|
||||||
|
|
||||||
mPipTaskId = TASK_ID_NO_PIP;
|
mPipTaskId = TASK_ID_NO_PIP;
|
||||||
for (int i = mListeners.size() - 1; i >= 0; --i) {
|
for (int i = mListeners.size() - 1; i >= 0; --i) {
|
||||||
mListeners.get(i).onMoveToFullscreen();
|
mListeners.get(i).onMoveToFullscreen();
|
||||||
@@ -386,6 +398,7 @@ public class PipManager implements BasePipManager, PipTaskOrganizer.PipTransitio
|
|||||||
public void suspendPipResizing(int reason) {
|
public void suspendPipResizing(int reason) {
|
||||||
if (DEBUG) Log.d(TAG,
|
if (DEBUG) Log.d(TAG,
|
||||||
"suspendPipResizing() reason=" + reason + " callers=" + Debug.getCallers(2));
|
"suspendPipResizing() reason=" + reason + " callers=" + Debug.getCallers(2));
|
||||||
|
|
||||||
mSuspendPipResizingReason |= reason;
|
mSuspendPipResizingReason |= reason;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -408,7 +421,11 @@ public class PipManager implements BasePipManager, PipTaskOrganizer.PipTransitio
|
|||||||
* @param state In Pip state also used to determine the new size for the Pip.
|
* @param state In Pip state also used to determine the new size for the Pip.
|
||||||
*/
|
*/
|
||||||
void resizePinnedStack(int state) {
|
void resizePinnedStack(int state) {
|
||||||
if (DEBUG) Log.d(TAG, "resizePinnedStack() state=" + state, new Exception());
|
if (DEBUG) {
|
||||||
|
Log.d(TAG, "resizePinnedStack() state=" + stateToName(state) + ", current state="
|
||||||
|
+ getStateDescription(), new Exception());
|
||||||
|
}
|
||||||
|
|
||||||
boolean wasStateNoPip = (mState == STATE_NO_PIP);
|
boolean wasStateNoPip = (mState == STATE_NO_PIP);
|
||||||
for (int i = mListeners.size() - 1; i >= 0; --i) {
|
for (int i = mListeners.size() - 1; i >= 0; --i) {
|
||||||
mListeners.get(i).onPipResizeAboutToStart();
|
mListeners.get(i).onPipResizeAboutToStart();
|
||||||
@@ -418,7 +435,7 @@ public class PipManager implements BasePipManager, PipTaskOrganizer.PipTransitio
|
|||||||
if (DEBUG) Log.d(TAG, "resizePinnedStack() deferring"
|
if (DEBUG) Log.d(TAG, "resizePinnedStack() deferring"
|
||||||
+ " mSuspendPipResizingReason=" + mSuspendPipResizingReason
|
+ " mSuspendPipResizingReason=" + mSuspendPipResizingReason
|
||||||
+ " mResumeResizePinnedStackRunnableState="
|
+ " mResumeResizePinnedStackRunnableState="
|
||||||
+ mResumeResizePinnedStackRunnableState);
|
+ stateToName(mResumeResizePinnedStackRunnableState));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
mState = state;
|
mState = state;
|
||||||
@@ -458,7 +475,8 @@ public class PipManager implements BasePipManager, PipTaskOrganizer.PipTransitio
|
|||||||
* stack to the centered PIP bound {@link R.config_centeredPictureInPictureBounds}.
|
* stack to the centered PIP bound {@link R.config_centeredPictureInPictureBounds}.
|
||||||
*/
|
*/
|
||||||
private void showPipMenu() {
|
private void showPipMenu() {
|
||||||
if (DEBUG) Log.d(TAG, "showPipMenu()");
|
if (DEBUG) Log.d(TAG, "showPipMenu(), current state=" + getStateDescription());
|
||||||
|
|
||||||
mState = STATE_PIP_MENU;
|
mState = STATE_PIP_MENU;
|
||||||
for (int i = mListeners.size() - 1; i >= 0; --i) {
|
for (int i = mListeners.size() - 1; i >= 0; --i) {
|
||||||
mListeners.get(i).onShowPipMenu();
|
mListeners.get(i).onShowPipMenu();
|
||||||
@@ -712,6 +730,7 @@ public class PipManager implements BasePipManager, PipTaskOrganizer.PipTransitio
|
|||||||
|
|
||||||
private void onPipTransitionFinishedOrCanceled() {
|
private void onPipTransitionFinishedOrCanceled() {
|
||||||
if (DEBUG) Log.d(TAG, "onPipTransitionFinishedOrCanceled()");
|
if (DEBUG) Log.d(TAG, "onPipTransitionFinishedOrCanceled()");
|
||||||
|
|
||||||
if (getState() == STATE_PIP_MENU) {
|
if (getState() == STATE_PIP_MENU) {
|
||||||
showPipMenu();
|
showPipMenu();
|
||||||
}
|
}
|
||||||
@@ -753,4 +772,28 @@ public class PipManager implements BasePipManager, PipTaskOrganizer.PipTransitio
|
|||||||
WindowManagerWrapper.getInstance().setPipVisibility(visible);
|
WindowManagerWrapper.getInstance().setPipVisibility(visible);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private String getStateDescription() {
|
||||||
|
if (mSuspendPipResizingReason == 0) {
|
||||||
|
return stateToName(mState);
|
||||||
|
}
|
||||||
|
return stateToName(mResumeResizePinnedStackRunnableState) + " (while " + stateToName(mState)
|
||||||
|
+ " is suspended)";
|
||||||
|
}
|
||||||
|
|
||||||
|
private static String stateToName(int state) {
|
||||||
|
switch (state) {
|
||||||
|
case STATE_NO_PIP:
|
||||||
|
return "NO_PIP";
|
||||||
|
|
||||||
|
case STATE_PIP:
|
||||||
|
return "PIP";
|
||||||
|
|
||||||
|
case STATE_PIP_MENU:
|
||||||
|
return "PIP_MENU";
|
||||||
|
|
||||||
|
default:
|
||||||
|
return "UNKNOWN(" + state + ")";
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -22,6 +22,7 @@ import android.app.Activity;
|
|||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.content.pm.ParceledListSlice;
|
import android.content.pm.ParceledListSlice;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
|
import android.util.Log;
|
||||||
|
|
||||||
import com.android.systemui.R;
|
import com.android.systemui.R;
|
||||||
import com.android.systemui.pip.tv.dagger.TvPipComponent;
|
import com.android.systemui.pip.tv.dagger.TvPipComponent;
|
||||||
@@ -34,6 +35,7 @@ import javax.inject.Inject;
|
|||||||
* Activity to show the PIP menu to control PIP.
|
* Activity to show the PIP menu to control PIP.
|
||||||
*/
|
*/
|
||||||
public class PipMenuActivity extends Activity implements PipManager.Listener {
|
public class PipMenuActivity extends Activity implements PipManager.Listener {
|
||||||
|
private static final boolean DEBUG = false;
|
||||||
private static final String TAG = "PipMenuActivity";
|
private static final String TAG = "PipMenuActivity";
|
||||||
|
|
||||||
static final String EXTRA_CUSTOM_ACTIONS = "custom_actions";
|
static final String EXTRA_CUSTOM_ACTIONS = "custom_actions";
|
||||||
@@ -47,7 +49,6 @@ public class PipMenuActivity extends Activity implements PipManager.Listener {
|
|||||||
private boolean mRestorePipSizeWhenClose;
|
private boolean mRestorePipSizeWhenClose;
|
||||||
private PipControlsViewController mPipControlsViewController;
|
private PipControlsViewController mPipControlsViewController;
|
||||||
|
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
public PipMenuActivity(TvPipComponent.Builder pipComponentBuilder, PipManager pipManager) {
|
public PipMenuActivity(TvPipComponent.Builder pipComponentBuilder, PipManager pipManager) {
|
||||||
super();
|
super();
|
||||||
@@ -57,6 +58,8 @@ public class PipMenuActivity extends Activity implements PipManager.Listener {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onCreate(Bundle bundle) {
|
protected void onCreate(Bundle bundle) {
|
||||||
|
if (DEBUG) Log.d(TAG, "onCreate()");
|
||||||
|
|
||||||
super.onCreate(bundle);
|
super.onCreate(bundle);
|
||||||
if (!mPipManager.isPipShown()) {
|
if (!mPipManager.isPipShown()) {
|
||||||
finish();
|
finish();
|
||||||
@@ -81,13 +84,18 @@ public class PipMenuActivity extends Activity implements PipManager.Listener {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onNewIntent(Intent intent) {
|
protected void onNewIntent(Intent intent) {
|
||||||
|
if (DEBUG) Log.d(TAG, "onNewIntent(), intent=" + intent);
|
||||||
super.onNewIntent(intent);
|
super.onNewIntent(intent);
|
||||||
|
|
||||||
onPipMenuActionsChanged(getIntent().getParcelableExtra(EXTRA_CUSTOM_ACTIONS));
|
onPipMenuActionsChanged(getIntent().getParcelableExtra(EXTRA_CUSTOM_ACTIONS));
|
||||||
}
|
}
|
||||||
|
|
||||||
private void restorePipAndFinish() {
|
private void restorePipAndFinish() {
|
||||||
|
if (DEBUG) Log.d(TAG, "restorePipAndFinish()");
|
||||||
|
|
||||||
if (mRestorePipSizeWhenClose) {
|
if (mRestorePipSizeWhenClose) {
|
||||||
|
if (DEBUG) Log.d(TAG, " > restoring to the default position");
|
||||||
|
|
||||||
// When PIP menu activity is closed, restore to the default position.
|
// When PIP menu activity is closed, restore to the default position.
|
||||||
mPipManager.resizePinnedStack(PipManager.STATE_PIP);
|
mPipManager.resizePinnedStack(PipManager.STATE_PIP);
|
||||||
}
|
}
|
||||||
@@ -96,12 +104,16 @@ public class PipMenuActivity extends Activity implements PipManager.Listener {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onResume() {
|
public void onResume() {
|
||||||
|
if (DEBUG) Log.d(TAG, "onResume()");
|
||||||
|
|
||||||
super.onResume();
|
super.onResume();
|
||||||
mFadeInAnimation.start();
|
mFadeInAnimation.start();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onPause() {
|
public void onPause() {
|
||||||
|
if (DEBUG) Log.d(TAG, "onPause()");
|
||||||
|
|
||||||
super.onPause();
|
super.onPause();
|
||||||
mFadeOutAnimation.start();
|
mFadeOutAnimation.start();
|
||||||
restorePipAndFinish();
|
restorePipAndFinish();
|
||||||
@@ -109,6 +121,8 @@ public class PipMenuActivity extends Activity implements PipManager.Listener {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onDestroy() {
|
protected void onDestroy() {
|
||||||
|
if (DEBUG) Log.d(TAG, "onDestroy()");
|
||||||
|
|
||||||
super.onDestroy();
|
super.onDestroy();
|
||||||
mPipManager.removeListener(this);
|
mPipManager.removeListener(this);
|
||||||
mPipManager.resumePipResizing(
|
mPipManager.resumePipResizing(
|
||||||
@@ -117,29 +131,41 @@ public class PipMenuActivity extends Activity implements PipManager.Listener {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onBackPressed() {
|
public void onBackPressed() {
|
||||||
|
if (DEBUG) Log.d(TAG, "onBackPressed()");
|
||||||
|
|
||||||
restorePipAndFinish();
|
restorePipAndFinish();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onPipEntered() { }
|
public void onPipEntered() {
|
||||||
|
if (DEBUG) Log.d(TAG, "onPipEntered()");
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onPipActivityClosed() {
|
public void onPipActivityClosed() {
|
||||||
|
if (DEBUG) Log.d(TAG, "onPipActivityClosed()");
|
||||||
|
|
||||||
finish();
|
finish();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onPipMenuActionsChanged(ParceledListSlice actions) {
|
public void onPipMenuActionsChanged(ParceledListSlice actions) {
|
||||||
|
if (DEBUG) Log.d(TAG, "onPipMenuActionsChanged()");
|
||||||
|
|
||||||
boolean hasCustomActions = actions != null && !actions.getList().isEmpty();
|
boolean hasCustomActions = actions != null && !actions.getList().isEmpty();
|
||||||
mPipControlsViewController.setActions(
|
mPipControlsViewController.setActions(
|
||||||
hasCustomActions ? actions.getList() : Collections.EMPTY_LIST);
|
hasCustomActions ? actions.getList() : Collections.EMPTY_LIST);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onShowPipMenu() { }
|
public void onShowPipMenu() {
|
||||||
|
if (DEBUG) Log.d(TAG, "onShowPipMenu()");
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onMoveToFullscreen() {
|
public void onMoveToFullscreen() {
|
||||||
|
if (DEBUG) Log.d(TAG, "onMoveToFullscreen()");
|
||||||
|
|
||||||
// Moving PIP to fullscreen is implemented by resizing PINNED_STACK with null bounds.
|
// Moving PIP to fullscreen is implemented by resizing PINNED_STACK with null bounds.
|
||||||
// This conflicts with restoring PIP position, so disable it.
|
// This conflicts with restoring PIP position, so disable it.
|
||||||
mRestorePipSizeWhenClose = false;
|
mRestorePipSizeWhenClose = false;
|
||||||
@@ -148,8 +174,17 @@ public class PipMenuActivity extends Activity implements PipManager.Listener {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onPipResizeAboutToStart() {
|
public void onPipResizeAboutToStart() {
|
||||||
|
if (DEBUG) Log.d(TAG, "onPipResizeAboutToStart()");
|
||||||
|
|
||||||
finish();
|
finish();
|
||||||
mPipManager.suspendPipResizing(
|
mPipManager.suspendPipResizing(
|
||||||
PipManager.SUSPEND_PIP_RESIZE_REASON_WAITING_FOR_MENU_ACTIVITY_FINISH);
|
PipManager.SUSPEND_PIP_RESIZE_REASON_WAITING_FOR_MENU_ACTIVITY_FINISH);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void finish() {
|
||||||
|
if (DEBUG) Log.d(TAG, "finish()", new RuntimeException());
|
||||||
|
|
||||||
|
super.finish();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user