From 726f62061d551009f55371503b423181b2970f7c Mon Sep 17 00:00:00 2001 From: Chris McCormick Date: Sun, 8 Jun 2014 23:24:50 +0200 Subject: [PATCH 1/2] Part of fix for #18 on Gingerbread - call Looper.prepare() to set up the thread. --- .../nutomic/syncthingandroid/syncthing/SyncthingService.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/main/java/com/nutomic/syncthingandroid/syncthing/SyncthingService.java b/src/main/java/com/nutomic/syncthingandroid/syncthing/SyncthingService.java index 473f13c5..0b577dc6 100644 --- a/src/main/java/com/nutomic/syncthingandroid/syncthing/SyncthingService.java +++ b/src/main/java/com/nutomic/syncthingandroid/syncthing/SyncthingService.java @@ -7,6 +7,7 @@ import android.content.Context; import android.content.Intent; import android.os.AsyncTask; import android.os.IBinder; +import android.os.Looper; import android.support.v4.app.NotificationCompat; import android.util.Log; @@ -292,6 +293,7 @@ public class SyncthingService extends Service { new Thread(new Runnable() { @Override public void run() { + Looper.prepare(); if (isFirstStart(SyncthingService.this)) { Log.i(TAG, "App started for the first time. " + "Copying default config, keys will be generated automatically"); From a3965c6b832c1d3efabadda659bacf1ce6b1cf52 Mon Sep 17 00:00:00 2001 From: Chris McCormick Date: Sun, 8 Jun 2014 23:28:15 +0200 Subject: [PATCH 2/2] Fix for #18 - correctly pass the HOME environment variable in to the syncthing process. --- .../nutomic/syncthingandroid/syncthing/SyncthingService.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/nutomic/syncthingandroid/syncthing/SyncthingService.java b/src/main/java/com/nutomic/syncthingandroid/syncthing/SyncthingService.java index 0b577dc6..c98623e2 100644 --- a/src/main/java/com/nutomic/syncthingandroid/syncthing/SyncthingService.java +++ b/src/main/java/com/nutomic/syncthingandroid/syncthing/SyncthingService.java @@ -135,7 +135,7 @@ public class SyncthingService extends Service { process = Runtime.getRuntime().exec("sh"); dos = new DataOutputStream(process.getOutputStream()); // Set home directory to data folder for syncthing to use. - dos.writeBytes("HOME=" + getFilesDir() + "\n"); + dos.writeBytes("HOME=" + getFilesDir() + " "); // Call syncthing with -home (as it would otherwise use "~/.config/syncthing/". dos.writeBytes(getApplicationInfo().dataDir + "/" + BINARY_NAME + " " + "-home " + getFilesDir() + "\n");