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

Commit 86f4c771 authored by Mateusz Cicheński's avatar Mateusz Cicheński Committed by Android (Google) Code Review
Browse files

Merge "Pass the keep clear areas to PipBoundsState." into tm-dev

parents 033fcafa a6ac70ed
Loading
Loading
Loading
Loading
+10 −1
Original line number Diff line number Diff line
@@ -89,13 +89,14 @@ import com.android.wm.shell.transition.Transitions;

import java.io.PrintWriter;
import java.util.Optional;
import java.util.Set;
import java.util.function.Consumer;

/**
 * Manages the picture-in-picture (PIP) UI and states for Phones.
 */
public class PipController implements PipTransitionController.PipTransitionCallback,
        RemoteCallable<PipController> {
        RemoteCallable<PipController>, DisplayController.OnDisplaysChangedListener {
    private static final String TAG = "PipController";

    private Context mContext;
@@ -457,6 +458,14 @@ public class PipController implements PipTransitionController.PipTransitionCallb
        return mMainExecutor;
    }

    @Override
    public void onKeepClearAreasChanged(int displayId, Set<Rect> restricted,
            Set<Rect> unrestricted) {
        if (mPipBoundsState.getDisplayId() == displayId) {
            mPipBoundsState.setKeepClearAreas(restricted, unrestricted);
        }
    }

    private void onConfigurationChanged(Configuration newConfig) {
        mPipBoundsAlgorithm.onConfigurationChanged(mContext);
        mTouchHandler.onConfigurationChanged();
+12 −0
Original line number Diff line number Diff line
@@ -59,6 +59,7 @@ import org.mockito.Mock;
import org.mockito.MockitoAnnotations;

import java.util.Optional;
import java.util.Set;

/**
 * Unit tests for {@link PipController}
@@ -209,4 +210,15 @@ public class PipControllerTest extends ShellTestCase {

        verify(mMockPipMotionHelper, never()).movePip(any(Rect.class));
    }

    @Test
    public void onKeepClearAreasChanged_updatesPipBoundsState() {
        final int displayId = 1;
        final Rect keepClearArea = new Rect(0, 0, 10, 10);
        when(mMockPipBoundsState.getDisplayId()).thenReturn(displayId);

        mPipController.onKeepClearAreasChanged(displayId, Set.of(keepClearArea), Set.of());

        verify(mMockPipBoundsState).setKeepClearAreas(Set.of(keepClearArea), Set.of());
    }
}