diff options
author | Tao Liejun <L.J.Tao@motorola.com> | 2009-08-31 10:48:23 +0800 |
---|---|---|
committer | Nick Pelly <npelly@google.com> | 2009-08-31 21:02:23 -0700 |
commit | 888485a3f5fe991116c5536bb6d6903d47b63a70 (patch) | |
tree | 814360447d24cac9f120c9bec09d1dd88ad9fdeb /src/com/android/bluetooth/opp/BluetoothOppTransfer.java | |
parent | 32e47df203390052c1ef771d78b22fc4aa5f9e72 (diff) | |
download | android_packages_apps_Bluetooth-888485a3f5fe991116c5536bb6d6903d47b63a70.tar.gz android_packages_apps_Bluetooth-888485a3f5fe991116c5536bb6d6903d47b63a70.tar.bz2 android_packages_apps_Bluetooth-888485a3f5fe991116c5536bb6d6903d47b63a70.zip |
Cleanup Opp debug code
Stop Rfcomm polling
Delete a few unused functions
Diffstat (limited to 'src/com/android/bluetooth/opp/BluetoothOppTransfer.java')
-rw-r--r-- | src/com/android/bluetooth/opp/BluetoothOppTransfer.java | 42 |
1 files changed, 25 insertions, 17 deletions
diff --git a/src/com/android/bluetooth/opp/BluetoothOppTransfer.java b/src/com/android/bluetooth/opp/BluetoothOppTransfer.java index 80cf16da6..6be6d2d48 100644 --- a/src/com/android/bluetooth/opp/BluetoothOppTransfer.java +++ b/src/com/android/bluetooth/opp/BluetoothOppTransfer.java @@ -61,7 +61,9 @@ import java.util.UUID; */ public class BluetoothOppTransfer implements BluetoothOppBatch.BluetoothOppBatchListener { private static final String TAG = "BtOppTransfer"; + private static final boolean D = Constants.DEBUG; + private static final boolean V = Constants.VERBOSE; public static final int RFCOMM_ERROR = 10; @@ -111,7 +113,7 @@ public class BluetoothOppTransfer implements BluetoothOppBatch.BluetoothOppBatch mSession = session; mBatch.registerListern(this); - mAdapter = (BluetoothAdapter) mContext.getSystemService(Context.BLUETOOTH_SERVICE); + mAdapter = (BluetoothAdapter)mContext.getSystemService(Context.BLUETOOTH_SERVICE); } @@ -191,7 +193,7 @@ public class BluetoothOppTransfer implements BluetoothOppBatch.BluetoothOppBatch if (mCurrentShare != null) { /* we have additional share to process */ if (V) Log.v(TAG, "continue session for info " + mCurrentShare.mId + - " from batch " + mBatch.mId); + " from batch " + mBatch.mId); processCurrentShare(); } else { /* for outbound transfer, all shares are processed */ @@ -538,7 +540,7 @@ public class BluetoothOppTransfer implements BluetoothOppBatch.BluetoothOppBatch if (isOpush) { channel = mBatch.mDestination.getServiceChannel(savedUuid); if (D) Log.d(TAG, "Get OPUSH channel " + channel + " from SDP for " + - mBatch.mDestination); + mBatch.mDestination); if (channel != -1) { mConnectThread = new SocketConnectThread(mBatch.mDestination, channel); mConnectThread.start(); @@ -556,11 +558,15 @@ public class BluetoothOppTransfer implements BluetoothOppBatch.BluetoothOppBatch private class SocketConnectThread extends Thread { private final String host; + private final BluetoothDevice device; + private final int channel; private boolean isConnected; + private long timestamp; + private BluetoothSocket btSocket = null; /* create a TCP socket */ @@ -663,25 +669,27 @@ public class BluetoothOppTransfer implements BluetoothOppBatch.BluetoothOppBatch } try { btSocket.connect(); + + if (V) Log.v(TAG, "Rfcomm socket connection attempt took " + + (System.currentTimeMillis() - timestamp) + " ms"); + BluetoothOppRfcommTransport transport; + transport = new BluetoothOppRfcommTransport(btSocket); + + BluetoothOppPreference.getInstance(mContext).setChannel(device, OPUSH_UUID16, + channel); + BluetoothOppPreference.getInstance(mContext).setName(device, device.getName()); + + if (V) Log.v(TAG, "Send transport message " + transport.toString()); + + mSessionHandler.obtainMessage(RFCOMM_CONNECTED, transport).sendToTarget(); } catch (IOException e) { Log.e(TAG, "Rfcomm socket connect exception "); + BluetoothOppPreference.getInstance(mContext) + .removeChannel(device, OPUSH_UUID16); markConnectionFailed(btSocket); return; } - - if (V) Log.v(TAG, "Rfcomm socket connection attempt took " + - (System.currentTimeMillis() - timestamp) + " ms"); - BluetoothOppRfcommTransport transport; - transport = new BluetoothOppRfcommTransport(btSocket); - - BluetoothOppPreference.getInstance(mContext).setChannel(device, OPUSH_UUID16, - channel); - BluetoothOppPreference.getInstance(mContext).setName(device, device.getName()); - - if (V) Log.v(TAG, "Send transport message " + transport.toString()); - mSessionHandler.obtainMessage(RFCOMM_CONNECTED, transport).sendToTarget(); } - } private void markConnectionFailed(Socket s) { @@ -733,7 +741,7 @@ public class BluetoothOppTransfer implements BluetoothOppBatch.BluetoothOppBatch && mCurrentShare.mConfirm == BluetoothShare.USER_CONFIRMATION_AUTO_CONFIRMED) { /* have additional auto confirmed share to process */ if (V) Log.v(TAG, "Transfer continue session for info " + mCurrentShare.mId + - " from batch " + mBatch.mId); + " from batch " + mBatch.mId); processCurrentShare(); setConfirmed(); } |