avoid crashes when BT turned off

Test at enqueueWork() and onHandleWorkImpl(). Seems to do it. Maybe
turning it off mid-send will still crash...
This commit is contained in:
Eric House 2019-02-08 22:22:03 -08:00
parent 30f70db59b
commit 8f6745a308

View file

@ -292,17 +292,15 @@ public class BTService extends XWJIService {
private static void enqueueWork( Context context, Intent intent ) private static void enqueueWork( Context context, Intent intent )
{ {
if ( BTEnabled() ) {
enqueueWork( context, BTService.class, sJobID, intent ); enqueueWork( context, BTService.class, sJobID, intent );
Log.d( TAG, "called enqueueWork(cmd=%s)", }
cmdFrom( intent, BTAction.values() ) );
} }
public static void onACLConnected( Context context ) public static void onACLConnected( Context context )
{ {
Log.d( TAG, "onACLConnected()" );
enqueueWork( context, enqueueWork( context,
getIntentTo( context, BTAction.ACL_CONN ) ); getIntentTo( context, BTAction.ACL_CONN ) );
} }
public static void radioChanged( Context context, boolean cameOn ) public static void radioChanged( Context context, boolean cameOn )
@ -417,6 +415,7 @@ public class BTService extends XWJIService {
@Override @Override
void onHandleWorkImpl( Intent intent, XWJICmds jicmd, long timestamp ) void onHandleWorkImpl( Intent intent, XWJICmds jicmd, long timestamp )
{ {
if ( BTEnabled() ) {
BTAction cmd = (BTAction)jicmd; BTAction cmd = (BTAction)jicmd;
switch( cmd ) { switch( cmd ) {
case ACL_CONN: // just forces onCreate to run case ACL_CONN: // just forces onCreate to run
@ -527,6 +526,7 @@ public class BTService extends XWJIService {
default: default:
Assert.fail(); Assert.fail();
} }
}
} // onHandleWorkImpl() } // onHandleWorkImpl()
private void add( BTQueueElem elem ) private void add( BTQueueElem elem )