Merge "Add additional guards to ensure input consumer is re-registered."
This commit is contained in:
committed by
Android (Google) Code Review
commit
8f7bad2fec
@@ -30,6 +30,9 @@ import android.view.IPinnedStackListener;
|
||||
import android.view.IWindowManager;
|
||||
import android.view.WindowManagerGlobal;
|
||||
|
||||
import com.android.systemui.recents.misc.SystemServicesProxy;
|
||||
import com.android.systemui.recents.misc.SystemServicesProxy.TaskStackListener;
|
||||
|
||||
/**
|
||||
* Manages the picture-in-picture (PIP) UI and states for Phones.
|
||||
*/
|
||||
@@ -48,6 +51,26 @@ public class PipManager {
|
||||
private PipMenuActivityController mMenuController;
|
||||
private PipTouchHandler mTouchHandler;
|
||||
|
||||
/**
|
||||
* Handler for system task stack changes.
|
||||
*/
|
||||
TaskStackListener mTaskStackListener = new TaskStackListener() {
|
||||
@Override
|
||||
public void onActivityPinned() {
|
||||
mTouchHandler.onActivityPinned();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPinnedStackAnimationEnded() {
|
||||
// TODO(winsonc): Disable touch interaction with the PiP until the animation ends
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPinnedActivityRestartAttempt() {
|
||||
// TODO(winsonc): Hide the menu and expand the PiP
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Handler for messages from the PIP controller.
|
||||
*/
|
||||
@@ -102,6 +125,7 @@ public class PipManager {
|
||||
} catch (RemoteException e) {
|
||||
Log.e(TAG, "Failed to register pinned stack listener", e);
|
||||
}
|
||||
SystemServicesProxy.getInstance(mContext).registerTaskStackListener(mTaskStackListener);
|
||||
|
||||
mMenuController = new PipMenuActivityController(context, mActivityManager, mWindowManager);
|
||||
mTouchHandler = new PipTouchHandler(context, mMenuController, mActivityManager,
|
||||
|
||||
@@ -136,13 +136,6 @@ public class PipMenuActivity extends Activity {
|
||||
showMenu();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onStart() {
|
||||
super.onStart();
|
||||
notifyMenuVisibility(true);
|
||||
repostDelayedFinish(INITIAL_DISMISS_DELAY);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPictureInPictureModeChanged(boolean isInPictureInPictureMode) {
|
||||
if (!isInPictureInPictureMode) {
|
||||
|
||||
@@ -75,6 +75,8 @@ public class PipMenuActivityController {
|
||||
}
|
||||
case MESSAGE_EXPAND_PIP: {
|
||||
mListeners.forEach(l -> l.onPipExpand());
|
||||
// Preemptively mark the menu as invisible once we expand the PiP
|
||||
mListeners.forEach(l -> l.onPipMenuVisibilityChanged(false));
|
||||
break;
|
||||
}
|
||||
case MESSAGE_MINIMIZE_PIP: {
|
||||
@@ -83,10 +85,16 @@ public class PipMenuActivityController {
|
||||
}
|
||||
case MESSAGE_DISMISS_PIP: {
|
||||
mListeners.forEach(l -> l.onPipDismiss());
|
||||
// Preemptively mark the menu as invisible once we dismiss the PiP
|
||||
mListeners.forEach(l -> l.onPipMenuVisibilityChanged(false));
|
||||
break;
|
||||
}
|
||||
case MESSAGE_UPDATE_ACTIVITY_CALLBACK: {
|
||||
mToActivityMessenger = msg.replyTo;
|
||||
// Mark the menu as invisible once the activity finishes as well
|
||||
if (mToActivityMessenger == null) {
|
||||
mListeners.forEach(l -> l.onPipMenuVisibilityChanged(false));
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -212,6 +212,17 @@ public class PipTouchHandler implements TunerService.Tunable {
|
||||
}
|
||||
}
|
||||
|
||||
public void onActivityPinned() {
|
||||
// Reset some states once we are pinned
|
||||
if (mIsTappingThrough) {
|
||||
mIsTappingThrough = false;
|
||||
registerInputConsumer();
|
||||
}
|
||||
if (mIsMinimized) {
|
||||
setMinimizedState(false);
|
||||
}
|
||||
}
|
||||
|
||||
public void onConfigurationChanged() {
|
||||
mSnapAlgorithm.onConfigurationChanged();
|
||||
updateBoundedPinnedStackBounds(false /* updatePinnedStackBounds */);
|
||||
|
||||
Reference in New Issue
Block a user