diff --git a/packages/SystemUI/src/com/android/systemui/tv/pip/PipManager.java b/packages/SystemUI/src/com/android/systemui/tv/pip/PipManager.java index ea15b81642142..ff7ea276aa911 100644 --- a/packages/SystemUI/src/com/android/systemui/tv/pip/PipManager.java +++ b/packages/SystemUI/src/com/android/systemui/tv/pip/PipManager.java @@ -68,6 +68,9 @@ public class PipManager { public static final int SUSPEND_PIP_RESIZE_REASON_WAITING_FOR_MENU_ACTIVITY_FINISH = 0x1; public static final int SUSPEND_PIP_RESIZE_REASON_WAITING_FOR_OVERLAY_ACTIVITY_FINISH = 0x2; + + private static final int CLOSE_PIP_WHEN_MEDIA_SESSION_GONE_TIMEOUT_MS = 3000; + private int mSuspendPipResizingReason; private static final float SCALE_FACTOR = 1.1f; @@ -172,6 +175,12 @@ public class PipManager { resizePinnedStack(mState); } }; + private final Runnable mClosePipRunnable = new Runnable() { + @Override + public void run() { + closePip(); + } + }; private final BroadcastReceiver mBroadcastReceiver = new BroadcastReceiver() { @Override @@ -283,6 +292,7 @@ public class PipManager { for (int i = mListeners.size() - 1; i >= 0; --i) { mListeners.get(i).onPipActivityClosed(); } + mHandler.removeCallbacks(mClosePipRunnable); } /** @@ -545,6 +555,12 @@ public class PipManager { for (int i = mListeners.size() - 1; i >= 0; i--) { mListeners.get(i).onMediaControllerChanged(); } + if (mPipMediaController == null) { + mHandler.postDelayed(mClosePipRunnable, + CLOSE_PIP_WHEN_MEDIA_SESSION_GONE_TIMEOUT_MS); + } else { + mHandler.removeCallbacks(mClosePipRunnable); + } } }