Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit f40fcdca authored by Jaewan Kim's avatar Jaewan Kim
Browse files

PIP: Close PIP if media session is gone

This keeps the PIP if there's no media session from the beginning.

Bug: 26717072
Change-Id: Idf5bab14d8979c0e50f4451f61bb9355d4562b96
parent d1a766e8
Loading
Loading
Loading
Loading
+16 −0
Original line number Diff line number Diff line
@@ -66,6 +66,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;
@@ -170,6 +173,12 @@ public class PipManager {
            resizePinnedStack(mState);
        }
    };
    private final Runnable mClosePipRunnable = new Runnable() {
        @Override
        public void run() {
            closePip();
        }
    };

    private final BroadcastReceiver mBroadcastReceiver = new BroadcastReceiver() {
        @Override
@@ -281,6 +290,7 @@ public class PipManager {
        for (int i = mListeners.size() - 1; i >= 0; --i) {
            mListeners.get(i).onPipActivityClosed();
        }
        mHandler.removeCallbacks(mClosePipRunnable);
    }

    /**
@@ -543,6 +553,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);
            }
        }
    }