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

This commit is contained in:
Mateusz Cicheński
2022-03-23 03:31:03 +00:00
committed by Android (Google) Code Review
2 changed files with 22 additions and 1 deletions

View File

@@ -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();

View File

@@ -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());
}
}