mirror of https://github.com/ospab/ostp.git
fix(flutter/android): surface getMetrics failures into the in-app log
Traced the whole traffic-counter pipeline (Dart -> MethodChannel -> Kotlin -> JNI -> Bridge) end to end; it's architecturally identical to the working desktop implementation, so no code-level bug was found. Previously a getMetrics exception was only reported as a PlatformException that Dart swallows with a bare debugPrint, invisible in the in-app log viewer users actually have access to. Now it's also written to the native log buffer via OstpClientSdk.addLog, so if the counter breaks again the actual cause (exception vs. genuinely-zero atomics) shows up in View Logs instead of requiring adb.
This commit is contained in:
parent
223f02287a
commit
2092f6c716
|
|
@ -92,6 +92,13 @@ class MainActivity : FlutterActivity() {
|
||||||
val metrics = net.ostp.client.OstpClientSdk.getMetrics()
|
val metrics = net.ostp.client.OstpClientSdk.getMetrics()
|
||||||
result.success(metrics ?: "{}")
|
result.success(metrics ?: "{}")
|
||||||
} catch (e: Throwable) {
|
} catch (e: Throwable) {
|
||||||
|
// Surfaced into the in-app log viewer (not just logcat) so a
|
||||||
|
// broken traffic counter is diagnosable from a user's bug
|
||||||
|
// report without adb access.
|
||||||
|
android.util.Log.e("MainActivity", "getMetrics failed", e)
|
||||||
|
try {
|
||||||
|
net.ostp.client.OstpClientSdk.addLog("getMetrics failed: ${e.javaClass.simpleName}: ${e.message}")
|
||||||
|
} catch (_: Throwable) {}
|
||||||
result.error("ERROR", e.message, null)
|
result.error("ERROR", e.message, null)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue