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

Commit cd354d3f authored by William Xiao's avatar William Xiao
Browse files

Only log smartspace timers when value changes

The value is logged every time the device locks as communal gets ready,
so only log when the value changes to avoid spamming the buffer with
empty list logs when there are no timers.

Bug: N/A
Test: N/A, verified locally via logcat
Flag: NONE small logging change
Change-Id: Ic3cbce5652d8f31123618e5df32694dff10c41c0
parent 9637b6d9
Loading
Loading
Loading
Loading
+20 −13
Original line number Diff line number Diff line
@@ -82,19 +82,26 @@ constructor(
            }

        _timers.value =
            timerTargets.map { (stableId, target) ->
            timerTargets
                .map { (stableId, target) ->
                    CommunalSmartspaceTimer(
                    // The view layer should have the instance based smartspaceTargetId instead of
                    // stable id, so that when a new instance of the timer is created, for example,
                    // when it is paused, the view should re-render its remote views.
                        // The view layer should have the instance based smartspaceTargetId instead
                        // of stable id, so that when a new instance of the timer is created, for
                        // example, when it is paused, the view should re-render its remote views.
                        smartspaceTargetId =
                            if (communalTimerFlickerFix()) stableId else target.smartspaceTargetId,
                        createdTimestampMillis = targetCreationTimes[stableId]!!,
                        remoteViews = target.remoteViews!!,
                    )
                }

        logger.d({ "Smartspace timers updated: $str1" }) { str1 = _timers.value.toString() }
                .also { newVal ->
                    // Only log when value changes to avoid filling up the buffer.
                    if (newVal != _timers.value) {
                        logger.d({ "Smartspace timers updated: $str1" }) {
                            str1 = newVal.toString()
                        }
                    }
                }
    }

    override fun startListening() {