diff options
author | William Escande <wescande@google.com> | 2022-01-28 12:51:42 +0100 |
---|---|---|
committer | William Escande <wescande@google.com> | 2022-01-28 12:54:14 +0100 |
commit | 77a57ad9d0b49ba3fb8a33a954cf81ee6fa7c4d0 (patch) | |
tree | 90c6ffaa07bce445d1a911fc051ea6d4fe78c753 /framework/java/android | |
parent | e10aefec8c5d0787793fcb75ad21ac3c04c09fc4 (diff) |
Revert the getSocketManager Synchronous call
Fix: 216736996
Tag: #stability
Test: atest 'CtsBluetoothTestCases:android.bluetooth.cts.BasicAdapterTest#test_listenUsingRfcommWithServiceRecord'
Test: atest 'CtsBluetoothTestCases:android.bluetooth.cts.LeL2capSocketTest#testOpenInsecureLeL2capServerSocketOnce'
Ignore-AOSP-First: No such change on AOSP yet
Change-Id: I1242fd01105265949a59deca9bf45e99e2a12a38
Diffstat (limited to 'framework/java/android')
-rw-r--r-- | framework/java/android/bluetooth/BluetoothSocket.java | 29 |
1 files changed, 6 insertions, 23 deletions
diff --git a/framework/java/android/bluetooth/BluetoothSocket.java b/framework/java/android/bluetooth/BluetoothSocket.java index 7b5d2fe24b..a570f1f063 100644 --- a/framework/java/android/bluetooth/BluetoothSocket.java +++ b/framework/java/android/bluetooth/BluetoothSocket.java @@ -16,8 +16,6 @@ package android.bluetooth; -import static android.bluetooth.BluetoothUtils.getSyncTimeout; - import android.annotation.RequiresNoPermission; import android.annotation.RequiresPermission; import android.bluetooth.annotations.RequiresBluetoothConnectPermission; @@ -29,8 +27,6 @@ import android.os.ParcelUuid; import android.os.RemoteException; import android.util.Log; -import com.android.modules.utils.SynchronousResultReceiver; - import java.io.Closeable; import java.io.FileDescriptor; import java.io.IOException; @@ -41,7 +37,6 @@ import java.nio.ByteOrder; import java.util.Arrays; import java.util.Locale; import java.util.UUID; -import java.util.concurrent.TimeoutException; /** * A connected or connecting Bluetooth socket. @@ -432,11 +427,7 @@ public final class BluetoothSocket implements Closeable { IBluetooth bluetoothProxy = BluetoothAdapter.getDefaultAdapter().getBluetoothService(); if (bluetoothProxy == null) throw new IOException("Bluetooth is off"); - final SynchronousResultReceiver<IBluetoothSocketManager> recv = - new SynchronousResultReceiver(); - bluetoothProxy.getSocketManager(recv); - IBluetoothSocketManager socketManager = - recv.awaitResultNoInterrupt(getSyncTimeout()).getValue(null); + IBluetoothSocketManager socketManager = bluetoothProxy.getSocketManager(); if (socketManager == null) throw new IOException("bt get socket manager failed"); mPfd = socketManager.connectSocket(mDevice, mType, mUuid, mPort, getSecurityFlags()); synchronized (this) { @@ -460,7 +451,7 @@ public final class BluetoothSocket implements Closeable { } mSocketState = SocketState.CONNECTED; } - } catch (RemoteException | TimeoutException e) { + } catch (RemoteException e) { Log.e(TAG, e.toString() + "\n" + Log.getStackTraceString(new Throwable())); throw new IOException("unable to send RPC: " + e.getMessage()); } @@ -481,18 +472,14 @@ public final class BluetoothSocket implements Closeable { } try { if (DBG) Log.d(TAG, "bindListen(): mPort=" + mPort + ", mType=" + mType); - final SynchronousResultReceiver<IBluetoothSocketManager> recv = - new SynchronousResultReceiver(); - bluetoothProxy.getSocketManager(recv); - IBluetoothSocketManager socketManager = - recv.awaitResultNoInterrupt(getSyncTimeout()).getValue(null); + IBluetoothSocketManager socketManager = bluetoothProxy.getSocketManager(); if (socketManager == null) { Log.e(TAG, "bindListen() bt get socket manager failed"); return -1; } mPfd = socketManager .createSocketChannel(mType, mServiceName, mUuid, mPort, getSecurityFlags()); - } catch (RemoteException | TimeoutException e) { + } catch (RemoteException e) { Log.e(TAG, e.toString() + "\n" + Log.getStackTraceString(new Throwable())); return -1; } @@ -757,14 +744,10 @@ public final class BluetoothSocket implements Closeable { } if (DBG) Log.d(TAG, "requestMaximumTxDataLength"); - final SynchronousResultReceiver<IBluetoothSocketManager> recv = - new SynchronousResultReceiver(); - bluetoothProxy.getSocketManager(recv); - IBluetoothSocketManager socketManager = - recv.awaitResultNoInterrupt(getSyncTimeout()).getValue(null); + IBluetoothSocketManager socketManager = bluetoothProxy.getSocketManager(); if (socketManager == null) throw new IOException("bt get socket manager failed"); socketManager.requestMaximumTxDataLength(mDevice); - } catch (RemoteException | TimeoutException e) { + } catch (RemoteException e) { Log.e(TAG, e.toString() + "\n" + Log.getStackTraceString(new Throwable())); throw new IOException("unable to send RPC: " + e.getMessage()); } |