Skip to content

Commit

Permalink
Exit should really, properly exit now.
Browse files Browse the repository at this point in the history
Fixes owntracks#954. App wasn't quitting the message sending thread before. Now,
we do that, *and* we `killProcess`.
  • Loading branch information
growse committed Mar 14, 2021
1 parent 8005193 commit dec7113
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
* Fix for regression introduced in 2.2 where self-signed certificates supplied as the CA were doing more restrictive hostname checking (#896). Hostnames are no longer matched if the CA cert is the same as the MQTT leaf cert.
* Geocoder preference should now work properly on API<24
* Initial location fix should now also work better on API<24
* Fix an issue where trying to exit the app wouldn't work if there were outstanding messages queued to be sent (#954)

## Version 2.2.2

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,7 @@ public void onLocationResult(LocationResult locationResult) {
public void onDestroy() {
stopForeground(true);
preferences.unregisterOnPreferenceChangedListener(this);
messageProcessor.stopSendingMessages();
super.onDestroy();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -425,6 +425,11 @@ private void processIncomingMessage(MessageTransition message) {
eventBus.post(message);
}

public void stopSendingMessages() {
Timber.d("Interrupting background sending thread");
backgroundDequeueThread.interrupt();
}

public enum EndpointState {
INITIAL,
IDLE,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ synchronized void sendMessage(MessageBase m) throws ConfigurationIncompleteExcep
try {
connectToBroker();
} catch (MqttConnectionException e) {
Timber.w("failed connection attempts :%s", sendMessageConnectPressure);
Timber.w("failed connection attempts: %s", sendMessageConnectPressure);
messageProcessor.onMessageDeliveryFailed(messageId);
throw new OutgoingMessageSendingException(e);
} catch (ConfigurationIncompleteException e) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@

import javax.inject.Inject;

import static android.os.Process.killProcess;
import static android.os.Process.myPid;

@PerActivity
public class DrawerProvider {
private static final int COLOR_ICON_PRIMARY = R.color.md_light_primary_icon;
Expand Down Expand Up @@ -116,6 +119,7 @@ public void attach(@NonNull Toolbar toolbar) {
activity.finishAffinity();
// Kill scheduled tasks
scheduler.cancelAllTasks();
killProcess(myPid());
return true;
}

Expand Down

0 comments on commit dec7113

Please sign in to comment.