Skip to content

Commit 79842f3

Browse files
committed
fix: bundle static curl for ARMv7 — NullClaw uses curl subprocess for HTTP, not found on Wear OS
1 parent 65eadf7 commit 79842f3

2 files changed

Lines changed: 16 additions & 5 deletions

File tree

app/src/main/java/com/thinkoff/clawwatch/ClawRunner.kt

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,8 @@ class ClawRunner(private val context: Context) {
2727
private val filesDir get() = context.filesDir
2828
// HOME = parent of filesDir so ~/.nullclaw/config.json lands at dataDir/.nullclaw/config.json
2929
private val homeDir get() = context.filesDir.parentFile!!
30-
private val binaryFile get() = File(context.applicationInfo.nativeLibraryDir, "libnullclaw.so")
30+
private val nativeLibDir get() = context.applicationInfo.nativeLibraryDir
31+
private val binaryFile get() = File(nativeLibDir, "libnullclaw.so")
3132
private val configFile get() = File(filesDir, CONFIG_NAME)
3233
private val nullclawConfigFile get() = File(homeDir, ".nullclaw/config.json")
3334

@@ -36,6 +37,16 @@ class ClawRunner(private val context: Context) {
3637
/** Write NullClaw home config with API key and model, copy app config from assets. */
3738
suspend fun ensureInstalled() = withContext(Dispatchers.IO) {
3839
Log.i(TAG, "NullClaw binary at ${binaryFile.absolutePath} (exists: ${binaryFile.exists()})")
40+
// Symlink libcurl_bin.so → filesDir/curl so NullClaw can find it via PATH
41+
val curlDest = File(filesDir, "curl")
42+
if (!curlDest.exists()) {
43+
val curlSrc = File(nativeLibDir, "libcurl_bin.so")
44+
if (curlSrc.exists()) {
45+
curlSrc.copyTo(curlDest, overwrite = true)
46+
curlDest.setExecutable(true)
47+
Log.i(TAG, "curl installed at ${curlDest.absolutePath}")
48+
}
49+
}
3950
if (!configFile.exists()) {
4051
context.assets.open(CONFIG_NAME).use { it.copyTo(configFile.outputStream()) }
4152
}
@@ -122,12 +133,12 @@ class ClawRunner(private val context: Context) {
122133
environment().apply {
123134
put("ANTHROPIC_API_KEY", apiKey)
124135
put("HOME", homeDir.absolutePath)
125-
put("PATH", "/system/bin:/system/xbin")
126-
// CA bundle for Zig's TLS (musl has no system store on Android)
136+
// filesDir has our 'curl' binary — NullClaw calls curl as subprocess
137+
put("PATH", "${filesDir.absolutePath}:$nativeLibDir:/system/bin:/system/xbin")
138+
// CA bundle for curl's HTTPS calls
127139
if (caBundleFile.exists()) {
128-
put("SSL_CERT_FILE", caBundleFile.absolutePath)
129140
put("CURL_CA_BUNDLE", caBundleFile.absolutePath)
130-
put("CAINFO", caBundleFile.absolutePath)
141+
put("SSL_CERT_FILE", caBundleFile.absolutePath)
131142
}
132143
}
133144
}
3.61 MB
Binary file not shown.

0 commit comments

Comments
 (0)