Loading services/core/java/com/android/server/wm/DisplayContent.java +4 −3 Original line number Diff line number Diff line Loading @@ -2397,7 +2397,8 @@ class DisplayContent extends RootDisplayArea implements WindowManagerPolicy.Disp sl = reduceConfigLayout(sl, Surface.ROTATION_90, density, unrotDh, unrotDw, uiMode); sl = reduceConfigLayout(sl, Surface.ROTATION_180, density, unrotDw, unrotDh, uiMode); sl = reduceConfigLayout(sl, Surface.ROTATION_270, density, unrotDh, unrotDw, uiMode); outConfig.smallestScreenWidthDp = (int)(displayInfo.smallestNominalAppWidth / density); outConfig.smallestScreenWidthDp = (int) (displayInfo.smallestNominalAppWidth / density + 0.5f); outConfig.screenLayout = sl; } Loading @@ -2419,8 +2420,8 @@ class DisplayContent extends RootDisplayArea implements WindowManagerPolicy.Disp longSize = shortSize; shortSize = tmp; } longSize = (int)(longSize/density); shortSize = (int)(shortSize/density); longSize = (int) (longSize / density + 0.5f); shortSize = (int) (shortSize / density + 0.5f); return Configuration.reduceScreenLayout(curLayout, longSize, shortSize); } Loading services/core/java/com/android/server/wm/TaskFragment.java +7 −6 Original line number Diff line number Diff line Loading @@ -2039,13 +2039,14 @@ class TaskFragment extends WindowContainer<WindowContainer> { } if (inOutConfig.screenWidthDp == Configuration.SCREEN_WIDTH_DP_UNDEFINED) { final int overrideScreenWidthDp = (int) (mTmpStableBounds.width() / density); final int overrideScreenWidthDp = (int) (mTmpStableBounds.width() / density + 0.5f); inOutConfig.screenWidthDp = (insideParentBounds && !customContainerPolicy) ? Math.min(overrideScreenWidthDp, parentConfig.screenWidthDp) : overrideScreenWidthDp; } if (inOutConfig.screenHeightDp == Configuration.SCREEN_HEIGHT_DP_UNDEFINED) { final int overrideScreenHeightDp = (int) (mTmpStableBounds.height() / density); final int overrideScreenHeightDp = (int) (mTmpStableBounds.height() / density + 0.5f); inOutConfig.screenHeightDp = (insideParentBounds && !customContainerPolicy) ? Math.min(overrideScreenHeightDp, parentConfig.screenHeightDp) : overrideScreenHeightDp; Loading @@ -2063,8 +2064,8 @@ class TaskFragment extends WindowContainer<WindowContainer> { && !mTmpFullBounds.isEmpty() && mTmpFullBounds.equals(parentBounds); if (WindowConfiguration.isFloating(windowingMode) && !inPipTransition) { // For floating tasks, calculate the smallest width from the bounds of the task inOutConfig.smallestScreenWidthDp = (int) ( Math.min(mTmpFullBounds.width(), mTmpFullBounds.height()) / density); inOutConfig.smallestScreenWidthDp = (int) (0.5f + Math.min(mTmpFullBounds.width(), mTmpFullBounds.height()) / density); } // otherwise, it will just inherit } Loading @@ -2078,8 +2079,8 @@ class TaskFragment 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. int compatScreenWidthDp = (int) (mTmpNonDecorBounds.width() / density); int compatScreenHeightDp = (int) (mTmpNonDecorBounds.height() / density); int compatScreenWidthDp = (int) (mTmpNonDecorBounds.width() / density + 0.5f); int compatScreenHeightDp = (int) (mTmpNonDecorBounds.height() / density + 0.5f); // 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) { Loading services/tests/wmtests/src/com/android/server/wm/TaskTests.java +12 −11 Original line number Diff line number Diff line Loading @@ -31,7 +31,6 @@ import static android.content.pm.ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE; import static android.content.pm.ActivityInfo.SCREEN_ORIENTATION_PORTRAIT; import static android.content.pm.ActivityInfo.SCREEN_ORIENTATION_UNSET; import static android.content.pm.ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED; import static android.util.DisplayMetrics.DENSITY_DEFAULT; import static android.view.IWindowManager.FIXED_TO_USER_ROTATION_ENABLED; import static android.view.Surface.ROTATION_0; import static android.view.Surface.ROTATION_90; Loading Loading @@ -667,8 +666,6 @@ public class TaskTests extends WindowTestsBase { final Task task = new TaskBuilder(mSupervisor).setDisplay(display).build(); final Configuration inOutConfig = new Configuration(); final Configuration parentConfig = new Configuration(); final int longSide = 1200; final int shortSide = 600; final Rect parentBounds = new Rect(0, 0, 250, 500); final Rect parentAppBounds = new Rect(0, 0, 250, 480); parentConfig.windowConfiguration.setBounds(parentBounds); Loading @@ -689,14 +686,17 @@ public class TaskTests extends WindowTestsBase { // If bounds are overridden, config properties should be made to match. Surface hierarchy // will crop for policy. inOutConfig.setToDefaults(); final int longSide = 960; final int shortSide = 540; parentConfig.densityDpi = 192; final Rect largerPortraitBounds = new Rect(0, 0, shortSide, longSide); inOutConfig.windowConfiguration.setBounds(largerPortraitBounds); task.computeConfigResourceOverrides(inOutConfig, parentConfig); // The override bounds are beyond the parent, the out appBounds should not be intersected // by parent appBounds. assertEquals(largerPortraitBounds, inOutConfig.windowConfiguration.getAppBounds()); assertEquals(longSide, inOutConfig.screenHeightDp * parentConfig.densityDpi / 160); assertEquals(shortSide, inOutConfig.screenWidthDp * parentConfig.densityDpi / 160); assertEquals(800, inOutConfig.screenHeightDp); // 960/(192/160) = 800 assertEquals(450, inOutConfig.screenWidthDp); // 540/(192/160) = 450 inOutConfig.setToDefaults(); // Landscape bounds. Loading @@ -716,16 +716,17 @@ public class TaskTests extends WindowTestsBase { // Without limiting to be inside the parent bounds, the out screen size should keep relative // to the input bounds. final ActivityRecord activity = new ActivityBuilder(mAtm).setTask(task).build(); final ActivityRecord.CompatDisplayInsets compatIntsets = final ActivityRecord.CompatDisplayInsets compatInsets = new ActivityRecord.CompatDisplayInsets( display, activity, /* fixedOrientationBounds= */ null); task.computeConfigResourceOverrides(inOutConfig, parentConfig, compatIntsets); task.computeConfigResourceOverrides(inOutConfig, parentConfig, compatInsets); assertEquals(largerLandscapeBounds, inOutConfig.windowConfiguration.getAppBounds()); assertEquals((shortSide - statusBarHeight) * DENSITY_DEFAULT / parentConfig.densityDpi, inOutConfig.screenHeightDp); assertEquals(longSide * DENSITY_DEFAULT / parentConfig.densityDpi, inOutConfig.screenWidthDp); final float density = parentConfig.densityDpi * DisplayMetrics.DENSITY_DEFAULT_SCALE; final int expectedHeightDp = (int) ((shortSide - statusBarHeight) / density + 0.5f); assertEquals(expectedHeightDp, inOutConfig.screenHeightDp); final int expectedWidthDp = (int) (longSide / density + 0.5f); assertEquals(expectedWidthDp, inOutConfig.screenWidthDp); assertEquals(Configuration.ORIENTATION_LANDSCAPE, inOutConfig.orientation); } Loading Loading
services/core/java/com/android/server/wm/DisplayContent.java +4 −3 Original line number Diff line number Diff line Loading @@ -2397,7 +2397,8 @@ class DisplayContent extends RootDisplayArea implements WindowManagerPolicy.Disp sl = reduceConfigLayout(sl, Surface.ROTATION_90, density, unrotDh, unrotDw, uiMode); sl = reduceConfigLayout(sl, Surface.ROTATION_180, density, unrotDw, unrotDh, uiMode); sl = reduceConfigLayout(sl, Surface.ROTATION_270, density, unrotDh, unrotDw, uiMode); outConfig.smallestScreenWidthDp = (int)(displayInfo.smallestNominalAppWidth / density); outConfig.smallestScreenWidthDp = (int) (displayInfo.smallestNominalAppWidth / density + 0.5f); outConfig.screenLayout = sl; } Loading @@ -2419,8 +2420,8 @@ class DisplayContent extends RootDisplayArea implements WindowManagerPolicy.Disp longSize = shortSize; shortSize = tmp; } longSize = (int)(longSize/density); shortSize = (int)(shortSize/density); longSize = (int) (longSize / density + 0.5f); shortSize = (int) (shortSize / density + 0.5f); return Configuration.reduceScreenLayout(curLayout, longSize, shortSize); } Loading
services/core/java/com/android/server/wm/TaskFragment.java +7 −6 Original line number Diff line number Diff line Loading @@ -2039,13 +2039,14 @@ class TaskFragment extends WindowContainer<WindowContainer> { } if (inOutConfig.screenWidthDp == Configuration.SCREEN_WIDTH_DP_UNDEFINED) { final int overrideScreenWidthDp = (int) (mTmpStableBounds.width() / density); final int overrideScreenWidthDp = (int) (mTmpStableBounds.width() / density + 0.5f); inOutConfig.screenWidthDp = (insideParentBounds && !customContainerPolicy) ? Math.min(overrideScreenWidthDp, parentConfig.screenWidthDp) : overrideScreenWidthDp; } if (inOutConfig.screenHeightDp == Configuration.SCREEN_HEIGHT_DP_UNDEFINED) { final int overrideScreenHeightDp = (int) (mTmpStableBounds.height() / density); final int overrideScreenHeightDp = (int) (mTmpStableBounds.height() / density + 0.5f); inOutConfig.screenHeightDp = (insideParentBounds && !customContainerPolicy) ? Math.min(overrideScreenHeightDp, parentConfig.screenHeightDp) : overrideScreenHeightDp; Loading @@ -2063,8 +2064,8 @@ class TaskFragment extends WindowContainer<WindowContainer> { && !mTmpFullBounds.isEmpty() && mTmpFullBounds.equals(parentBounds); if (WindowConfiguration.isFloating(windowingMode) && !inPipTransition) { // For floating tasks, calculate the smallest width from the bounds of the task inOutConfig.smallestScreenWidthDp = (int) ( Math.min(mTmpFullBounds.width(), mTmpFullBounds.height()) / density); inOutConfig.smallestScreenWidthDp = (int) (0.5f + Math.min(mTmpFullBounds.width(), mTmpFullBounds.height()) / density); } // otherwise, it will just inherit } Loading @@ -2078,8 +2079,8 @@ class TaskFragment 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. int compatScreenWidthDp = (int) (mTmpNonDecorBounds.width() / density); int compatScreenHeightDp = (int) (mTmpNonDecorBounds.height() / density); int compatScreenWidthDp = (int) (mTmpNonDecorBounds.width() / density + 0.5f); int compatScreenHeightDp = (int) (mTmpNonDecorBounds.height() / density + 0.5f); // 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) { Loading
services/tests/wmtests/src/com/android/server/wm/TaskTests.java +12 −11 Original line number Diff line number Diff line Loading @@ -31,7 +31,6 @@ import static android.content.pm.ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE; import static android.content.pm.ActivityInfo.SCREEN_ORIENTATION_PORTRAIT; import static android.content.pm.ActivityInfo.SCREEN_ORIENTATION_UNSET; import static android.content.pm.ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED; import static android.util.DisplayMetrics.DENSITY_DEFAULT; import static android.view.IWindowManager.FIXED_TO_USER_ROTATION_ENABLED; import static android.view.Surface.ROTATION_0; import static android.view.Surface.ROTATION_90; Loading Loading @@ -667,8 +666,6 @@ public class TaskTests extends WindowTestsBase { final Task task = new TaskBuilder(mSupervisor).setDisplay(display).build(); final Configuration inOutConfig = new Configuration(); final Configuration parentConfig = new Configuration(); final int longSide = 1200; final int shortSide = 600; final Rect parentBounds = new Rect(0, 0, 250, 500); final Rect parentAppBounds = new Rect(0, 0, 250, 480); parentConfig.windowConfiguration.setBounds(parentBounds); Loading @@ -689,14 +686,17 @@ public class TaskTests extends WindowTestsBase { // If bounds are overridden, config properties should be made to match. Surface hierarchy // will crop for policy. inOutConfig.setToDefaults(); final int longSide = 960; final int shortSide = 540; parentConfig.densityDpi = 192; final Rect largerPortraitBounds = new Rect(0, 0, shortSide, longSide); inOutConfig.windowConfiguration.setBounds(largerPortraitBounds); task.computeConfigResourceOverrides(inOutConfig, parentConfig); // The override bounds are beyond the parent, the out appBounds should not be intersected // by parent appBounds. assertEquals(largerPortraitBounds, inOutConfig.windowConfiguration.getAppBounds()); assertEquals(longSide, inOutConfig.screenHeightDp * parentConfig.densityDpi / 160); assertEquals(shortSide, inOutConfig.screenWidthDp * parentConfig.densityDpi / 160); assertEquals(800, inOutConfig.screenHeightDp); // 960/(192/160) = 800 assertEquals(450, inOutConfig.screenWidthDp); // 540/(192/160) = 450 inOutConfig.setToDefaults(); // Landscape bounds. Loading @@ -716,16 +716,17 @@ public class TaskTests extends WindowTestsBase { // Without limiting to be inside the parent bounds, the out screen size should keep relative // to the input bounds. final ActivityRecord activity = new ActivityBuilder(mAtm).setTask(task).build(); final ActivityRecord.CompatDisplayInsets compatIntsets = final ActivityRecord.CompatDisplayInsets compatInsets = new ActivityRecord.CompatDisplayInsets( display, activity, /* fixedOrientationBounds= */ null); task.computeConfigResourceOverrides(inOutConfig, parentConfig, compatIntsets); task.computeConfigResourceOverrides(inOutConfig, parentConfig, compatInsets); assertEquals(largerLandscapeBounds, inOutConfig.windowConfiguration.getAppBounds()); assertEquals((shortSide - statusBarHeight) * DENSITY_DEFAULT / parentConfig.densityDpi, inOutConfig.screenHeightDp); assertEquals(longSide * DENSITY_DEFAULT / parentConfig.densityDpi, inOutConfig.screenWidthDp); final float density = parentConfig.densityDpi * DisplayMetrics.DENSITY_DEFAULT_SCALE; final int expectedHeightDp = (int) ((shortSide - statusBarHeight) / density + 0.5f); assertEquals(expectedHeightDp, inOutConfig.screenHeightDp); final int expectedWidthDp = (int) (longSide / density + 0.5f); assertEquals(expectedWidthDp, inOutConfig.screenWidthDp); assertEquals(Configuration.ORIENTATION_LANDSCAPE, inOutConfig.orientation); } Loading