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

Commit b2b59d1f authored by Hongwei Wang's avatar Hongwei Wang
Browse files

Always update the PictureInPictureParams

In PipTaskListener#setPictureInPictureParams, we used to do a
copyOnlySet when receive a different PictureInPictureParams.

For the following scenario, given the internal mPictureInPictureParams
variable contains 3 actions

- App sends a param with 0 action
    - Detected action change, actions are wiped out from menu
    - copyOnlySet is called, 3 actions remain in mPictureInPictureParams
- App sends a param with 3 actions
    - Detected no action change, due to copyOnlySet
    - PiP menu remains empty

Fixes this issue by directly assign the value, instead of copyOnlyset

Flag: com.android.wm.shell.enable_pip2
Bug: 401557393
Video: http://recall/-/aaaaaabFQoRHlzixHdtY/bWFkgdCmLEGPyx2sTBYyP0
Test: manually, follow the reproduce steps in bug
Test: atest WMShellUnitTests:PipTaskListenerTest
Change-Id: I3a79082b71401a93a3a04707cf60ba494ceeb8ce
parent 01fb3505
Loading
Loading
Loading
Loading
+3 −2
Original line number Diff line number Diff line
@@ -111,8 +111,9 @@ public class PipTaskListener implements ShellTaskOrganizer.TaskListener,
                listener.onActionsChanged(params.getActions(), params.getCloseAction());
            }
        }
        mPictureInPictureParams.copyOnlySet(params != null ? params
                : new PictureInPictureParams.Builder().build());
        // Set the new params but make sure mPictureInPictureParams is not null.
        mPictureInPictureParams = params == null
                ? new PictureInPictureParams.Builder().build() : params;
    }

    /** Add a PipParamsChangedCallback listener. */
+1 −0
Original line number Diff line number Diff line
@@ -196,6 +196,7 @@ public class PipTaskListenerTest {
        verifyNoMoreInteractions(mMockPipParamsChangedCallback);
        verify(mMockPipTransitionState, times(0))
                .setOnIdlePipTransitionStateRunnable(any(Runnable.class));
        assertTrue(mPipTaskListener.getPictureInPictureParams().empty());
    }

    @Test