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

Commit 23df6994 authored by Youngsang Cho's avatar Youngsang Cho
Browse files

Close PIP when PIP activity is finished

Bug: 26717072
Change-Id: I5dd431b0ee64ca152bd49013bb6bbb3e8d9fba71
parent 40089ca9
Loading
Loading
Loading
Loading
+30 −5
Original line number Diff line number Diff line
@@ -101,7 +101,26 @@ public class PipManager {
        @Override
        public void run() {
            if (mState != STATE_NO_PIP) {
                // TODO: check whether PIP task is closed.
                StackInfo stackInfo = null;
                try {
                    stackInfo = mActivityManager.getStackInfo(PINNED_STACK_ID);
                    if (stackInfo == null) {
                        Log.w(TAG, "There is no pinned stack");
                        closeInternal(false);
                        return;
                    }
                } catch (RemoteException e) {
                    Log.e(TAG, "getStackInfo failed", e);
                    return;
                }
                for (int i = stackInfo.taskIds.length - 1; i >= 0; --i) {
                    if (stackInfo.taskIds[i] == mPipTaskId) {
                        // PIP task is still alive.
                        return;
                    }
                }
                // PIP task doesn't exist anymore in PINNED_STACK.
                closeInternal(true);
            }
        }
    };
@@ -203,14 +222,20 @@ public class PipManager {
     * Closes PIP (PIPed activity and PIP system UI).
     */
    public void closePip() {
        closeInternal(true);
    }

    private void closeInternal(boolean removePipStack) {
        mState = STATE_NO_PIP;
        mPipTaskId = TASK_ID_NO_PIP;
        if (removePipStack) {
            try {
                mActivityManager.removeStack(PINNED_STACK_ID);
            } catch (RemoteException e) {
                Log.e(TAG, "removeStack failed", e);
            }
        }
    }

    /**
     * Moves the PIPed activity to the fullscreen and closes PIP system UI.