Loading core/java/android/content/res/Configuration.java +2 −2 Original line number Diff line number Diff line Loading @@ -1974,10 +1974,10 @@ public final class Configuration implements Parcelable, Comparable<Configuration return true; } int diff = other.seq - seq; if (diff > 0x10000) { if (Math.abs(diff) > 0x10000000) { // If there has been a sufficiently large jump, assume the // sequence has wrapped around. return false; return diff < 0; } return diff > 0; } Loading core/tests/coretests/src/android/content/res/ConfigurationTest.java +16 −0 Original line number Diff line number Diff line Loading @@ -157,6 +157,22 @@ public class ConfigurationTest extends TestCase { assertFalse(config.isNightModeActive()); } @Test public void testSequenceNumberWrapAround() { Configuration config = new Configuration(); Configuration otherConfig = new Configuration(); // Verify the other configuration is not newer when this sequence number warp around. config.seq = 1000; otherConfig.seq = Integer.MAX_VALUE - 1000; assertFalse(config.isOtherSeqNewer(otherConfig)); // Verify the other configuration is newer when the other sequence number warp around. config.seq = Integer.MAX_VALUE - 1000; otherConfig.seq = 1000; assertTrue(config.isOtherSeqNewer(otherConfig)); } private void dumpDebug(File f, Configuration config) throws Exception { final AtomicFile af = new AtomicFile(f); FileOutputStream fos = af.startWrite(); Loading Loading
core/java/android/content/res/Configuration.java +2 −2 Original line number Diff line number Diff line Loading @@ -1974,10 +1974,10 @@ public final class Configuration implements Parcelable, Comparable<Configuration return true; } int diff = other.seq - seq; if (diff > 0x10000) { if (Math.abs(diff) > 0x10000000) { // If there has been a sufficiently large jump, assume the // sequence has wrapped around. return false; return diff < 0; } return diff > 0; } Loading
core/tests/coretests/src/android/content/res/ConfigurationTest.java +16 −0 Original line number Diff line number Diff line Loading @@ -157,6 +157,22 @@ public class ConfigurationTest extends TestCase { assertFalse(config.isNightModeActive()); } @Test public void testSequenceNumberWrapAround() { Configuration config = new Configuration(); Configuration otherConfig = new Configuration(); // Verify the other configuration is not newer when this sequence number warp around. config.seq = 1000; otherConfig.seq = Integer.MAX_VALUE - 1000; assertFalse(config.isOtherSeqNewer(otherConfig)); // Verify the other configuration is newer when the other sequence number warp around. config.seq = Integer.MAX_VALUE - 1000; otherConfig.seq = 1000; assertTrue(config.isOtherSeqNewer(otherConfig)); } private void dumpDebug(File f, Configuration config) throws Exception { final AtomicFile af = new AtomicFile(f); FileOutputStream fos = af.startWrite(); Loading