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

Commit d78bf970 authored by Youngsang Cho's avatar Youngsang Cho Committed by Android (Google) Code Review
Browse files

Merge "Close PIP when PIP activity is finished" into nyc-dev

parents c657f3d0 23df6994
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.