Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -1468,6 +1468,37 @@ fun XServerScreen(
}
}

DisposableEffect(lifecycleOwner, performanceHudView) {
val hud = performanceHudView
if (hud != null) {
if (lifecycleOwner.lifecycle.currentState.isAtLeast(Lifecycle.State.RESUMED)) {
hud.resume()
} else {
hud.pause()
}

val observer = LifecycleEventObserver { _, event ->
when (event) {
Lifecycle.Event.ON_PAUSE -> {
Timber.d("Pausing PerformanceHudView for lifecycle event: $event")
hud.pause()
}
Lifecycle.Event.ON_RESUME -> {
Timber.d("Resuming PerformanceHudView for lifecycle event: $event")
hud.resume()
}
else -> Unit
}
}
lifecycleOwner.lifecycle.addObserver(observer)
Comment thread
cubic-dev-ai[bot] marked this conversation as resolved.
onDispose {
lifecycleOwner.lifecycle.removeObserver(observer)
}
} else {
onDispose { }
}
}
Comment thread
coderabbitai[bot] marked this conversation as resolved.

val isPortrait = container.isPortraitMode
// var launchedView by rememberSaveable { mutableStateOf(false) }
Box(modifier = Modifier.fillMaxSize()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ class PerformanceHudView(
private var attachedMetricSignature: List<MetricSignature> = emptyList()
private var appearance = appearanceFor(initialConfig.size)
private var smoothedBatteryRuntimeHours: Double? = null
private var isPaused = false

private val backgroundDrawable = GradientDrawable().apply {
shape = GradientDrawable.RECTANGLE
Expand Down Expand Up @@ -166,9 +167,27 @@ class PerformanceHudView(
refreshVisibleMetrics()
}

fun pause() {
if (!isPaused) {
isPaused = true
stopUpdates()
}
}

fun resume() {
if (isPaused) {
isPaused = false
if (isAttachedToWindow) {
startUpdates()
}
}
}

override fun onAttachedToWindow() {
super.onAttachedToWindow()
startUpdates()
if (!isPaused) {
startUpdates()
}
}

override fun onDetachedFromWindow() {
Expand Down Expand Up @@ -678,7 +697,7 @@ class PerformanceHudView(
discoverPrioritizedCpuTempPaths(),
)
if (reading != null) {
Timber.v("[HUD] CPU temp: %d°C from %s", reading.celsius, reading.source)
Timber.d("[HUD] CPU temp: %d°C from %s", reading.celsius, reading.source)
}
return reading?.celsius
}
Expand All @@ -690,7 +709,7 @@ class PerformanceHudView(
) + discoverPrioritizedGpuTempPaths()
val reading = readTemperatureCWithSource(paths)
if (reading != null) {
Timber.v("[HUD] GPU temp: %d°C from %s", reading.celsius, reading.source)
Timber.d("[HUD] GPU temp: %d°C from %s", reading.celsius, reading.source)
}
return reading?.celsius
}
Expand Down
Loading