Skip to content

Commit af35a44

Browse files
committed
fix: fix single-instance errors on android
1 parent 1672ff6 commit af35a44

File tree

2 files changed

+11
-0
lines changed

2 files changed

+11
-0
lines changed

mobile/src/main/java/net/activitywatch/android/SyncInterface.kt

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,15 @@ class SyncInterface(context: Context) {
2323
syncDir = "$downloadsDir/ActivityWatch"
2424
Os.setenv("AW_SYNC_DIR", syncDir, true)
2525

26+
// Set XDG environment variables to app-writable paths
27+
// This is required for aw-client-rust (used by aw-sync) to create lock files
28+
val cacheDir = context.cacheDir.absolutePath
29+
val filesDir = context.filesDir.absolutePath
30+
31+
Os.setenv("XDG_CACHE_HOME", cacheDir, true)
32+
Os.setenv("XDG_CONFIG_HOME", "$filesDir/config", true)
33+
Os.setenv("XDG_DATA_HOME", "$filesDir/data", true)
34+
2635
// Create sync directory if it doesn't exist
2736
File(syncDir).mkdirs()
2837

@@ -77,6 +86,7 @@ class SyncInterface(context: Context) {
7786
val handler = Handler(Looper.getMainLooper())
7887

7988
executor.execute {
89+
Log.i(TAG, "Starting sync operation: $operation")
8090
try {
8191
val response = syncFn()
8292
val json = JSONObject(response)

mobile/src/main/java/net/activitywatch/android/SyncScheduler.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ class SyncScheduler(private val context: Context) {
1717
if (isRunning) {
1818
performSync()
1919
// Schedule next sync in 15 minutes
20+
Log.i(TAG, "Scheduling next sync in 15 minutes")
2021
handler.postDelayed(this, 15 * 60 * 1000L)
2122
}
2223
}

0 commit comments

Comments
 (0)