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

Commit 315f549f authored by Mateusz Cicheński's avatar Mateusz Cicheński Committed by Automerger Merge Worker
Browse files

Merge "Pass the keep clear areas to PipBoundsState." into tm-dev am: 86f4c771

Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/17323776

Change-Id: Iaea837683ed5c0fd276f7105f454d9f9c1b95d12
parents 9b2f9b60 86f4c771
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());
    }
}