From 196a5f268b26f906ab51df36ec612fcae445f839 Mon Sep 17 00:00:00 2001 From: Brad Fitzpatrick Date: Sat, 24 Jul 2010 18:09:28 -0700 Subject: [PATCH] stop service in more cases --- .../uploader/src/com/danga/camli/UploadService.java | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/clients/android/uploader/src/com/danga/camli/UploadService.java b/clients/android/uploader/src/com/danga/camli/UploadService.java index 28174be33..5da638ef4 100644 --- a/clients/android/uploader/src/com/danga/camli/UploadService.java +++ b/clients/android/uploader/src/com/danga/camli/UploadService.java @@ -108,7 +108,12 @@ public class UploadService extends Service { mCallback.setByteStatus(mBytesUploaded, mBytesTotal); } catch (RemoteException e) { } + } + stopServiceIfEmpty(); + } + private void stopServiceIfEmpty() { + synchronized (this) { if (mQueueSet.isEmpty()) { stopService(new Intent(UploadService.this, UploadService.class)); } @@ -132,6 +137,7 @@ public class UploadService extends Service { SharedPreferences sp = getSharedPreferences(Preferences.NAME, 0); HostPort hp = new HostPort(sp.getString(Preferences.HOST, "")); if (!hp.isValid()) { + stopServiceIfEmpty(); return false; } @@ -144,6 +150,7 @@ public class UploadService extends Service { synchronized (UploadService.this) { if (mQueueSet.contains(qf)) { Log.d(TAG, "Dup blob enqueue, ignoring " + qf); + stopServiceIfEmpty(); return false; } Log.d(TAG, "Enqueueing blob: " + qf);