Buggy code:
private BluetoothAdapter mAdapter ; private BluetoothFtpService . RfcommSocketAcceptThread mRfcommAcceptThread = null ; private BluetoothFtpAuthenticator mAuth = null ; private BluetoothServerSocket mRfcommServerSocket = null ; private BluetoothSocket mConnSocket = null ; private BluetoothDevice mRemoteDevice = null ; private static String sRemoteDeviceName = null ; private boolean mHasStarted = false ; private volatile boolean mInterrupted ; private int mStartId = - 1 ; private BluetoothFtpObexServer mFtpServer = null ; private ServerSession mServerSession = null ; private boolean isWaitingAuthorization = false ; public BluetoothFtpService ( ) { } @ Override public void onCreate ( ) { } @ Override public int onStartCommand ( Intent intent , int flags , int startId ) { } private void parseIntent ( final Intent intent ) { String action = ( intent == null ) ? null : intent . getStringExtra ( "action" ) ; if ( action == null ) { Log . e ( BluetoothFtpService . TAG , "Unexpected<seq2seq4repair_space>error!<seq2seq4repair_space>action<seq2seq4repair_space>is<seq2seq4repair_space>null" ) ; return ; } if ( BluetoothFtpService . VERBOSE ) Log . v ( BluetoothFtpService . TAG , ( "PARSE<seq2seq4repair_space>INTENT<seq2seq4repair_space>action:<seq2seq4repair_space>" + action ) ) ; int state = intent . getIntExtra ( EXTRA_STATE , ERROR ) ; boolean removeTimeoutMsg = true ; if ( action . equals ( ACTION_STATE_CHANGED ) ) { removeTimeoutMsg = false ; Log . d ( BluetoothFtpService . TAG , ( ( ( "ACTION_STATE_CHANGED:<seq2seq4repair_space>state:<seq2seq4repair_space>" + state ) + "mHasStarted:<seq2seq4repair_space>" ) + ( mHasStarted ) ) ) ; if ( ( state == ( BluetoothAdapter . STATE_TURNING_OFF ) ) && ( ( mAdapter ) != null ) ) { FileUtils . interruptFileCopy = true ; if ( mSessionStatusHandler . hasMessages ( BluetoothFtpService . MSG_INTERNAL_USER_TIMEOUT ) ) { Intent i = new Intent ( BluetoothFtpService . USER_CONFIRM_TIMEOUT_ACTION ) ; sendBroadcast ( i ) ; removeFtpNotification ( BluetoothFtpService . NOTIFICATION_ID_ACCESS ) ; } closeService ( ) ; } else if ( ( state == ( BluetoothAdapter . STATE_ON ) ) && ( ! ( mHasStarted ) ) ) { if ( BluetoothFtpService . VERBOSE ) Log . v ( BluetoothFtpService . TAG , "FTP<seq2seq4repair_space>service<seq2seq4repair_space>start<seq2seq4repair_space>listener" ) ; mHasStarted = true ; mSessionStatusHandler . sendMessage ( mSessionStatusHandler . obtainMessage ( BluetoothFtpService . MSG_INTERNAL_START_LISTENER ) ) ; } } else if ( action . equals ( BluetoothFtpService . ACCESS_ALLOWED_ACTION ) ) { if ( ! ( isWaitingAuthorization ) ) { return ; } isWaitingAuthorization = false ; if ( intent . getBooleanExtra ( BluetoothFtpService . EXTRA_ALWAYS_ALLOWED , false ) ) { if ( ( mRemoteDevice ) != null ) { mRemoteDevice . setTrust ( true ) ; Log . v ( BluetoothFtpService . TAG , ( "setTrust()<seq2seq4repair_space>TRUE<seq2seq4repair_space>" + ( mRemoteDevice . getName ( ) ) ) ) ; } } try { if ( ( mConnSocket ) != null ) { startObexServerSession ( ) ; } else { stopObexServerSession ( ) ; } } catch ( IOException ex ) { Log . e ( BluetoothFtpService . TAG , ( "Caught<seq2seq4repair_space>the<seq2seq4repair_space>error:<seq2seq4repair_space>" + ( ex . toString ( ) ) ) ) ; } removeFtpNotification ( BluetoothFtpService . NOTIFICATION_ID_ACCESS ) ; } else if ( action . equals ( BluetoothFtpService . ACCESS_DISALLOWED_ACTION ) ) { stopObexServerSession ( ) ; } else if ( action . equals ( BluetoothFtpService . AUTH_RESPONSE_ACTION ) ) { String sessionkey = intent . getStringExtra ( BluetoothFtpService . EXTRA_SESSION_KEY ) ; notifyAuthKeyInput ( sessionkey ) ; removeAuthChallTimer ( ) ; removeFtpNotification ( BluetoothFtpService . NOTIFICATION_ID_ACCESS ) ; } else if ( action . equals ( BluetoothFtpService . AUTH_CANCELLED_ACTION ) ) { notifyAuthCancelled ( ) ; removeAuthChallTimer ( ) ; removeFtpNotification ( BluetoothFtpService . NOTIFICATION_ID_ACCESS ) ; } else if ( ( action . equals ( ACTION_ACL_DISCONNECTED ) ) && ( isWaitingAuthorization ) ) { BluetoothDevice device = intent . getParcelableExtra ( EXTRA_DEVICE ) ; if ( ( device != null ) && ( device . equals ( mRemoteDevice ) ) ) { FileUtils . interruptFileCopy = true ; if ( ( mSessionStatusHandler ) != null ) { mSessionStatusHandler . sendMessage ( mSessionStatusHandler . obtainMessage ( BluetoothFtpService . MSG_INTERNAL_USER_TIMEOUT ) ) ; removeTimeoutMsg = false ; } } } else { removeTimeoutMsg = false ; } <START_BUG> if ( removeTimeoutMsg ) { <END_BUG> mSessionStatusHandler . removeMessages ( BluetoothFtpService . MSG_INTERNAL_USER_TIMEOUT ) ; } } @ Override public void onDestroy ( ) { } @ Override public IBinder onBind ( Intent intent ) { } private void startRfcommSocketListener ( ) { } private final boolean initRfcommSocket ( ) { } private final void closeRfcommSocket ( boolean server , boolean accept ) throws IOException { } private final void closeService ( ) { } private final void startObexServerSession ( ) throws IOException { } private void stopObexServerSession ( ) { } private void notifyAuthKeyInput ( final String key ) { } private void notifyAuthCancelled ( ) { } private void notifyMediaScanner ( Bundle obj , int op ) { } private void notifyContentResolver ( Uri uri ) { } private class RfcommSocketAcceptThread extends Thread { private boolean stopped = false ; private static final String RTAG = "BluetoothFtpService:RfcommSocketAcceptThread" ; @ Override public void run ( ) { } void shutdown ( ) { } } private final Handler mSessionStatusHandler = new Handler ( ) { @ Override public void handleMessage ( Message msg ) { } } ; private Notification createFtpConnectedNotification ( ) { } private void createFtpNotification ( String action ) { } private void removeFtpNotification ( int id ) { } private void removeAuthChallTimer ( ) { } public static String getRemoteDeviceName ( ) { } public static class FtpMediaScannerNotifier implements MediaScannerConnectionClient { private MediaScannerConnection mConnection ; private Context mContext ; private Handler mCallback ; private int mOp ; public FtpMediaScannerNotifier ( Context context , final String filename , final String mimetype , Handler handler , int op ) { } public FtpMediaScannerNotifier ( Context context , final String [ ] filenames , final String [ ] mimetypes , Handler handler , int op ) { } public void onMediaScannerConnected ( ) { } public void onScanCompleted ( String path , Uri uri ) { }

Fix:
if ( removeTimeoutMsg && ( ( mSessionStatusHandler ) != null ) ) {