Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit f9c6e7b7 authored by Louis Chang's avatar Louis Chang Committed by Android (Google) Code Review
Browse files

Merge "Avoid configuration not updated after reasonable configuration changes"

parents 047d0ea6 baec1d5c
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -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;
    }
+16 −0
Original line number Diff line number Diff line
@@ -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();