greenaddress / abcore

ABCore - Android Bitcoin Core
http://abco.re
MIT License
164 stars 55 forks source link

Foreground service is never stopped #95

Open gwicks56 opened 5 years ago

gwicks56 commented 5 years ago

When the switch (android:id="@+id/switchCore") is toggled on the foreground services is started, but when it is toggled off stopservice() is never called, which means although it disconnects and stops the sync, the notification is left in the notification status bar ( ABCore is Running), which is a bit confusing.

Unless there is a reason you need ABCore to continue to treat the app as a foreground app after the switch is toggled, call:

stopService(new Intent(MainActivity.this, ABCoreService.class));

in

 stopDaemonAndSetStatus()

Alternatively you can do it inside ABCoreService with intent extras and calling stopForeground(true) and then stopSelf()

greenaddress commented 5 years ago

Agree either of the option (first one seems more reasonable since we don't need the service running) - @udiWertheimer ?

I think part of the issue here is the asymmetry as well, we start core as a new process but to stop it we use the RPC and that for example has races, especially if you try to stop it immediately while is still verifying blocks ...

We need something like -rpcwait in bitcoin-cli before we issue rpc requests, likewise we also need to handle rpc being down failures since a bad bitcoin.conf could easily make it bail out