@@ -461,6 +461,10 @@ public void onReceive(Context context, Intent intent) {
461461 int mCurDisplayHeight = 0 ;
462462 int mAppDisplayWidth = 0 ;
463463 int mAppDisplayHeight = 0 ;
464+ int mSmallestDisplayWidth = 0 ;
465+ int mSmallestDisplayHeight = 0 ;
466+ int mLargestDisplayWidth = 0 ;
467+ int mLargestDisplayHeight = 0 ;
464468
465469 int mRotation = 0 ;
466470 int mForcedAppOrientation = ActivityInfo .SCREEN_ORIENTATION_UNSPECIFIED ;
@@ -6068,12 +6072,21 @@ Configuration computeNewConfigurationLocked() {
60686072 return config ;
60696073 }
60706074
6071- private int reduceConfigWidthSize (int curSize , int rotation , float density , int dw , int dh ) {
6072- int size = (int )(mPolicy .getConfigDisplayWidth (dw , dh , rotation ) / density );
6073- if (size < curSize ) {
6074- curSize = size ;
6075+ private void adjustDisplaySizeRanges (int rotation , int dw , int dh ) {
6076+ final int width = mPolicy .getConfigDisplayWidth (dw , dh , rotation );
6077+ if (width < mSmallestDisplayWidth ) {
6078+ mSmallestDisplayWidth = width ;
6079+ }
6080+ if (width > mLargestDisplayWidth ) {
6081+ mLargestDisplayWidth = width ;
6082+ }
6083+ final int height = mPolicy .getConfigDisplayHeight (dw , dh , rotation );
6084+ if (height < mSmallestDisplayHeight ) {
6085+ mSmallestDisplayHeight = height ;
6086+ }
6087+ if (height > mLargestDisplayHeight ) {
6088+ mLargestDisplayHeight = height ;
60756089 }
6076- return curSize ;
60776090 }
60786091
60796092 private int reduceConfigLayout (int curLayout , int rotation , float density ,
@@ -6155,7 +6168,7 @@ private int reduceConfigLayout(int curLayout, int rotation, float density,
61556168 return curLayout ;
61566169 }
61576170
6158- private void computeSmallestWidthAndScreenLayout (boolean rotated , int dw , int dh ,
6171+ private void computeSizeRangesAndScreenLayout (boolean rotated , int dw , int dh ,
61596172 float density , Configuration outConfig ) {
61606173 // We need to determine the smallest width that will occur under normal
61616174 // operation. To this, start with the base screen size and compute the
@@ -6169,17 +6182,21 @@ private void computeSmallestWidthAndScreenLayout(boolean rotated, int dw, int dh
61696182 unrotDw = dw ;
61706183 unrotDh = dh ;
61716184 }
6172- int sw = reduceConfigWidthSize (unrotDw , Surface .ROTATION_0 , density , unrotDw , unrotDh );
6173- sw = reduceConfigWidthSize (sw , Surface .ROTATION_90 , density , unrotDh , unrotDw );
6174- sw = reduceConfigWidthSize (sw , Surface .ROTATION_180 , density , unrotDw , unrotDh );
6175- sw = reduceConfigWidthSize (sw , Surface .ROTATION_270 , density , unrotDh , unrotDw );
6185+ mSmallestDisplayWidth = 1 <<30 ;
6186+ mSmallestDisplayHeight = 1 <<30 ;
6187+ mLargestDisplayWidth = 0 ;
6188+ mLargestDisplayHeight = 0 ;
6189+ adjustDisplaySizeRanges (Surface .ROTATION_0 , unrotDw , unrotDh );
6190+ adjustDisplaySizeRanges (Surface .ROTATION_90 , unrotDh , unrotDw );
6191+ adjustDisplaySizeRanges (Surface .ROTATION_180 , unrotDw , unrotDh );
6192+ adjustDisplaySizeRanges (Surface .ROTATION_270 , unrotDh , unrotDw );
61766193 int sl = Configuration .SCREENLAYOUT_SIZE_XLARGE
61776194 | Configuration .SCREENLAYOUT_LONG_YES ;
61786195 sl = reduceConfigLayout (sl , Surface .ROTATION_0 , density , unrotDw , unrotDh );
61796196 sl = reduceConfigLayout (sl , Surface .ROTATION_90 , density , unrotDh , unrotDw );
61806197 sl = reduceConfigLayout (sl , Surface .ROTATION_180 , density , unrotDw , unrotDh );
61816198 sl = reduceConfigLayout (sl , Surface .ROTATION_270 , density , unrotDh , unrotDw );
6182- outConfig .smallestScreenWidthDp = sw ;
6199+ outConfig .smallestScreenWidthDp = ( int )( mSmallestDisplayWidth / density ) ;
61836200 outConfig .screenLayout = sl ;
61846201 }
61856202
@@ -6289,7 +6306,7 @@ boolean computeScreenConfigurationLocked(Configuration config) {
62896306 / dm .density );
62906307 config .screenHeightDp = (int )(mPolicy .getConfigDisplayHeight (dw , dh , mRotation )
62916308 / dm .density );
6292- computeSmallestWidthAndScreenLayout (rotated , dw , dh , dm .density , config );
6309+ computeSizeRangesAndScreenLayout (rotated , dw , dh , dm .density , config );
62936310
62946311 config .compatScreenWidthDp = (int )(config .screenWidthDp / mCompatibleScreenScale );
62956312 config .compatScreenHeightDp = (int )(config .screenHeightDp / mCompatibleScreenScale );
@@ -7199,6 +7216,15 @@ public int getMaximumSizeDimension() {
71997216 }
72007217 }
72017218
7219+ public void getCurrentSizeRange (Point smallestSize , Point largestSize ) {
7220+ synchronized (mDisplaySizeLock ) {
7221+ smallestSize .x = mSmallestDisplayWidth ;
7222+ smallestSize .y = mSmallestDisplayHeight ;
7223+ largestSize .x = mLargestDisplayWidth ;
7224+ largestSize .y = mLargestDisplayHeight ;
7225+ }
7226+ }
7227+
72027228 public void setForcedDisplaySize (int longDimen , int shortDimen ) {
72037229 synchronized (mWindowMap ) {
72047230 int width , height ;
@@ -9391,14 +9417,25 @@ void dumpWindowsLocked(FileDescriptor fd, PrintWriter pw, boolean dumpAll,
93919417 pw .println ();
93929418 if (mDisplay != null ) {
93939419 pw .print (" Display: init=" ); pw .print (mInitialDisplayWidth ); pw .print ("x" );
9394- pw .print (mInitialDisplayHeight ); pw .print (" base=" );
9395- pw .print (mBaseDisplayWidth ); pw .print ("x" ); pw .print (mBaseDisplayHeight );
9420+ pw .print (mInitialDisplayHeight );
9421+ if (mInitialDisplayWidth != mBaseDisplayWidth
9422+ || mInitialDisplayHeight != mBaseDisplayHeight ) {
9423+ pw .print (" base=" );
9424+ pw .print (mBaseDisplayWidth ); pw .print ("x" ); pw .print (mBaseDisplayHeight );
9425+ }
9426+ final int rawWidth = mDisplay .getRawWidth ();
9427+ final int rawHeight = mDisplay .getRawHeight ();
9428+ if (rawWidth != mCurDisplayWidth || rawHeight != mCurDisplayHeight ) {
9429+ pw .print (" raw=" ); pw .print (rawWidth ); pw .print ("x" ); pw .print (rawHeight );
9430+ }
93969431 pw .print (" cur=" );
93979432 pw .print (mCurDisplayWidth ); pw .print ("x" ); pw .print (mCurDisplayHeight );
93989433 pw .print (" app=" );
93999434 pw .print (mAppDisplayWidth ); pw .print ("x" ); pw .print (mAppDisplayHeight );
9400- pw .print (" raw=" ); pw .print (mDisplay .getRawWidth ());
9401- pw .print ("x" ); pw .println (mDisplay .getRawHeight ());
9435+ pw .print (" rng=" ); pw .print (mSmallestDisplayWidth );
9436+ pw .print ("x" ); pw .print (mSmallestDisplayHeight );
9437+ pw .print ("-" ); pw .print (mLargestDisplayWidth );
9438+ pw .print ("x" ); pw .println (mLargestDisplayHeight );
94029439 } else {
94039440 pw .println (" NO DISPLAY" );
94049441 }
0 commit comments