Buggy code:
public class LinphoneManager implements LinphoneChatMessage . LinphoneChatMessageListener , LinphoneCoreListener { private static LinphoneManager instance ; private Context mServiceContext ; private AudioManager mAudioManager ; private PowerManager mPowerManager ; private Resources mR ; private LinphonePreferences mPrefs ; private LinphoneCore mLc ; private String lastLcStatusMessage ; private String basePath ; private static boolean sExited ; private boolean mAudioFocused ; private int mLastNetworkType = - 1 ; private ConnectivityManager mConnectivityManager ; private Handler mHandler = new Handler ( ) ; private WakeLock mIncallWakeLock ; private static List < LinphoneChatMessage > mPendingChatFileMessage ; private static LinphoneChatMessage mUploadPendingFileMessage ; public String wizardLoginViewDomain = null ; private static List < LinphoneChatMessage . LinphoneChatMessageListener > simpleListeners = new ArrayList < LinphoneChatMessage . LinphoneChatMessageListener > ( ) ; public static void addListener ( LinphoneChatMessage . LinphoneChatMessageListener listener ) { } public static void removeListener ( LinphoneChatMessage . LinphoneChatMessageListener listener ) { } protected LinphoneManager ( final Context c ) { } private static final int LINPHONE_VOLUME_STREAM = STREAM_VOICE_CALL ; private static final int dbStep = 4 ; private final String mLPConfigXsd ; private final String mLinphoneFactoryConfigFile ; private final String mLinphoneRootCaFile ; public final String mLinphoneConfigFile ; private final String mRingSoundFile ; private final String mRingbackSoundFile ; private final String mPauseSoundFile ; private final String mChatDatabaseFile ; private final String mErrorToneFile ; private ByteArrayInputStream mUploadingImageStream ; private Timer mTimer ; private BroadcastReceiver mKeepAliveReceiver = new KeepAliveReceiver ( ) ; private void routeAudioToSpeakerHelper ( boolean speakerOn ) { } public void routeAudioToSpeaker ( ) { } public String getUserAgent ( ) throws NameNotFoundException { } public void routeAudioToReceiver ( ) { } public static final synchronized LinphoneManager createAndStart ( Context c ) { } public void addDownloadMessagePending ( LinphoneChatMessage message ) { } public boolean isMessagePending ( LinphoneChatMessage message ) { } public void removePendingMessage ( LinphoneChatMessage message ) { } public void setUploadPendingFileMessage ( LinphoneChatMessage message ) { } public LinphoneChatMessage getMessageUploadPending ( ) { } public void setUploadingImageStream ( ByteArrayInputStream array ) { } @ Override public void onLinphoneChatMessageStateChanged ( LinphoneChatMessage msg , LinphoneChatMessage . State state ) { <START_BUG> if ( state == ( State . FileTransferDone ) ) { <END_BUG> if ( ( msg . isOutgoing ( ) ) && ( ( mUploadingImageStream ) != null ) ) { LinphoneManager . mUploadPendingFileMessage = null ; mUploadingImageStream = null ; } else { File file = new File ( Environment . getExternalStorageDirectory ( ) , msg . getFileTransferInformation ( ) . getName ( ) ) ; try { String url = Media . insertImage ( getContext ( ) . getContentResolver ( ) , file . getPath ( ) , msg . getFileTransferInformation ( ) . getName ( ) , null ) ; msg . setAppData ( url ) ; file . delete ( ) ; } catch ( FileNotFoundException e ) { e . printStackTrace ( ) ; } removePendingMessage ( msg ) ; } } for ( LinphoneChatMessage . LinphoneChatMessageListener l : LinphoneManager . simpleListeners ) { l . onLinphoneChatMessageStateChanged ( msg , state ) ; } } @ Override public void onLinphoneChatMessageFileTransferReceived ( LinphoneChatMessage msg , LinphoneContent content , LinphoneBuffer buffer ) { } @ Override public void onLinphoneChatMessageFileTransferSent ( LinphoneChatMessage msg , LinphoneContent content , int offset , int size , LinphoneBuffer bufferToFill ) { } @ Override public void onLinphoneChatMessageFileTransferProgressChanged ( LinphoneChatMessage msg , LinphoneContent content , int offset , int total ) { } private boolean isPresenceModelActivitySet ( ) { } public void changeStatusToOnline ( ) { } public void changeStatusToOnThePhone ( ) { } public void changeStatusToOffline ( ) { } public static final synchronized LinphoneManager getInstance ( ) { } public static final synchronized LinphoneCore getLc ( ) { } public String getLPConfigXsdPath ( ) { } public void newOutgoingCall ( LinphoneManager . AddressType address ) { } public void newOutgoingCall ( String to , String displayName ) { } private void resetCameraFromPreferences ( ) { } public static interface AddressType { void setText ( CharSequence s ) { } CharSequence getText ( ) { } void setDisplayedName ( String s ) { } String getDisplayedName ( ) { } } public static interface NewOutgoingCallUiListener { public void onWrongDestinationAddress ( ) { } public void onCannotGetCallParameters ( ) { } public void onAlreadyInCall ( ) { } } public boolean toggleEnableCamera ( ) { } public void enableCamera ( LinphoneCall call , boolean enable ) { } public void sendStaticImage ( boolean send ) { } public void playDtmf ( ContentResolver r , char dtmf ) { } public void terminateCall ( ) { } public void initTunnelFromConf ( ) { } private boolean isTunnelNeeded ( NetworkInfo info ) { } private void manageTunnelServer ( NetworkInfo info ) { } private synchronized void startLibLinphone ( Context c ) { } private synchronized void initLiblinphone ( ) throws LinphoneCoreException { } private void copyAssetsFromPackage ( ) throws IOException { } public void copyIfNotExist ( int ressourceId , String target ) throws IOException { } public void copyFromPackage ( int ressourceId , String target ) throws IOException { } public boolean detectVideoCodec ( String mime ) { } public boolean detectAudioCodec ( String mime ) { } public void updateNetworkReachability ( ) { } @ TargetApi ( VERSION_CODES . HONEYCOMB ) private void doDestroy ( ) { } public static synchronized void destroy ( ) { } private String getString ( int key ) { } public void connectivityChanged ( ConnectivityManager cm , boolean noConnectivity ) { } public interface EcCalibrationListener { void onEcCalibrationStatus ( EcCalibratorStatus status , int delayMs ) { } } private LinphoneCall ringingCall ; private MediaPlayer mRingerPlayer ; private Vibrator mVibrator ; public void displayWarning ( LinphoneCore lc , String message ) { } public void authInfoRequested ( LinphoneCore lc , String realm , String username , String domain ) { } public void byeReceived ( LinphoneCore lc , String from ) { } public void displayMessage ( LinphoneCore lc , String message ) { } public void show ( LinphoneCore lc ) { }

Fix:
if ( ( state == ( State . FileTransferDone ) ) || ( state == ( State . FileTransferError ) ) ) {