mirror of https://github.com/perkeep/perkeep.git
stop service in more cases
This commit is contained in:
parent
beee3f30c7
commit
196a5f268b
|
@ -108,7 +108,12 @@ public class UploadService extends Service {
|
||||||
mCallback.setByteStatus(mBytesUploaded, mBytesTotal);
|
mCallback.setByteStatus(mBytesUploaded, mBytesTotal);
|
||||||
} catch (RemoteException e) {
|
} catch (RemoteException e) {
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
stopServiceIfEmpty();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void stopServiceIfEmpty() {
|
||||||
|
synchronized (this) {
|
||||||
if (mQueueSet.isEmpty()) {
|
if (mQueueSet.isEmpty()) {
|
||||||
stopService(new Intent(UploadService.this, UploadService.class));
|
stopService(new Intent(UploadService.this, UploadService.class));
|
||||||
}
|
}
|
||||||
|
@ -132,6 +137,7 @@ public class UploadService extends Service {
|
||||||
SharedPreferences sp = getSharedPreferences(Preferences.NAME, 0);
|
SharedPreferences sp = getSharedPreferences(Preferences.NAME, 0);
|
||||||
HostPort hp = new HostPort(sp.getString(Preferences.HOST, ""));
|
HostPort hp = new HostPort(sp.getString(Preferences.HOST, ""));
|
||||||
if (!hp.isValid()) {
|
if (!hp.isValid()) {
|
||||||
|
stopServiceIfEmpty();
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -144,6 +150,7 @@ public class UploadService extends Service {
|
||||||
synchronized (UploadService.this) {
|
synchronized (UploadService.this) {
|
||||||
if (mQueueSet.contains(qf)) {
|
if (mQueueSet.contains(qf)) {
|
||||||
Log.d(TAG, "Dup blob enqueue, ignoring " + qf);
|
Log.d(TAG, "Dup blob enqueue, ignoring " + qf);
|
||||||
|
stopServiceIfEmpty();
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
Log.d(TAG, "Enqueueing blob: " + qf);
|
Log.d(TAG, "Enqueueing blob: " + qf);
|
||||||
|
|
Loading…
Reference in New Issue