summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLinux Build Service Account <lnxbuild@localhost>2015-03-09 14:08:03 -0700
committerGerrit - the friendly Code Review server <code-review@localhost>2015-03-09 14:08:03 -0700
commit4b4d8147e1a58f20ac8b39d1e78b623d8f38633d (patch)
tree224c9ddbd91cb1dd74bbca8d9efae125d7d4cd5e
parenta821192ace9732295abee7e3c0837339b084d847 (diff)
parent39b40fa22cb25a9471d6ce51871338ee3df9499f (diff)
downloadandroid_packages_apps_Bluetooth-4b4d8147e1a58f20ac8b39d1e78b623d8f38633d.tar.gz
android_packages_apps_Bluetooth-4b4d8147e1a58f20ac8b39d1e78b623d8f38633d.tar.bz2
android_packages_apps_Bluetooth-4b4d8147e1a58f20ac8b39d1e78b623d8f38633d.zip
Merge "Bluetooth-OPP: Check socket congestion status before writing the data"
-rw-r--r--src/com/android/bluetooth/opp/BluetoothOppObexClientSession.java14
-rw-r--r--src/com/android/bluetooth/opp/BluetoothOppTransport.java15
2 files changed, 29 insertions, 0 deletions
diff --git a/src/com/android/bluetooth/opp/BluetoothOppObexClientSession.java b/src/com/android/bluetooth/opp/BluetoothOppObexClientSession.java
index 6684b1fd7..0b480e70b 100644
--- a/src/com/android/bluetooth/opp/BluetoothOppObexClientSession.java
+++ b/src/com/android/bluetooth/opp/BluetoothOppObexClientSession.java
@@ -587,6 +587,20 @@ public class BluetoothOppObexClientSession implements BluetoothOppObexSession {
}
readLength = a.read(buffer, 0, outputBufferSize);
+
+ while (true) {
+ int congStatus = ((BluetoothOppTransport)mTransport1).getSockCongStatus();
+ if ((congStatus == 0) || (congStatus == -1)) {
+ break;
+ }
+ try {
+ Thread.sleep(5);
+ } catch (InterruptedException slpe) {
+ Log.v(TAG, "Interrupted while checking the socket congestion evt");
+ break;
+ }
+ }
+
int writtenLength = 0;
while (writtenLength != readLength) {
//SET MTU SIZE BEFORE WRITE
diff --git a/src/com/android/bluetooth/opp/BluetoothOppTransport.java b/src/com/android/bluetooth/opp/BluetoothOppTransport.java
index 25c66fc7e..0615c1899 100644
--- a/src/com/android/bluetooth/opp/BluetoothOppTransport.java
+++ b/src/com/android/bluetooth/opp/BluetoothOppTransport.java
@@ -99,6 +99,21 @@ public class BluetoothOppTransport implements ObexTransport {
return status;
}
+ /**
+ * Returns the Congestion status of the Socket
+ */
+ public int getSockCongStatus() {
+ ByteBuffer bb = ByteBuffer.allocate(4);
+ bb.order(ByteOrder.LITTLE_ENDIAN);
+ int status;
+ try {
+ status = mSocket.getSocketOpt(5, bb.array());
+ } catch (IOException ex) {
+ return -1;
+ }
+ return bb.getInt();
+ }
+
public void connect() throws IOException {
}