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

Commit 1647128a authored by William Escande's avatar William Escande Committed by Gerrit Code Review
Browse files

Merge "Use SynchronousResultReceiver when fetching Gatt" into main

parents 2c060396 2c953746
Loading
Loading
Loading
Loading
+11 −4
Original line number Diff line number Diff line
@@ -66,7 +66,6 @@ import android.bluetooth.IBluetooth;
import android.bluetooth.IBluetoothActivityEnergyInfoListener;
import android.bluetooth.IBluetoothCallback;
import android.bluetooth.IBluetoothConnectionCallback;
import android.bluetooth.IBluetoothGatt;
import android.bluetooth.IBluetoothMetadataListener;
import android.bluetooth.IBluetoothOobDataCallback;
import android.bluetooth.IBluetoothPreferredAudioProfilesCallback;
@@ -5179,7 +5178,15 @@ public class AdapterService extends Service {
        }

        @Override
        public IBluetoothGatt getBluetoothGatt() {
        public void getBluetoothGatt(SynchronousResultReceiver receiver) {
            try {
                receiver.send(getBluetoothGatt());
            } catch (RuntimeException e) {
                receiver.propagateException(e);
            }
        }

        private IBinder getBluetoothGatt() {
            AdapterService service = getService();
            if (service == null) {
                return null;
@@ -6841,11 +6848,11 @@ public class AdapterService extends Service {
        return BluetoothStatusCodes.FEATURE_NOT_SUPPORTED;
    }

    IBluetoothGatt getBluetoothGatt() {
    IBinder getBluetoothGatt() {
        if (mGattService == null) {
            return null;
        }
        return IBluetoothGatt.Stub.asInterface(((ProfileService) mGattService).getBinder());
        return ((ProfileService) mGattService).getBinder();
    }

    void unregAllGattClient(AttributionSource source) {
+6 −2
Original line number Diff line number Diff line
@@ -4219,9 +4219,13 @@ public final class BluetoothAdapter {
        mServiceLock.readLock().lock();
        try {
            if (mService != null) {
                return mService.getBluetoothGatt();
                final SynchronousResultReceiver<IBinder> recv = SynchronousResultReceiver.get();
                mService.getBluetoothGatt(recv);
                return IBluetoothGatt.Stub.asInterface(
                        recv.awaitResultNoInterrupt(getSyncTimeout()).getValue(null));
            }
        } catch (RemoteException e) {

        } catch (RemoteException | TimeoutException e) {
            Log.e(TAG, e.toString() + "\n" + Log.getStackTraceString(new Throwable()));
        } finally {
            mServiceLock.readLock().unlock();
+1 −1
Original line number Diff line number Diff line
@@ -305,7 +305,7 @@ interface IBluetooth
    oneway void isMediaProfileConnected(in AttributionSource attributionSource, in SynchronousResultReceiver receiver);

    @JavaPassthrough(annotation="@android.annotation.RequiresNoPermission")
    IBluetoothGatt getBluetoothGatt();
    oneway void getBluetoothGatt(in SynchronousResultReceiver receiver);

    @JavaPassthrough(annotation="@android.annotation.RequiresPermission(android.Manifest.permission.BLUETOOTH_CONNECT)")
    oneway void unregAllGattClient(in AttributionSource attributionSource, in SynchronousResultReceiver receiver);