mirror of
git://xwords.git.sourceforge.net/gitroot/xwords/xwords
synced 2025-02-05 20:45:49 +01:00
don't shut down MQTT levels we didn't reach
This is a shot-in-the-dark at internal MQTT crashes being reported through the Play Store.
This commit is contained in:
parent
37b5f80e05
commit
97f280a6ea
1 changed files with 12 additions and 6 deletions
|
@ -297,6 +297,7 @@ public class MQTTUtils extends Thread
|
|||
|
||||
if ( !stateOk ) {
|
||||
Log.e( TAG, "%H.setState(): bad state for %s: %s", this, newState, mState );
|
||||
Assert.failDbg();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -434,6 +435,7 @@ public class MQTTUtils extends Thread
|
|||
|
||||
mShouldExit = true;
|
||||
|
||||
State prevState = mState;
|
||||
setState( State.CLOSING );
|
||||
|
||||
MqttAsyncClient client;
|
||||
|
@ -449,7 +451,7 @@ public class MQTTUtils extends Thread
|
|||
if ( null == client ) {
|
||||
Log.e( TAG, "disconnect(): null client" );
|
||||
} else {
|
||||
startDisconThread( client );
|
||||
startDisconThread( client, prevState );
|
||||
}
|
||||
|
||||
// Make sure we don't need to call clearInstance(this)
|
||||
|
@ -459,7 +461,7 @@ public class MQTTUtils extends Thread
|
|||
Log.d( TAG, "%H.disconnect() DONE", this );
|
||||
}
|
||||
|
||||
private void startDisconThread( final MqttAsyncClient client )
|
||||
private void startDisconThread( final MqttAsyncClient client, State maxState )
|
||||
{
|
||||
new Thread( new Runnable() {
|
||||
@Override
|
||||
|
@ -471,12 +473,16 @@ public class MQTTUtils extends Thread
|
|||
try {
|
||||
switch ( ii ) {
|
||||
case 0:
|
||||
action = "unsubscribe";
|
||||
token = client.unsubscribe( mDevID );
|
||||
if ( State.SUBSCRIBED == maxState ) {
|
||||
action = "unsubscribe";
|
||||
token = client.unsubscribe( mDevID );
|
||||
}
|
||||
break; // not continue, which skips the Log() below
|
||||
case 1:
|
||||
action = "disconnect";
|
||||
token = client.disconnect();
|
||||
if ( client.isConnected() ) {
|
||||
action = "disconnect";
|
||||
token = client.disconnect();
|
||||
}
|
||||
break;
|
||||
case 2:
|
||||
action = "close";
|
||||
|
|
Loading…
Add table
Reference in a new issue