Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 1e56d510 authored by Treehugger Robot's avatar Treehugger Robot Committed by Gerrit Code Review
Browse files

Merge "OPP: Prevent NPE of mConnectThread"

parents d70a3cf2 bcbe0aad
Loading
Loading
Loading
Loading
+29 −18
Original line number Diff line number Diff line
@@ -82,6 +82,8 @@ public class BluetoothOppTransfer implements BluetoothOppBatch.BluetoothOppBatch

    private static final String SOCKET_LINK_KEY_ERROR = "Invalid exchange";

    private static final Object INSTANCE_LOCK = new Object();

    private Context mContext;

    private BluetoothAdapter mAdapter;
@@ -162,8 +164,10 @@ public class BluetoothOppTransfer implements BluetoothOppBatch.BluetoothOppBatch
                        markConnectionFailed(null);
                        return;
                    }
                    synchronized (INSTANCE_LOCK) {
                        mConnectThread =
                                new SocketConnectThread(mDevice, false, true, record.getL2capPsm());
                    }
                    mConnectThread.start();
                    mDevice = null;
                }
@@ -206,9 +210,10 @@ public class BluetoothOppTransfer implements BluetoothOppBatch.BluetoothOppBatch
            switch (msg.what) {
                case SOCKET_ERROR_RETRY:
                    BluetoothDevice device = (BluetoothDevice) msg.obj;
                    synchronized (INSTANCE_LOCK) {
                        mConnectThread = new SocketConnectThread(device, true);

                        mConnectThread.start();
                    }
                    break;
                case TRANSPORT_ERROR:
                    /*
@@ -218,7 +223,9 @@ public class BluetoothOppTransfer implements BluetoothOppBatch.BluetoothOppBatch
                    if (V) {
                        Log.v(TAG, "receive TRANSPORT_ERROR msg");
                    }
                    synchronized (INSTANCE_LOCK) {
                        mConnectThread = null;
                    }
                    markBatchFailed(BluetoothShare.STATUS_CONNECTION_ERROR);
                    mBatch.mStatus = Constants.BATCH_STATUS_FAILED;

@@ -231,7 +238,9 @@ public class BluetoothOppTransfer implements BluetoothOppBatch.BluetoothOppBatch
                    if (V) {
                        Log.v(TAG, "Transfer receive TRANSPORT_CONNECTED msg");
                    }
                    synchronized (INSTANCE_LOCK) {
                        mConnectThread = null;
                    }
                    mTransport = (ObexTransport) msg.obj;
                    startObexSession();

@@ -514,6 +523,7 @@ public class BluetoothOppTransfer implements BluetoothOppBatch.BluetoothOppBatch
        }

        cleanUp();
        synchronized (INSTANCE_LOCK) {
            if (mConnectThread != null) {
                try {
                    mConnectThread.interrupt();
@@ -528,6 +538,7 @@ public class BluetoothOppTransfer implements BluetoothOppBatch.BluetoothOppBatch
                }
                mConnectThread = null;
            }
        }
        // Prevent concurrent access
        synchronized (this) {
            if (mHandlerThread != null) {