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

Unverified Commit c85196ee authored by cketti's avatar cketti Committed by GitHub
Browse files

Merge pull request #5398 from k9mail/always_drop_wakelock

Fix Push keeping the device awake
parents ec1f3c37 d96641d7
Loading
Loading
Loading
Loading
+0 −3
Original line number Diff line number Diff line
@@ -44,7 +44,4 @@ internal interface ImapConnection {

    @Throws(SocketException::class)
    fun setSocketReadTimeout(timeout: Int)

    @Throws(IOException::class)
    fun isDataAvailable(): Boolean
}
+0 −5
Original line number Diff line number Diff line
@@ -910,11 +910,6 @@ class RealImapConnection implements ImapConnection {
        return isCondstoreCapable() ? LENGTH_LIMIT_WITH_CONDSTORE : LENGTH_LIMIT_WITHOUT_CONDSTORE;
    }

    @Override
    public boolean isDataAvailable() throws IOException {
        return inputStream.available() > 0;
    }

    @Override
    public int getConnectionGeneration() {
        return connectionGeneration;
+7 −14
Original line number Diff line number Diff line
@@ -95,26 +95,19 @@ internal class RealImapFolderIdler(

            var response: ImapResponse
            do {
                val expectSleeping = !connection.isDataAvailable() && !stopIdle
                idleRefreshTimer = idleRefreshManager.startTimer(
                    timeout = idleRefreshTimeoutProvider.idleRefreshTimeoutMs,
                    callback = ::idleRefresh
                )

                idleRefreshTimer = if (expectSleeping) {
                    idleRefreshManager.startTimer(idleRefreshTimeoutProvider.idleRefreshTimeoutMs) { idleRefresh() }
                } else {
                    null
                }

                if (expectSleeping) {
                wakeLock.release()
                }

                try {
                    response = connection.readResponse()
                } finally {
                    if (expectSleeping) {
                    wakeLock.acquire()
                    idleRefreshTimer?.cancel()
                }
                }

                if (response.isRelevant && !stopIdle) {
                    Timber.v("%s.idle(): Received a relevant untagged response during IDLE", logTag)
+0 −1
Original line number Diff line number Diff line
@@ -121,7 +121,6 @@ class RealImapFolderIdlerTest {
        wakeLock.waitForRelease()
        imapConnection.enqueueUntaggedServerResponse("1 EXISTS")
        imapConnection.waitForCommand("DONE")
        assertThat(wakeLock.isHeld).isTrue()
        imapConnection.enqueueTaggedServerResponse("OK")

        latch.awaitWithTimeout()
+0 −2
Original line number Diff line number Diff line
@@ -94,8 +94,6 @@ internal open class TestImapConnection(val timeout: Long, override val connectio
        currentSocketReadTimeout = timeout
    }

    override fun isDataAvailable(): Boolean = false

    fun waitForCommand(command: String) {
        do {
            val receivedCommand = receivedCommands.poll(timeout, TimeUnit.SECONDS) ?: throw AssertionError("Timeout")