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
28 changes: 28 additions & 0 deletions 404.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<meta name="robots" content="noindex" />
<meta name="theme-color" content="#1B5E20" />
<title>Page not found · Fern</title>
<style>
:root { --bg: #f6fbf4; --fg: #14291a; --muted: #4d6454; --accent: #1B5E20; }
@media (prefers-color-scheme: dark) { :root { --bg: #0f1a12; --fg: #e4f1e6; --muted: #9db4a2; --accent: #7fd18a; } }
* { box-sizing: border-box; }
body { margin: 0; min-height: 100vh; display: grid; place-items: center; padding: 24px; background: var(--bg); color: var(--fg); font: 16px/1.6 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; text-align: center; }
main { max-width: 440px; }
h1 { font-size: 64px; margin: 0; color: var(--accent); }
p { color: var(--muted); margin: 8px 0 24px; }
a { display: inline-block; padding: 12px 22px; border-radius: 999px; background: var(--accent); color: var(--bg); text-decoration: none; font-weight: 600; }
a:focus-visible { outline: 3px solid currentColor; outline-offset: 3px; }
</style>
</head>
<body>
<main>
<h1>404</h1>
<p>That page does not exist. Fern is still here, though.</p>
<a href="/">Back to Fern</a>
</main>
</body>
</html>
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,14 @@ All notable changes to Fern are listed here. Versions follow the Android `versio

## Unreleased

**Fixes**
* CSV and Markdown exports no longer change with the phone language (a decimal comma used to split CSV columns on German/Spanish devices)
* Device names containing `|` or line breaks no longer break the Markdown snapshot table

**Website & docs**
* Custom 404 page, security headers and asset caching (`vercel.json`)
* New `docs/TROUBLESHOOTING.md`

**Accessibility**
* Gauges, peak chips and spec rows are announced as one item by TalkBack (e.g. "CPU 42 percent, 8 cores") instead of separate fragments
* Decorative icons no longer read out "Decorative"
Expand Down
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,10 @@
Enable **Advanced mode** in Settings → grant Fern in [Shizuku](https://shizuku.rikka.app/) (or use root).
When connected: richer CPU sampling and per-app memory / CPU on Active apps.

## Troubleshooting

See [docs/TROUBLESHOOTING.md](docs/TROUBLESHOOTING.md).

## Privacy

No analytics SDK. Metrics stay on your device. Elevated access only runs what you enable.
Expand Down
36 changes: 22 additions & 14 deletions app/src/main/java/com/endroid/fern/monitor/HistoryExport.kt
Original file line number Diff line number Diff line change
@@ -1,10 +1,18 @@
package com.endroid.fern.monitor

import java.util.Locale

/**
* Build CSV / markdown for session metric history and live snapshots.
* Pure functions — safe for unit tests and UI share sheets.
*/
object HistoryExport {
/** Always US-style numbers: a decimal comma would split CSV columns on de/es/fr devices. */
private fun f(fmt: String, v: Number): String = String.format(Locale.US, fmt, v)

/** Keep a value inside one markdown table cell. */
private fun cell(v: String): String = v.replace("|", "\\|").replace("\n", " ").replace("\r", " ")

fun batteryCsv(samples: List<Float>, startEpochMs: Long = System.currentTimeMillis()): String {
val sb = StringBuilder()
sb.appendLine("index,epoch_ms,battery_percent")
Expand Down Expand Up @@ -33,9 +41,9 @@ object HistoryExport {
for (i in 0 until n) {
sb.append(i).append(',')
.append(startEpochMs + i.toLong() * intervalMs).append(',')
.append(cpu.getOrNull(i)?.let { "%.2f".format(it) } ?: "").append(',')
.append(ram.getOrNull(i)?.let { "%.2f".format(it) } ?: "").append(',')
.append(battery.getOrNull(i)?.let { "%.2f".format(it) } ?: "")
.append(cpu.getOrNull(i)?.let { f("%.2f", it) } ?: "").append(',')
.append(ram.getOrNull(i)?.let { f("%.2f", it) } ?: "").append(',')
.append(battery.getOrNull(i)?.let { f("%.2f", it) } ?: "")
.append('\n')
}
return sb.toString()
Expand Down Expand Up @@ -69,19 +77,19 @@ object HistoryExport {
appendLine()
appendLine("| Field | Value |")
appendLine("| --- | --- |")
appendLine("| Device | $deviceModel |")
appendLine("| Android | $androidVersion (API $sdkInt) |")
appendLine("| CPU | ${"%.1f".format(cpuPercent)}% · $cpuCores cores · $cpuHardware |")
appendLine("| RAM | $ramUsedMb / $ramTotalMb MB (${"%.1f".format(ramPercent)}%) |")
appendLine("| Device | ${cell(deviceModel)} |")
appendLine("| Android | ${cell(androidVersion)} (API $sdkInt) |")
appendLine("| CPU | ${f("%.1f", cpuPercent)}% · $cpuCores cores · ${cell(cpuHardware)} |")
appendLine("| RAM | $ramUsedMb / $ramTotalMb MB (${f("%.1f", ramPercent)}%) |")
appendLine(
"| Battery | $batteryPercent% · ${if (batteryCharging) "charging" else "discharging"} · $batteryHealth |"
"| Battery | $batteryPercent% · ${if (batteryCharging) "charging" else "discharging"} · ${cell(batteryHealth)} |"
)
batteryTempC?.let { appendLine("| Battery temp | ${"%.1f".format(it)}°C |") }
appendLine("| Thermal | $thermalLabel |")
appendLine("| Network | $networkLabel · ${"%.1f".format(networkKBps)} KB/s |")
appendLine("| Uptime | ${"%.1f".format(uptimeHours)} h |")
appendLine("| Session peak CPU / RAM | ${"%.1f".format(peakCpu)}% / ${"%.1f".format(peakRam)}% |")
appendLine("| Session avg CPU / RAM | ${"%.1f".format(avgCpu)}% / ${"%.1f".format(avgRam)}% |")
batteryTempC?.let { appendLine("| Battery temp | ${f("%.1f", it)}°C |") }
appendLine("| Thermal | ${cell(thermalLabel)} |")
appendLine("| Network | ${cell(networkLabel)} · ${f("%.1f", networkKBps)} KB/s |")
appendLine("| Uptime | ${f("%.1f", uptimeHours)} h |")
appendLine("| Session peak CPU / RAM | ${f("%.1f", peakCpu)}% / ${f("%.1f", peakRam)}% |")
appendLine("| Session avg CPU / RAM | ${f("%.1f", avgCpu)}% / ${f("%.1f", avgRam)}% |")
appendLine()
appendLine("_Exported offline from Fern. No account required._")
}
Expand Down
50 changes: 50 additions & 0 deletions app/src/test/java/com/endroid/fern/HistoryExportLocaleTest.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
package com.endroid.fern

import com.endroid.fern.monitor.HistoryExport
import org.junit.Assert.assertEquals
import org.junit.Assert.assertFalse
import org.junit.Assert.assertTrue
import org.junit.Test
import java.util.Locale

/** Exports must not change with the device language (a decimal comma would split CSV columns). */
class HistoryExportLocaleTest {

private fun <T> withLocale(l: Locale, block: () -> T): T {
val old = Locale.getDefault()
Locale.setDefault(l)
try { return block() } finally { Locale.setDefault(old) }
}

@Test
fun sessionCsvUsesDotDecimalsInGerman() {
val csv = withLocale(Locale.GERMANY) {
HistoryExport.sessionCsv(listOf(10.5f), listOf(30.25f), listOf(90f), 1000, 0L)
}
val row = csv.lines()[1]
assertEquals("0,0,10.50,30.25,90.00", row)
assertEquals(5, row.split(',').size)
}

@Test
fun markdownUsesDotDecimalsInSpanish() {
val md = withLocale(Locale("es", "ES")) { snapshot("Pixel") }
assertTrue(md.contains("12.5%"))
assertFalse(md.contains("12,5%"))
}

@Test
fun markdownEscapesPipesInTextFields() {
val md = snapshot("Model | X\nline2")
assertTrue(md.contains("| Device | Model \\| X line2 |"))
}

private fun snapshot(model: String) = HistoryExport.snapshotMarkdown(
deviceModel = model, androidVersion = "14", sdkInt = 34,
cpuPercent = 12.5f, cpuCores = 8, cpuHardware = "tensor",
ramUsedMb = 4000, ramTotalMb = 8000, ramPercent = 50f,
batteryPercent = 80, batteryCharging = false, batteryHealth = "Good", batteryTempC = 31.2f,
thermalLabel = "None", networkLabel = "Wi-Fi", networkKBps = 12f,
uptimeHours = 3.5f, peakCpu = 40f, peakRam = 60f, avgCpu = 15f, avgRam = 45f,
)
}
22 changes: 22 additions & 0 deletions docs/TROUBLESHOOTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# Troubleshooting

## Per-app CPU / RAM is empty on Active apps
Per-app numbers need elevated access. Turn on **Advanced mode** in Settings, then grant Fern in [Shizuku](https://shizuku.rikka.app/) (or allow root). Without it Android only shows Fern what a normal app may see.

## Shizuku says Fern is not authorised
Open Shizuku, make sure it is running (restart it after a reboot unless you use root or wireless debugging auto-start), then open Fern and grant the permission again.

## The overlay does not appear
The overlay needs the "Display over other apps" permission. Enable it for Fern in system settings, then switch the overlay on again in Fern.

## Readings stop when the screen is off
Some vendors stop background work aggressively. Set Fern's battery usage to "Unrestricted" (wording varies by device) if you want continuous history.

## CPU shows a different value than another monitor
Fern samples the whole device from kernel counters over a short window. Other apps may use a different interval or exclude some cores, so small differences are normal.

## Exported CSV opens in one column
Fern writes comma-separated values with dot decimals. In your spreadsheet, choose "Comma" as the separator when importing.

## Still stuck?
Open an issue with your device model, Android version, and whether Advanced mode is on: https://github.com/wized2/Fern/issues/new/choose
17 changes: 17 additions & 0 deletions vercel.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"headers": [
{
"source": "/(.*)",
"headers": [
{ "key": "X-Content-Type-Options", "value": "nosniff" },
{ "key": "Referrer-Policy", "value": "strict-origin-when-cross-origin" },
{ "key": "X-Frame-Options", "value": "DENY" },
{ "key": "Permissions-Policy", "value": "camera=(), microphone=(), geolocation=()" }
]
},
{
"source": "/assets/(.*)",
"headers": [{ "key": "Cache-Control", "value": "public, max-age=604800" }]
}
]
}
Loading