Skip to content

Commit

Permalink
BootstrapReceiver: Go asynchronous.
Browse files Browse the repository at this point in the history
  • Loading branch information
Andreas Schildbach committed Nov 17, 2019
1 parent a972e7d commit 9928e6a
Showing 1 changed file with 17 additions and 8 deletions.
25 changes: 17 additions & 8 deletions wallet/src/de/schildbach/wallet/service/BootstrapReceiver.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2011-2015 the original author or authors.
* Copyright the original author or authors.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
Expand All @@ -17,16 +17,16 @@

package de.schildbach.wallet.service;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import de.schildbach.wallet.Configuration;
import de.schildbach.wallet.Constants;
import de.schildbach.wallet.WalletApplication;

import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.os.AsyncTask;
import androidx.annotation.WorkerThread;
import de.schildbach.wallet.Configuration;
import de.schildbach.wallet.Constants;
import de.schildbach.wallet.WalletApplication;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/**
* @author Andreas Schildbach
Expand All @@ -37,7 +37,16 @@ public class BootstrapReceiver extends BroadcastReceiver {
@Override
public void onReceive(final Context context, final Intent intent) {
log.info("got broadcast: " + intent);
final PendingResult result = goAsync();
AsyncTask.execute(() -> {
org.bitcoinj.core.Context.propagate(Constants.CONTEXT);
onAsyncReceive(context, intent);
result.finish();
});
}

@WorkerThread
private void onAsyncReceive(final Context context, final Intent intent) {
final WalletApplication application = (WalletApplication) context.getApplicationContext();

final boolean bootCompleted = Intent.ACTION_BOOT_COMPLETED.equals(intent.getAction());
Expand Down

0 comments on commit 9928e6a

Please sign in to comment.