Loading core/java/android/content/res/Configuration.java +18 −1 Original line number Diff line number Diff line Loading @@ -1672,6 +1672,23 @@ public final class Configuration implements Parcelable, Comparable<Configuration n = this.densityDpi - that.densityDpi; if (n != 0) return n; n = this.assetsSeq - that.assetsSeq; if (n != 0) return n; if (this.appBounds == null && that.appBounds != null) { return 1; } else if (this.appBounds != null && that.appBounds == null) { return -1; } else if (this.appBounds != null && that.appBounds != null) { n = this.appBounds.left - that.appBounds.left; if (n != 0) return n; n = this.appBounds.top - that.appBounds.top; if (n != 0) return n; n = this.appBounds.right - that.appBounds.right; if (n != 0) return n; n = this.appBounds.bottom - that.appBounds.bottom; if (n != 0) return n; } // if (n != 0) return n; return n; } Loading services/tests/servicestests/src/com/android/server/wm/AppBoundsTests.java +26 −1 Original line number Diff line number Diff line Loading @@ -27,6 +27,7 @@ import android.support.test.filters.SmallTest; import android.support.test.runner.AndroidJUnit4; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotEquals; import static org.junit.Assert.assertTrue; /** Loading Loading @@ -121,7 +122,6 @@ public class AppBoundsTests extends WindowTestsBase { mParentBounds); } private void testStackBoundsConfiguration(Integer stackId, Rect parentBounds, Rect bounds, Rect expectedConfigBounds) { final StackWindowController stackController = stackId != null ? Loading @@ -140,4 +140,29 @@ public class AppBoundsTests extends WindowTestsBase { assertTrue((expectedConfigBounds == null && config.appBounds == null) || expectedConfigBounds.equals(config.appBounds)); } /** * Ensures appBounds are considered in {@link Configuration#compareTo(Configuration)}. */ @Test public void testConfigurationCompareTo() throws Exception { final Configuration blankConfig = new Configuration(); final Configuration config1 = new Configuration(); config1.appBounds = new Rect(1, 2, 3, 4); final Configuration config2 = new Configuration(config1); assertEquals(config1.compareTo(config2), 0); config2.appBounds.left = 0; // Different bounds assertNotEquals(config1.compareTo(config2), 0); // No bounds assertEquals(config1.compareTo(blankConfig), -1); assertEquals(blankConfig.compareTo(config1), 1); } } Loading
core/java/android/content/res/Configuration.java +18 −1 Original line number Diff line number Diff line Loading @@ -1672,6 +1672,23 @@ public final class Configuration implements Parcelable, Comparable<Configuration n = this.densityDpi - that.densityDpi; if (n != 0) return n; n = this.assetsSeq - that.assetsSeq; if (n != 0) return n; if (this.appBounds == null && that.appBounds != null) { return 1; } else if (this.appBounds != null && that.appBounds == null) { return -1; } else if (this.appBounds != null && that.appBounds != null) { n = this.appBounds.left - that.appBounds.left; if (n != 0) return n; n = this.appBounds.top - that.appBounds.top; if (n != 0) return n; n = this.appBounds.right - that.appBounds.right; if (n != 0) return n; n = this.appBounds.bottom - that.appBounds.bottom; if (n != 0) return n; } // if (n != 0) return n; return n; } Loading
services/tests/servicestests/src/com/android/server/wm/AppBoundsTests.java +26 −1 Original line number Diff line number Diff line Loading @@ -27,6 +27,7 @@ import android.support.test.filters.SmallTest; import android.support.test.runner.AndroidJUnit4; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotEquals; import static org.junit.Assert.assertTrue; /** Loading Loading @@ -121,7 +122,6 @@ public class AppBoundsTests extends WindowTestsBase { mParentBounds); } private void testStackBoundsConfiguration(Integer stackId, Rect parentBounds, Rect bounds, Rect expectedConfigBounds) { final StackWindowController stackController = stackId != null ? Loading @@ -140,4 +140,29 @@ public class AppBoundsTests extends WindowTestsBase { assertTrue((expectedConfigBounds == null && config.appBounds == null) || expectedConfigBounds.equals(config.appBounds)); } /** * Ensures appBounds are considered in {@link Configuration#compareTo(Configuration)}. */ @Test public void testConfigurationCompareTo() throws Exception { final Configuration blankConfig = new Configuration(); final Configuration config1 = new Configuration(); config1.appBounds = new Rect(1, 2, 3, 4); final Configuration config2 = new Configuration(config1); assertEquals(config1.compareTo(config2), 0); config2.appBounds.left = 0; // Different bounds assertNotEquals(config1.compareTo(config2), 0); // No bounds assertEquals(config1.compareTo(blankConfig), -1); assertEquals(blankConfig.compareTo(config1), 1); } }