use of com.samourai.whirlpool.client.wallet.AndroidWhirlpoolWalletService in project samourai-wallet-android by Samourai-Wallet.
the class TorService method onStartCommand.
@Override
public int onStartCommand(Intent intent, int flags, int startId) {
if (Objects.requireNonNull(intent.getAction()).equals(TorService.STOP_SERVICE)) {
if (DojoUtil.getInstance(getApplicationContext()).getDojoParams() != null && !intent.hasExtra("KILL_TOR")) {
Toast.makeText(getApplicationContext(), "You cannot stop Tor service when dojo is connected", Toast.LENGTH_SHORT).show();
return START_STICKY;
}
Disposable disposable = TorManager.getInstance(getApplicationContext()).stopTor().subscribe(stat -> {
compositeDisposable.dispose();
stopSelf();
}, error -> {
//
});
compositeDisposable.add(disposable);
AndroidWhirlpoolWalletService whirlpoolWalletService = AndroidWhirlpoolWalletService.getInstance();
if (whirlpoolWalletService.getWhirlpoolWallet().isPresent()) {
// restart WhirlpoolWallet with new Tor config
whirlpoolWalletService.restart(this).subscribeOn(Schedulers.io()).subscribe();
}
} else if (intent.getAction().equals(TorService.RENEW_IDENTITY)) {
renewIdentity();
return START_STICKY;
} else if (Objects.requireNonNull(intent.getAction()).equals(TorService.START_SERVICE)) {
if (!TorManager.getInstance(getApplicationContext()).isProcessRunning) {
startTor();
}
}
return START_STICKY;
}
use of com.samourai.whirlpool.client.wallet.AndroidWhirlpoolWalletService in project samourai-wallet-android by Samourai-Wallet.
the class TorService method startTor.
private void startTor() {
title = "Tor: Waiting";
updateNotification("Connecting....");
if (torDisposable != null) {
compositeDisposable.delete(torDisposable);
Log.i(TAG, "startTOR: ".concat(String.valueOf(torDisposable.isDisposed())));
}
torDisposable = TorManager.getInstance(getApplicationContext()).startTor().debounce(100, TimeUnit.MILLISECONDS).subscribeOn(Schedulers.io()).observeOn(AndroidSchedulers.mainThread()).subscribe(proxy -> {
title = "Tor: Running";
updateNotification("Running....");
}, Throwable::printStackTrace);
compositeDisposable.add(torDisposable);
Disposable statusDisposable = TorManager.getInstance(this).torStatus.subscribeOn(Schedulers.io()).observeOn(AndroidSchedulers.mainThread()).subscribe(state -> {
if (state == TorManager.CONNECTION_STATES.CONNECTED) {
AndroidWhirlpoolWalletService whirlpoolWalletService = AndroidWhirlpoolWalletService.getInstance();
if (whirlpoolWalletService.getWhirlpoolWallet().isPresent()) {
// restart WhirlpoolWallet with new Tor config once Tor is connected
whirlpoolWalletService.restart(this).subscribeOn(Schedulers.io()).subscribe();
}
}
});
logger();
compositeDisposable.add(statusDisposable);
}
Aggregations