android: DiagLog thread-safe timestamps; auto-connect survives stop/start

- SimpleDateFormat is now used under the lock; rotation counts bytes
- AutoConnectManager.stop() clears pendingEvaluate, whose reset runnable
  it removes, so later connects are not silently swallowed

Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
DenozordecandClaude Opus 5.5 committed 2026-10-10 09:09:40 +07:00
1 parent 01c398f2f7
commit e6c893219c
2 files changed
+6 -2

No files matched your search

@@ -62,9 +62,10 @@ object DiagLog
val base = dir ?: return
try
{
val line = "${format.format(Date())} $tag: $message\n"
synchronized(this)
{
/* SimpleDateFormat is not thread-safe: format under the lock */
val line = "${format.format(Date())} $tag: $message\n"
if (written > MAX_SIZE)
{
rotate(base)
@@ -79,7 +80,7 @@ object DiagLog
}
w.write(line)
w.flush()
written += line.length + 1
written += line.toByteArray(Charsets.UTF_8).size
}
}
catch (_: Exception)
@@ -145,6 +145,9 @@ class AutoConnectManager private constructor(
return
}
handler.removeCallbacksAndMessages(null)
/* the runnable that clears this flag was just removed with the
* callbacks: clear it here or every later connect is swallowed */
pendingEvaluate.set(false)
service?.unregisterListener(this)
try
{