Merge "Allow reachability for translucent activities" into tm-qpr-dev am: 3194b5a054
Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/21538127 Change-Id: I5f972774ffcb2d21e413fdba901ac049a6917254 Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
This commit is contained in:
@@ -870,10 +870,9 @@ final class LetterboxUiController {
|
|||||||
return mActivityRecord.mWmService.mContext.getResources();
|
return mActivityRecord.mWmService.mContext.getResources();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void handleHorizontalDoubleTap(int x) {
|
@VisibleForTesting
|
||||||
// TODO(b/260857308): Investigate if enabling reachability for translucent activity
|
void handleHorizontalDoubleTap(int x) {
|
||||||
if (hasInheritedLetterboxBehavior() || !isHorizontalReachabilityEnabled()
|
if (!isHorizontalReachabilityEnabled() || mActivityRecord.isInTransition()) {
|
||||||
|| mActivityRecord.isInTransition()) {
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -911,10 +910,9 @@ final class LetterboxUiController {
|
|||||||
mActivityRecord.recomputeConfiguration();
|
mActivityRecord.recomputeConfiguration();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void handleVerticalDoubleTap(int y) {
|
@VisibleForTesting
|
||||||
// TODO(b/260857308): Investigate if enabling reachability for translucent activity
|
void handleVerticalDoubleTap(int y) {
|
||||||
if (hasInheritedLetterboxBehavior() || !isVerticalReachabilityEnabled()
|
if (!isVerticalReachabilityEnabled() || mActivityRecord.isInTransition()) {
|
||||||
|| mActivityRecord.isInTransition()) {
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -113,6 +113,8 @@ import org.junit.runner.RunWith;
|
|||||||
import org.mockito.ArgumentCaptor;
|
import org.mockito.ArgumentCaptor;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.function.Consumer;
|
||||||
|
import java.util.function.Function;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Tests for Size Compatibility mode.
|
* Tests for Size Compatibility mode.
|
||||||
@@ -167,6 +169,156 @@ public class SizeCompatTests extends WindowTestsBase {
|
|||||||
setUpApp(builder.build());
|
setUpApp(builder.build());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testHorizontalReachabilityEnabledForTranslucentActivities() {
|
||||||
|
setUpDisplaySizeWithApp(2500, 1000);
|
||||||
|
mActivity.mDisplayContent.setIgnoreOrientationRequest(true /* ignoreOrientationRequest */);
|
||||||
|
final LetterboxConfiguration config = mWm.mLetterboxConfiguration;
|
||||||
|
config.setTranslucentLetterboxingOverrideEnabled(true);
|
||||||
|
config.setLetterboxHorizontalPositionMultiplier(0.5f);
|
||||||
|
config.setIsHorizontalReachabilityEnabled(true);
|
||||||
|
|
||||||
|
// Opaque activity
|
||||||
|
prepareUnresizable(mActivity, SCREEN_ORIENTATION_PORTRAIT);
|
||||||
|
addWindowToActivity(mActivity);
|
||||||
|
mActivity.mRootWindowContainer.performSurfacePlacement();
|
||||||
|
|
||||||
|
// Translucent Activity
|
||||||
|
final ActivityRecord translucentActivity = new ActivityBuilder(mAtm)
|
||||||
|
.setLaunchedFromUid(mActivity.getUid())
|
||||||
|
.setScreenOrientation(SCREEN_ORIENTATION_PORTRAIT)
|
||||||
|
.build();
|
||||||
|
doReturn(false).when(translucentActivity).fillsParent();
|
||||||
|
mTask.addChild(translucentActivity);
|
||||||
|
|
||||||
|
spyOn(translucentActivity.mLetterboxUiController);
|
||||||
|
doReturn(true).when(translucentActivity.mLetterboxUiController)
|
||||||
|
.shouldShowLetterboxUi(any());
|
||||||
|
|
||||||
|
addWindowToActivity(translucentActivity);
|
||||||
|
translucentActivity.mRootWindowContainer.performSurfacePlacement();
|
||||||
|
|
||||||
|
final Function<ActivityRecord, Rect> innerBoundsOf =
|
||||||
|
(ActivityRecord a) -> {
|
||||||
|
final Rect bounds = new Rect();
|
||||||
|
a.mLetterboxUiController.getLetterboxInnerBounds(bounds);
|
||||||
|
return bounds;
|
||||||
|
};
|
||||||
|
final Runnable checkLetterboxPositions = () -> assertEquals(innerBoundsOf.apply(mActivity),
|
||||||
|
innerBoundsOf.apply(translucentActivity));
|
||||||
|
final Runnable checkIsLeft = () -> assertThat(
|
||||||
|
innerBoundsOf.apply(translucentActivity).left).isEqualTo(0);
|
||||||
|
final Runnable checkIsRight = () -> assertThat(
|
||||||
|
innerBoundsOf.apply(translucentActivity).right).isEqualTo(2500);
|
||||||
|
final Runnable checkIsCentered = () -> assertThat(
|
||||||
|
innerBoundsOf.apply(translucentActivity).left > 0
|
||||||
|
&& innerBoundsOf.apply(translucentActivity).right < 2500).isTrue();
|
||||||
|
|
||||||
|
final Consumer<Integer> doubleClick =
|
||||||
|
(Integer x) -> {
|
||||||
|
mActivity.mLetterboxUiController.handleHorizontalDoubleTap(x);
|
||||||
|
mActivity.mRootWindowContainer.performSurfacePlacement();
|
||||||
|
};
|
||||||
|
|
||||||
|
// Initial state
|
||||||
|
checkIsCentered.run();
|
||||||
|
|
||||||
|
// Double-click left
|
||||||
|
doubleClick.accept(/* x */ 10);
|
||||||
|
checkLetterboxPositions.run();
|
||||||
|
checkIsLeft.run();
|
||||||
|
|
||||||
|
// Double-click right
|
||||||
|
doubleClick.accept(/* x */ 1990);
|
||||||
|
checkLetterboxPositions.run();
|
||||||
|
checkIsCentered.run();
|
||||||
|
|
||||||
|
// Double-click right
|
||||||
|
doubleClick.accept(/* x */ 1990);
|
||||||
|
checkLetterboxPositions.run();
|
||||||
|
checkIsRight.run();
|
||||||
|
|
||||||
|
// Double-click left
|
||||||
|
doubleClick.accept(/* x */ 10);
|
||||||
|
checkLetterboxPositions.run();
|
||||||
|
checkIsCentered.run();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testVerticalReachabilityEnabledForTranslucentActivities() {
|
||||||
|
setUpDisplaySizeWithApp(1000, 2500);
|
||||||
|
mActivity.mDisplayContent.setIgnoreOrientationRequest(true /* ignoreOrientationRequest */);
|
||||||
|
final LetterboxConfiguration config = mWm.mLetterboxConfiguration;
|
||||||
|
config.setTranslucentLetterboxingOverrideEnabled(true);
|
||||||
|
config.setLetterboxVerticalPositionMultiplier(0.5f);
|
||||||
|
config.setIsVerticalReachabilityEnabled(true);
|
||||||
|
|
||||||
|
// Opaque activity
|
||||||
|
prepareUnresizable(mActivity, SCREEN_ORIENTATION_LANDSCAPE);
|
||||||
|
addWindowToActivity(mActivity);
|
||||||
|
mActivity.mRootWindowContainer.performSurfacePlacement();
|
||||||
|
|
||||||
|
// Translucent Activity
|
||||||
|
final ActivityRecord translucentActivity = new ActivityBuilder(mAtm)
|
||||||
|
.setLaunchedFromUid(mActivity.getUid())
|
||||||
|
.setScreenOrientation(SCREEN_ORIENTATION_LANDSCAPE)
|
||||||
|
.build();
|
||||||
|
doReturn(false).when(translucentActivity).fillsParent();
|
||||||
|
mTask.addChild(translucentActivity);
|
||||||
|
|
||||||
|
spyOn(translucentActivity.mLetterboxUiController);
|
||||||
|
doReturn(true).when(translucentActivity.mLetterboxUiController)
|
||||||
|
.shouldShowLetterboxUi(any());
|
||||||
|
|
||||||
|
addWindowToActivity(translucentActivity);
|
||||||
|
translucentActivity.mRootWindowContainer.performSurfacePlacement();
|
||||||
|
|
||||||
|
final Function<ActivityRecord, Rect> innerBoundsOf =
|
||||||
|
(ActivityRecord a) -> {
|
||||||
|
final Rect bounds = new Rect();
|
||||||
|
a.mLetterboxUiController.getLetterboxInnerBounds(bounds);
|
||||||
|
return bounds;
|
||||||
|
};
|
||||||
|
final Runnable checkLetterboxPositions = () -> assertEquals(innerBoundsOf.apply(mActivity),
|
||||||
|
innerBoundsOf.apply(translucentActivity));
|
||||||
|
final Runnable checkIsTop = () -> assertThat(
|
||||||
|
innerBoundsOf.apply(translucentActivity).top).isEqualTo(0);
|
||||||
|
final Runnable checkIsBottom = () -> assertThat(
|
||||||
|
innerBoundsOf.apply(translucentActivity).bottom).isEqualTo(2500);
|
||||||
|
final Runnable checkIsCentered = () -> assertThat(
|
||||||
|
innerBoundsOf.apply(translucentActivity).top > 0
|
||||||
|
&& innerBoundsOf.apply(translucentActivity).bottom < 2500).isTrue();
|
||||||
|
|
||||||
|
final Consumer<Integer> doubleClick =
|
||||||
|
(Integer y) -> {
|
||||||
|
mActivity.mLetterboxUiController.handleVerticalDoubleTap(y);
|
||||||
|
mActivity.mRootWindowContainer.performSurfacePlacement();
|
||||||
|
};
|
||||||
|
|
||||||
|
// Initial state
|
||||||
|
checkIsCentered.run();
|
||||||
|
|
||||||
|
// Double-click top
|
||||||
|
doubleClick.accept(/* y */ 10);
|
||||||
|
checkLetterboxPositions.run();
|
||||||
|
checkIsTop.run();
|
||||||
|
|
||||||
|
// Double-click bottom
|
||||||
|
doubleClick.accept(/* y */ 1990);
|
||||||
|
checkLetterboxPositions.run();
|
||||||
|
checkIsCentered.run();
|
||||||
|
|
||||||
|
// Double-click bottom
|
||||||
|
doubleClick.accept(/* y */ 1990);
|
||||||
|
checkLetterboxPositions.run();
|
||||||
|
checkIsBottom.run();
|
||||||
|
|
||||||
|
// Double-click top
|
||||||
|
doubleClick.accept(/* y */ 10);
|
||||||
|
checkLetterboxPositions.run();
|
||||||
|
checkIsCentered.run();
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testApplyStrategyToTranslucentActivities() {
|
public void testApplyStrategyToTranslucentActivities() {
|
||||||
mWm.mLetterboxConfiguration.setTranslucentLetterboxingOverrideEnabled(true);
|
mWm.mLetterboxConfiguration.setTranslucentLetterboxingOverrideEnabled(true);
|
||||||
|
|||||||
Reference in New Issue
Block a user