Merge "Fix screenlayout calculation with overridden screenW/Hdp" into rvc-qpr-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
dd5f3cd7fb
@@ -2382,8 +2382,16 @@ class Task extends WindowContainer<WindowContainer> {
|
||||
// For calculating screen layout, we need to use the non-decor inset screen area for the
|
||||
// calculation for compatibility reasons, i.e. screen area without system bars that
|
||||
// could never go away in Honeycomb.
|
||||
final int compatScreenWidthDp = (int) (mTmpNonDecorBounds.width() / density);
|
||||
final int compatScreenHeightDp = (int) (mTmpNonDecorBounds.height() / density);
|
||||
int compatScreenWidthDp = (int) (mTmpNonDecorBounds.width() / density);
|
||||
int compatScreenHeightDp = (int) (mTmpNonDecorBounds.height() / density);
|
||||
// Use overrides if provided. If both overrides are provided, mTmpNonDecorBounds is
|
||||
// undefined so it can't be used.
|
||||
if (inOutConfig.screenWidthDp != Configuration.SCREEN_WIDTH_DP_UNDEFINED) {
|
||||
compatScreenWidthDp = inOutConfig.screenWidthDp;
|
||||
}
|
||||
if (inOutConfig.screenHeightDp != Configuration.SCREEN_HEIGHT_DP_UNDEFINED) {
|
||||
compatScreenHeightDp = inOutConfig.screenHeightDp;
|
||||
}
|
||||
// Reducing the screen layout starting from its parent config.
|
||||
inOutConfig.screenLayout = computeScreenLayoutOverride(parentConfig.screenLayout,
|
||||
compatScreenWidthDp, compatScreenHeightDp);
|
||||
|
||||
@@ -541,7 +541,7 @@ public class ActivityRecordTests extends ActivityTestsBase {
|
||||
mActivity = new ActivityBuilder(mService)
|
||||
.setTask(mTask)
|
||||
.setLaunchTaskBehind(true)
|
||||
.setConfigChanges(CONFIG_ORIENTATION)
|
||||
.setConfigChanges(CONFIG_ORIENTATION | CONFIG_SCREEN_LAYOUT)
|
||||
.build();
|
||||
mActivity.setState(ActivityStack.ActivityState.STOPPED, "Testing");
|
||||
|
||||
|
||||
@@ -402,6 +402,31 @@ public class TaskRecordTests extends ActivityTestsBase {
|
||||
assertEquals(Configuration.ORIENTATION_LANDSCAPE, inOutConfig.orientation);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testComputeConfigResourceLayoutOverrides() {
|
||||
final Rect fullScreenBounds = new Rect(0, 0, 1000, 2500);
|
||||
TestDisplayContent display = new TestDisplayContent.Builder(
|
||||
mService, fullScreenBounds.width(), fullScreenBounds.height()).build();
|
||||
final Task task = new TaskBuilder(mSupervisor).setDisplay(display).build();
|
||||
final Configuration inOutConfig = new Configuration();
|
||||
final Configuration parentConfig = new Configuration();
|
||||
final Rect nonLongBounds = new Rect(0, 0, 1000, 1250);
|
||||
parentConfig.windowConfiguration.setBounds(fullScreenBounds);
|
||||
parentConfig.windowConfiguration.setAppBounds(fullScreenBounds);
|
||||
parentConfig.densityDpi = 400;
|
||||
parentConfig.screenHeightDp = (fullScreenBounds.bottom * 160) / parentConfig.densityDpi;
|
||||
parentConfig.screenWidthDp = (fullScreenBounds.right * 160) / parentConfig.densityDpi;
|
||||
parentConfig.windowConfiguration.setRotation(ROTATION_0);
|
||||
|
||||
// Set BOTH screenW/H to an override value
|
||||
inOutConfig.screenWidthDp = nonLongBounds.width() * 160 / parentConfig.densityDpi;
|
||||
inOutConfig.screenHeightDp = nonLongBounds.height() * 160 / parentConfig.densityDpi;
|
||||
task.computeConfigResourceOverrides(inOutConfig, parentConfig);
|
||||
|
||||
// screenLayout should honor override when both screenW/H are set.
|
||||
assertTrue((inOutConfig.screenLayout & Configuration.SCREENLAYOUT_LONG_NO) != 0);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testComputeNestedConfigResourceOverrides() {
|
||||
final Task task = new TaskBuilder(mSupervisor).build();
|
||||
|
||||
Reference in New Issue
Block a user