summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--android/app/src/com/android/bluetooth/btservice/AdapterService.java9
-rw-r--r--framework/java/android/bluetooth/BluetoothSocket.java29
-rw-r--r--system/binder/android/bluetooth/IBluetooth.aidl2
3 files changed, 8 insertions, 32 deletions
diff --git a/android/app/src/com/android/bluetooth/btservice/AdapterService.java b/android/app/src/com/android/bluetooth/btservice/AdapterService.java
index 4df7116a38..43d8f11487 100644
--- a/android/app/src/com/android/bluetooth/btservice/AdapterService.java
+++ b/android/app/src/com/android/bluetooth/btservice/AdapterService.java
@@ -2969,14 +2969,7 @@ public class AdapterService extends Service {
}
@Override
- public void getSocketManager(SynchronousResultReceiver receiver) {
- try {
- receiver.send(getSocketManager());
- } catch (RuntimeException e) {
- receiver.propagateException(e);
- }
- }
- private IBluetoothSocketManager getSocketManager() {
+ public IBluetoothSocketManager getSocketManager() {
AdapterService service = getService();
if (service == null) {
return null;
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());
}
diff --git a/system/binder/android/bluetooth/IBluetooth.aidl b/system/binder/android/bluetooth/IBluetooth.aidl
index b7d40682b2..369f7e5410 100644
--- a/system/binder/android/bluetooth/IBluetooth.aidl
+++ b/system/binder/android/bluetooth/IBluetooth.aidl
@@ -180,7 +180,7 @@ interface IBluetooth
// For Socket
@JavaPassthrough(annotation="@android.annotation.RequiresNoPermission")
- oneway void getSocketManager(in SynchronousResultReceiver receiver);
+ IBluetoothSocketManager getSocketManager();
@JavaPassthrough(annotation="@android.annotation.RequiresPermission(allOf={android.Manifest.permission.BLUETOOTH_CONNECT,android.Manifest.permission.BLUETOOTH_PRIVILEGED})")
oneway void factoryReset(in AttributionSource attributionSource, in SynchronousResultReceiver receiver);