fix: secure and refresh unrooted log exports

This commit is contained in:
Kurt Himebauch committed 2026-11-05 14:42:22 -05:00
1 parent ca0689d254
commit 718712eb01
6 files changed
+78 -11

No files matched your search

@@ -25,6 +25,7 @@ import com.droiddeck.launcher.session.SessionState
import org.json.JSONArray
import org.json.JSONObject
import java.io.File
import java.util.UUID
import java.util.concurrent.CountDownLatch
import java.util.concurrent.TimeUnit
@@ -206,7 +207,13 @@ class AgentBridgeProvider : ContentProvider() {
private fun logs(context: Context): JSONObject {
val dir = logDir(context)?.takeIf { it.isDirectory }
?: return error("NO_SESSION_LOGS", "No session artifact directory is available")
val zip = SessionLogShare.zipFolder(context, dir, File(context.getExternalFilesDir(null), "agent-logs"))
val output = File(context.getExternalFilesDir(null), "agent-logs/${UUID.randomUUID()}")
val zip = try {
SessionLogShare.zipFolder(context, dir, output)
} catch (error: Exception) {
output.deleteRecursively()
throw error
}
?: return error("NO_SESSION_LOGS", "The session artifact directory is empty")
return JSONObject().put("ok", true).put("command", "logs").put("sessionId", dir.name).put("zip", zip.absolutePath)
}