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

Commit 09e73b3c authored by Mohammed Althaf T's avatar Mohammed Althaf T 😊
Browse files

AM: Fix sync always pending on Android 14+

parent 7ae22486
Loading
Loading
Loading
Loading
+4 −4
Original line number Diff line number Diff line
@@ -196,8 +196,8 @@ class SyncFrameworkIntegration @Inject constructor(
        // Android 14+ does not handle pending sync state correctly.
        // For now we simply always return false
        // See also sync cancellation in [SyncAdapterImpl.onPerformSync]
        if (Build.VERSION.SDK_INT >= 34)
            return flowOf(false)
        // if (Build.VERSION.SDK_INT >= 34)
        //     return flowOf(false)

        // Determine the pending state for each data type of the account as separate flows
        val pendingStateFlows: List<Flow<Boolean>> = dataTypes.mapNotNull { dataType ->
@@ -241,11 +241,11 @@ class SyncFrameworkIntegration @Inject constructor(
            val listener = ContentResolver.addStatusChangeListener(
                ContentResolver.SYNC_OBSERVER_TYPE_PENDING
            ) {
                trySend(anyPendingSync(accounts, authority))
                runCatching { trySend(anyPendingSync(accounts, authority)) }
            }

            // Emit initial value
            trySend(anyPendingSync(accounts, authority))
            runCatching { trySend(anyPendingSync(accounts, authority)) }

            // Clean up listener on close
            awaitClose { ContentResolver.removeStatusChangeListener(listener) }