Some upstream keybox sources inject HTML comments inside PEM
certificate blocks. BouncyCastle's PEMParser chokes on these
non-base64 lines, silently failing to load the keybox.
Filter lines starting with <!-- in trimLines() before the content
reaches the PEM parser.
Individual thread crashes silently kill the thread without bringing
down the process. The half-dead process stays alive but broken, and
the service.sh restart loop never fires.
Install a default uncaught exception handler that logs the error and
calls exitProcess(0), triggering the restart loop for full recovery.
When a config file is deleted, the event handler sets file=null but
then force-unwraps it with file!! in the when block, crashing the
FileObserver thread. All subsequent config change notifications are
silently lost.
Replace force-unwrap with safe call, log a warning on deletion.
When the Java interceptor process dies, callback->transact() returns
DEAD_OBJECT but the code fell through to the real keystore, exposing
genuine TEE state to requesting apps.
Add pingBinder() liveness check on pre-transact failure. If the
interceptor is confirmed dead, return DEAD_OBJECT to the caller
instead of forwarding to real hardware. Apps see a transient service
error rather than the actual device attestation state.