mirror of
https://github.com/moparisthebest/Conversations
synced 2024-11-30 20:52:21 -05:00
background daemon doesn't start automatically if there are no enabled accounts. fixed #443 fixed #442
This commit is contained in:
parent
3da0d5adce
commit
2a185c8fc9
@ -32,7 +32,7 @@ public class DatabaseBackend extends SQLiteOpenHelper {
|
|||||||
+ ") ON DELETE CASCADE, UNIQUE(" + Contact.ACCOUNT + ", "
|
+ ") ON DELETE CASCADE, UNIQUE(" + Contact.ACCOUNT + ", "
|
||||||
+ Contact.JID + ") ON CONFLICT REPLACE);";
|
+ Contact.JID + ") ON CONFLICT REPLACE);";
|
||||||
|
|
||||||
public DatabaseBackend(Context context) {
|
private DatabaseBackend(Context context) {
|
||||||
super(context, DATABASE_NAME, null, DATABASE_VERSION);
|
super(context, DATABASE_NAME, null, DATABASE_VERSION);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -222,6 +222,14 @@ public class DatabaseBackend extends SQLiteOpenHelper {
|
|||||||
db.delete(Account.TABLENAME, Account.UUID + "=?", args);
|
db.delete(Account.TABLENAME, Account.UUID + "=?", args);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean hasEnabledAccounts() {
|
||||||
|
SQLiteDatabase db = this.getReadableDatabase();
|
||||||
|
Cursor cursor= db.rawQuery("select count("+Account.UUID+") from "+Account.TABLENAME+" where not options & (1 <<1)", null);
|
||||||
|
cursor.moveToFirst();
|
||||||
|
int count = cursor.getInt(0);
|
||||||
|
return (count>0);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public SQLiteDatabase getWritableDatabase() {
|
public SQLiteDatabase getWritableDatabase() {
|
||||||
SQLiteDatabase db = super.getWritableDatabase();
|
SQLiteDatabase db = super.getWritableDatabase();
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
package eu.siacs.conversations.services;
|
package eu.siacs.conversations.services;
|
||||||
|
|
||||||
|
import eu.siacs.conversations.persistance.DatabaseBackend;
|
||||||
import android.content.BroadcastReceiver;
|
import android.content.BroadcastReceiver;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
@ -14,7 +15,9 @@ public class EventReceiver extends BroadcastReceiver {
|
|||||||
} else {
|
} else {
|
||||||
mIntentForService.setAction("other");
|
mIntentForService.setAction("other");
|
||||||
}
|
}
|
||||||
|
if (intent.getAction().equals("ui") || DatabaseBackend.getInstance(context).hasEnabledAccounts()) {
|
||||||
context.startService(mIntentForService);
|
context.startService(mIntentForService);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user