Merge remote-tracking branch 'origin/main' into review/malibridge-1950

This commit is contained in:
Kurt Himebauch committed 2026-11-02 18:14:00 -05:00
commit f05e0df39e
135 files changed
+5415 -979

No files matched your search

@@ -199,11 +199,15 @@ class DroidDeckHudHost(context: Context) {
metrics.snapshot()
Thread.sleep(500)
val mango = metrics.snapshot()
fun shown(value: Any?, unit: String) = if (value == null) "none" else "$value$unit"
val readers = com.droiddeck.launcher.session.GpuStatsComponent.readerStatus()
file.writeText(metrics.also { it.setMangoReadings(null) }.buildDiagnosticsReport(context) + "\n== As the HUD shows them (MangoHud's sources) ==\n" +
"CPU ${mango.cpuPercent}% ${mango.cpuTempC}°C, GPU ${mango.gpuPercent}% ${mango.gpuClockMhz}MHz ${mango.gpuTempC}°C, " +
"CPU ${shown(mango.cpuPercent, "%")} ${shown(mango.cpuTempC, "°C")}, GPU ${shown(mango.gpuPercent, "%")} " +
"${shown(mango.gpuClockMhz, "MHz")} ${shown(mango.gpuTempC, "°C")}, " +
"RAM ${mango.ramUsedText()}/${mango.ramTotalText()}, VRAM ${mango.vramText()}, battery ${mango.battery.percent}% " +
"${mango.battery.watts}W charging=${mango.battery.charging}\n" +
"GPU feeds: ${com.droiddeck.launcher.session.GpuStatsComponent.sources.ifEmpty { "none (no session, or kgsl absent)" }}\n" +
(if (readers.isNotEmpty()) "GPU readers without root: $readers\n" else "") +
"CPU temperature zones: ${LinuxRuntime.cpuTempZones().joinToString { it.name }}\n" +
"Frames: ${if (feed.engine.isNotEmpty() || feed.pid > 0) "gamescope (pid ${feed.pid}, ${feed.engine})" else "compositor"}, " +
"fps ${feed.stats.fps}\n")
@@ -125,6 +125,7 @@ class DroidDeckHudView(context: Context) : View(context) {
private var accent = 0xFF1A9FFF.toInt()
private var surfaceRgb = 0x121417
private var headerMark: RectF? = null
private var headerWordmark: RectF? = null
private var chipRect: RectF? = null
var dock = DroidDeckHudDock.NONE
@@ -167,12 +168,9 @@ class DroidDeckHudView(context: Context) : View(context) {
color = colGraph
}
private val headerPaint = Paint(Paint.ANTI_ALIAS_FLAG).apply { style = Paint.Style.FILL }
private val wordmarkPaint = Paint(Paint.ANTI_ALIAS_FLAG).apply {
typeface = Typeface.create(Typeface.SANS_SERIF, Typeface.BOLD)
}
private class Glyph(val x: Float, val baseline: Float, val text: String, val color: Int, val sizePx: Float, val sans: Boolean = false, val glow: Boolean = false) {
fun moved(dx: Float, dy: Float) = Glyph(x + dx, baseline + dy, text, color, sizePx, sans, glow)
private class Glyph(val x: Float, val baseline: Float, val text: String, val color: Int, val sizePx: Float, val glow: Boolean = false) {
fun moved(dx: Float, dy: Float) = Glyph(x + dx, baseline + dy, text, color, sizePx, glow)
}
private class Span(val text: String, val color: Int, val sizePx: Float, val glow: Boolean = false)
private class HudRow(val label: Span, val vals: List<Span>, val inline: Boolean = false)
@@ -523,7 +521,7 @@ class DroidDeckHudView(context: Context) : View(context) {
private fun rebuild() {
glyphs.clear(); tileRects.clear(); graphRect = null
headerMark = null; chipRect = null; dPanel = null; dDividerTop = -1f; tabRect = null; stripRect = null
headerMark = null; headerWordmark = null; chipRect = null; dPanel = null; dDividerTop = -1f; tabRect = null; stripRect = null
val s = snap
if (s == null) { contentW = 0f; contentH = 0f; return }
if (dock != DroidDeckHudDock.NONE) { buildDockTab(); return }
@@ -576,24 +574,18 @@ class DroidDeckHudView(context: Context) : View(context) {
private fun footerClock(): Boolean = showClockTime && size == DroidDeckHudSize.PILL
private fun measureSans(text: String, sizePx: Float): Float { wordmarkPaint.textSize = sizePx; return wordmarkPaint.measureText(text) }
private fun panelInset() = sp(8f)
private fun panelLeft() = sp(13f)
private fun contentLeft() = panelLeft() + sp(16f)
private fun addPanelHeader(left: Float, inner: Float): Pair<Float, Float> {
val wordPx = sp(10f); val clockPx = sp(9.5f); val gapH = sp(7f)
wordmarkPaint.textSize = wordPx
val markH = wordmarkPaint.fontMetrics.let { it.descent - it.ascent } * 0.95f
val clockPx = sp(9.5f); val gapH = sp(7f)
val wordH = sp(12f)
val markTop = inner + gapH
val markLeft = left - DroidDeckMark.inkLeftFor(markH)
headerMark = RectF(markLeft, markTop, markLeft + DroidDeckMark.widthFor(markH), markTop + markH)
val midY = markTop + markH / 2f
var x = markLeft + DroidDeckMark.inkRightFor(markH) + sp(6f)
wordmarkPaint.getTextBounds("DroidDeck", 0, 9, inkRect)
glyphs.add(Glyph(x, midY - inkRect.exactCenterY(), "DroidDeck", blend(colValue), wordPx, sans = true))
x += measureSans("DroidDeck", wordPx)
val wordW = WordmarkArt.widthFor(wordH)
headerWordmark = RectF(left, markTop, left + wordW, markTop + wordH)
val midY = markTop + wordH / 2f
var x = left + wordW
if (showClockTime) {
measurePaint.textSize = clockPx
measurePaint.getTextBounds("0", 0, 1, inkRect)
@@ -605,7 +597,7 @@ class DroidDeckHudView(context: Context) : View(context) {
glyphs.add(Glyph(x, base, t, blend(colDim), clockPx))
x += measure(t, clockPx)
}
dDividerTop = markTop + markH + gapH
dDividerTop = markTop + wordH + gapH
return Pair(dDividerTop + max(1f, density), x)
}
@@ -647,7 +639,7 @@ class DroidDeckHudView(context: Context) : View(context) {
}
var right = panel.right
for (g in glyphs) {
val paint = if (g.sans) wordmarkPaint else measurePaint
val paint = measurePaint
paint.textSize = g.sizePx
paint.getTextBounds(g.text, 0, g.text.length, inkRect)
if (inkRect.isEmpty) continue
@@ -1323,7 +1315,7 @@ class DroidDeckHudView(context: Context) : View(context) {
stripRect?.let { drawStrip(canvas, it) }
for (g in glyphs) {
val paint = if (g.sans) wordmarkPaint else drawPaint
val paint = drawPaint
paint.textSize = g.sizePx
paint.color = g.color
if (g.glow) paint.setShadowLayer(sp(6f), 0f, 0f, withAlpha(colGraph, 217))
@@ -1331,6 +1323,7 @@ class DroidDeckHudView(context: Context) : View(context) {
if (g.glow) paint.clearShadowLayer()
}
headerMark?.let { DroidDeckMark.draw(canvas, it.left, it.top, it.height(), blend(colValue), accent) }
headerWordmark?.let { WordmarkArt.draw(canvas, it.left, it.top, it.height(), blend(colValue), accent) }
graphRect?.let { drawGraph(canvas, it) }
@@ -1420,10 +1413,6 @@ class DroidDeckHudView(context: Context) : View(context) {
headerPaint.color = withAlpha(accent, 90)
c.drawRect(panel.left, dDividerTop, roundEdgeX(panel, dDividerTop, stroke), dividerBottom, headerPaint)
}
val halfRound = dRadius >= panel.height() / 2f - 0.5f
val wmH = if (halfRound) panel.height() * 0.92f else min(panel.height(), panel.width()) * 0.55f
DroidDeckMark.draw(c, panel.right - DroidDeckMark.widthFor(wmH) - (if (halfRound) panel.height() * 0.02f else sp(10f)),
panel.centerY() - wmH / 2f, wmH, Color.argb(20, 255, 255, 255), withAlpha(accent, 20))
c.restore()
if (stroke > 0f) {
val h = stroke / 2f
@@ -1487,10 +1476,10 @@ class DroidDeckHudView(context: Context) : View(context) {
internal val isDragging: Boolean get() = lockController.isDragging() || tabDragging
private companion object {
const val TAB_NUM_SP = 10f
const val TAB_LABEL_SP = 6f
const val TAB_PAD_X_SP = 5f
const val TAB_PAD_Y_SP = 4f
const val TAB_NUM_SP = 15f
const val TAB_LABEL_SP = 7.25f
const val TAB_PAD_X_SP = 7f
const val TAB_PAD_Y_SP = 5.5f
const val REFRESH_MS = 500L
private const val HUE_IDLE_MS = 500L
const val MIN_SCALE = 0.5f
@@ -870,6 +870,9 @@ public class HudMetrics {
private long[] lastCoreTotal = null;
private long[] lastCoreIdle = null;
private static final int PER_CORE_STAT = 1, PER_CORE_ESTIMATE = 2;
/** Sources of the last per-core reading: PER_CORE_STAT and/or PER_CORE_ESTIMATE (clock speed); 0 when no core was read. */
private volatile int perCoreSources = 0;
public int[] readPerCorePercent() {
int cores = Runtime.getRuntime().availableProcessors();
@@ -909,13 +912,20 @@ public class HudMetrics {
}
}
} catch (Exception ignored) {}
int sources = 0;
for (int i = 0; i < out.length; i++) {
if (out[i] >= 0) continue;
if (out[i] >= 0) {
sources |= PER_CORE_STAT;
continue;
}
Long cur = readLongFromLine("/sys/devices/system/cpu/cpu" + i + "/cpufreq/scaling_cur_freq");
Long max = readLongFromLine("/sys/devices/system/cpu/cpu" + i + "/cpufreq/cpuinfo_max_freq");
if (cur != null && max != null && max > 0L)
if (cur != null && max != null && max > 0L) {
out[i] = clampPercent((int) ((Math.max(0L, Math.min(cur, max)) * 100L) / max));
sources |= PER_CORE_ESTIMATE;
}
}
perCoreSources = sources;
return out;
}
@@ -1008,10 +1018,13 @@ public class HudMetrics {
int v = s.perCorePercent[i];
cores.append('c').append(i).append('=').append(v < 0 ? "?" : (v + "%"));
}
if (s.perCorePercent.length > 0)
metricHit(sb, "Per-core %", cores.toString(), "/proc/stat (per-cpu lines)");
int coreSources = perCoreSources;
if (s.perCorePercent.length > 0 && coreSources != 0)
metricHit(sb, "Per-core %", cores.toString(), coreSources == PER_CORE_STAT ? "/proc/stat (per-cpu lines)"
: coreSources == PER_CORE_ESTIMATE ? "scaling_cur_freq / cpuinfo_max_freq (clock estimate)"
: "/proc/stat (per-cpu lines); scaling_cur_freq / cpuinfo_max_freq (clock estimate) for the other cores");
else
metricMiss(sb, "Per-core %", "/proc/stat");
metricMiss(sb, "Per-core %", "/proc/stat", "/sys/devices/system/cpu/cpu*/cpufreq/scaling_cur_freq");
StringBuilder coreClk = new StringBuilder();
for (int i = 0; i < s.perCoreClockMhz.length; i++) {
@@ -0,0 +1,54 @@
package com.droiddeck.launcher.hud
import android.graphics.Canvas
import android.graphics.Paint
import android.graphics.Path
import androidx.compose.ui.graphics.asAndroidPath
import androidx.compose.ui.graphics.vector.PathParser
internal object WordmarkArt {
const val BOX_X = 239.135f
const val BOX_Y = 120.02f
const val BOX_W = 1040.7f - 239.135f
const val BOX_H = 243.2f - 120.02f
const val MARK_SCALE = 0.527445f
const val LEFT_HALF = "M-31.98 0H56.055V40.489A71.81 71.81 0 0 0 56.055 183.231V223.72H-31.98Z"
const val RIGHT_HALF = "M71.885 0.28A111.86 111.86 0 0 1 71.885 223.44V183.234A71.81 71.81 0 0 0 71.885 40.486Z"
const val LETTERS =
"M361.45 241.36V160.13H387.02V241.36ZM387.02 196.73 376.32 188.38Q379.5 174.17 387.02 166.31Q394.54 158.46 407.91 158.46Q413.76 158.46 418.19 160.21Q422.62 161.97 425.96 165.65L410.75 184.87Q409.08 183.03 406.57 182.03Q404.07 181.02 400.89 181.02Q394.54 181.02 390.78 184.95Q387.02 188.88 387.02 196.73" +
"ZM467.91 243.2Q455.38 243.2 445.27 237.6Q435.15 232 429.3 222.31Q423.45 212.61 423.45 200.58Q423.45 188.54 429.3 179.02Q435.15 169.49 445.18 163.89Q455.21 158.29 467.91 158.29Q480.62 158.29 490.64 163.81Q500.67 169.32 506.52 178.93Q512.37 188.54 512.37 200.58Q512.37 212.61 506.52 222.31Q500.67 232 490.64 237.6Q480.62 243.2 467.91 243.2" +
"ZM467.91 219.97Q473.43 219.97 477.61 217.54Q481.79 215.12 484.04 210.69Q486.3 206.26 486.3 200.58Q486.3 194.9 483.96 190.63Q481.62 186.37 477.52 183.95Q473.43 181.52 467.91 181.52Q462.56 181.52 458.39 183.95Q454.21 186.37 451.87 190.72Q449.53 195.06 449.53 200.75Q449.53 206.26 451.87 210.69Q454.21 215.12 458.39 217.54Q462.56 219.97 467.91 219.97" +
"ZM523.4 241.36V160.13H548.98V241.36ZM536.27 148.93Q530.26 148.93 526.33 144.84Q522.4 140.74 522.4 134.89Q522.4 128.88 526.33 124.86Q530.26 120.85 536.27 120.85Q542.29 120.85 546.13 124.86Q549.98 128.88 549.98 134.89Q549.98 140.74 546.13 144.84Q542.29 148.93 536.27 148.93ZM599.95 243.03Q588.42 243.03 579.48 237.52Q570.54 232 565.44 222.47Q560.34 212.95 560.34 200.75Q560.34 188.54 565.44 179.02Q570.54 169.49 579.48 163.97Q588.42 158.46 599.95 158.46Q608.31 158.46 615.08 161.63Q621.85 164.81 626.28 170.41Q630.71 176.01 631.21 183.2V217.46Q630.71 224.65 626.36 230.41Q622.02 236.18 615.16 239.61Q608.31 243.03 599.95 243.03" +
"ZM604.47 219.97Q609.98 219.97 613.99 217.54Q618 215.12 620.34 210.77Q622.68 206.43 622.68 200.75Q622.68 195.06 620.43 190.8Q618.17 186.54 614.08 184.03Q609.98 181.52 604.63 181.52Q599.28 181.52 595.19 184.03Q591.09 186.54 588.67 190.88Q586.25 195.23 586.25 200.75Q586.25 206.26 588.59 210.61Q590.93 214.95 595.11 217.46Q599.28 219.97 604.47 219.97" +
"ZM646.75 241.36H621.68V219.46L625.53 199.74L621.18 180.02V120.02H646.75ZM683.19 241.36V218.29H712.44Q723.13 218.29 731.16 214.03Q739.18 209.77 743.53 201.58Q747.87 193.39 747.87 182.19Q747.87 170.99 743.44 162.97Q739.01 154.95 731.07 150.6Q723.13 146.26 712.44 146.26H682.35V123.36H712.77Q726.14 123.36 737.42 127.62Q748.71 131.88 757.15 139.82Q765.59 147.76 770.18 158.54Q774.78 169.32 774.78 182.36Q774.78 195.23 770.18 206.09Q765.59 216.96 757.23 224.81Q748.87 232.67 737.59 237.01Q726.31 241.36 713.11 241.36" +
"ZM665.47 241.36V123.36H691.71V241.36ZM827.6 243.2Q814.39 243.2 804.11 237.77Q793.83 232.33 787.98 222.64Q782.13 212.95 782.13 200.75Q782.13 188.54 787.9 178.93Q793.67 169.32 803.53 163.81Q813.39 158.29 825.76 158.29Q837.79 158.29 846.98 163.47Q856.18 168.65 861.44 177.85Q866.71 187.04 866.71 198.91Q866.71 201.08 866.46 203.5Q866.21 205.93 865.54 209.1L795.51 209.27V191.72L854.67 191.55L843.64 198.91Q843.47 191.89 841.47 187.29Q839.46 182.69 835.54 180.27Q831.61 177.85 825.92 177.85Q819.91 177.85 815.48 180.61Q811.05 183.36 808.63 188.38Q806.2 193.39 806.2 200.58Q806.2 207.77 808.79 212.86Q811.38 217.96 816.15 220.72Q820.91 223.48 827.43 223.48Q833.45 223.48 838.29 221.39Q843.14 219.3 846.82 215.12L860.86 229.16Q854.84 236.18 846.32 239.69Q837.79 243.2 827.6 243.2" +
"ZM916.68 243.2Q904.15 243.2 893.95 237.68Q883.75 232.17 877.9 222.47Q872.05 212.78 872.05 200.75Q872.05 188.54 877.99 178.93Q883.92 169.32 894.12 163.81Q904.31 158.29 917.02 158.29Q926.54 158.29 934.48 161.55Q942.42 164.81 948.6 171.33L932.22 187.71Q929.38 184.53 925.62 183.03Q921.86 181.52 917.02 181.52Q911.5 181.52 907.24 183.95Q902.98 186.37 900.55 190.63Q898.13 194.9 898.13 200.58Q898.13 206.26 900.55 210.61Q902.98 214.95 907.32 217.46Q911.67 219.97 917.02 219.97Q922.03 219.97 925.96 218.21Q929.88 216.46 932.73 213.28L948.94 229.66Q942.59 236.35 934.56 239.77Q926.54 243.2 916.68 243.2" +
"ZM1010.61 241.36 982.2 199.24 1010.45 160.13H1039.03L1004.93 204.09L1005.77 193.56L1040.7 241.36ZM958.63 241.36V120.02H984.21V241.36Z"
private fun parse(d: String): Path = PathParser().parsePathString(d).toPath().asAndroidPath()
private val letters by lazy { parse(LETTERS) }
private val leftHalf by lazy { parse(LEFT_HALF) }
private val rightHalf by lazy { parse(RIGHT_HALF) }
private val paint = Paint(Paint.ANTI_ALIAS_FLAG).apply { style = Paint.Style.FILL }
fun widthFor(height: Float): Float = height * BOX_W / BOX_H
fun draw(canvas: Canvas, left: Float, top: Float, height: Float, inkColor: Int, ballColor: Int) {
val k = height / BOX_H
canvas.save()
canvas.translate(left, top)
canvas.scale(k, k)
canvas.translate(-BOX_X, -BOX_Y)
paint.color = inkColor
canvas.drawPath(letters, paint)
canvas.translate(239.135f, 123.36f)
canvas.scale(MARK_SCALE, MARK_SCALE)
canvas.translate(31.98f, 0f)
canvas.drawPath(leftHalf, paint)
canvas.drawPath(rightHalf, paint)
paint.color = ballColor
canvas.drawCircle(63.98f, 111.86f, 55.98f, paint)
canvas.restore()
}
}