mirror of
https://github.com/deltachat/deltachat-android.git
synced 2025-10-05 10:39:24 +02:00
call rpc.start() before it is used
This commit is contained in:
parent
906db9155a
commit
bcee64317d
2 changed files with 6 additions and 3 deletions
|
@ -17,6 +17,7 @@ public class Rpc {
|
||||||
private final Map<Integer, SettableFuture<JsonElement>> requestFutures = new ConcurrentHashMap<>();
|
private final Map<Integer, SettableFuture<JsonElement>> requestFutures = new ConcurrentHashMap<>();
|
||||||
private final DcJsonrpcInstance dcJsonrpcInstance;
|
private final DcJsonrpcInstance dcJsonrpcInstance;
|
||||||
private int requestId = 0;
|
private int requestId = 0;
|
||||||
|
private boolean started = false;
|
||||||
private final Gson gson = new GsonBuilder().serializeNulls().create();
|
private final Gson gson = new GsonBuilder().serializeNulls().create();
|
||||||
|
|
||||||
public Rpc(DcJsonrpcInstance dcJsonrpcInstance) {
|
public Rpc(DcJsonrpcInstance dcJsonrpcInstance) {
|
||||||
|
@ -46,6 +47,7 @@ public class Rpc {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void start() {
|
public void start() {
|
||||||
|
started = true;
|
||||||
new Thread(() -> {
|
new Thread(() -> {
|
||||||
while (true) {
|
while (true) {
|
||||||
try {
|
try {
|
||||||
|
@ -57,7 +59,9 @@ public class Rpc {
|
||||||
}, "jsonrpcThread").start();
|
}, "jsonrpcThread").start();
|
||||||
}
|
}
|
||||||
|
|
||||||
public SettableFuture<JsonElement> call(String method, Object... params) {
|
public SettableFuture<JsonElement> call(String method, Object... params) throws RpcException {
|
||||||
|
if (!started) throw new RpcException("RPC not started yet.");
|
||||||
|
|
||||||
int id;
|
int id;
|
||||||
synchronized (this) {
|
synchronized (this) {
|
||||||
id = ++requestId;
|
id = ++requestId;
|
||||||
|
|
|
@ -88,6 +88,7 @@ public class ApplicationContext extends MultiDexApplication {
|
||||||
|
|
||||||
dcAccounts = new DcAccounts(new File(getFilesDir(), "accounts").getAbsolutePath());
|
dcAccounts = new DcAccounts(new File(getFilesDir(), "accounts").getAbsolutePath());
|
||||||
rpc = new Rpc(dcAccounts.getJsonrpcInstance());
|
rpc = new Rpc(dcAccounts.getJsonrpcInstance());
|
||||||
|
rpc.start();
|
||||||
AccountManager.getInstance().migrateToDcAccounts(this);
|
AccountManager.getInstance().migrateToDcAccounts(this);
|
||||||
int[] allAccounts = dcAccounts.getAll();
|
int[] allAccounts = dcAccounts.getAll();
|
||||||
for (int accountId : allAccounts) {
|
for (int accountId : allAccounts) {
|
||||||
|
@ -126,8 +127,6 @@ public class ApplicationContext extends MultiDexApplication {
|
||||||
Log.i("DeltaChat", "shutting down event handler");
|
Log.i("DeltaChat", "shutting down event handler");
|
||||||
}, "eventThread").start();
|
}, "eventThread").start();
|
||||||
|
|
||||||
rpc.start();
|
|
||||||
|
|
||||||
// migrating global notifications pref. to per-account config, added 10/July/24
|
// migrating global notifications pref. to per-account config, added 10/July/24
|
||||||
final String NOTIFICATION_PREF = "pref_key_enable_notifications";
|
final String NOTIFICATION_PREF = "pref_key_enable_notifications";
|
||||||
boolean isMuted = !Prefs.getBooleanPreference(this, NOTIFICATION_PREF, true);
|
boolean isMuted = !Prefs.getBooleanPreference(this, NOTIFICATION_PREF, true);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue