From 430e77178e95146452816cf287b4d7c9345fe5f1 Mon Sep 17 00:00:00 2001 From: ovurrsl Date: Sat, 17 Oct 2026 06:35:50 +0300 Subject: [PATCH] fix: one refused thermal or power query no longer drops the others from the session report Thermal status, thermal headroom and power saver are now read one by one, so a vendor that throws on one of them still gets the other two lines, and the refused one shows as unknown. --- .../com/droiddeck/launcher/core/DeviceReport.kt | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/app/src/main/java/com/droiddeck/launcher/core/DeviceReport.kt b/app/src/main/java/com/droiddeck/launcher/core/DeviceReport.kt index 903851a5a..f10eeb1c1 100644 --- a/app/src/main/java/com/droiddeck/launcher/core/DeviceReport.kt +++ b/app/src/main/java/com/droiddeck/launcher/core/DeviceReport.kt @@ -152,13 +152,17 @@ object DeviceReport { k("RAM total", FileUtils.sizeToString(mi.totalMem)) k("RAM available", FileUtils.sizeToString(mi.availMem)) } - runCatching { - val pm = context.getSystemService(Context.POWER_SERVICE) as PowerManager - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) k("Thermal status", thermalStatusName(pm.currentThermalStatus)) - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) { - k("Thermal headroom (10 s)", pm.getThermalHeadroom(10).let { if (it.isNaN()) "not reported" else String.format(Locale.US, "%.2f", it) }) + val pm = runCatching { context.getSystemService(Context.POWER_SERVICE) as? PowerManager }.getOrNull() + if (pm != null) { + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) { + k("Thermal status", runCatching { thermalStatusName(pm.currentThermalStatus) }.getOrNull()) } - k("Power saver", pm.isPowerSaveMode) + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) { + k("Thermal headroom (10 s)", runCatching { + pm.getThermalHeadroom(10).let { if (it.isNaN()) "not reported" else String.format(Locale.US, "%.2f", it) } + }.getOrNull()) + } + k("Power saver", runCatching { pm.isPowerSaveMode }.getOrNull()) } if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) { val rate = runCatching { context.getSystemService(PerformanceHintManager::class.java)?.preferredUpdateRateNanos }.getOrNull()