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

Commit 57993d2f authored by William Escande's avatar William Escande Committed by Automerger Merge Worker
Browse files

Merge "Use SynchronousResultReceiver when fetching Gatt" into main am: 1647128a am: 069d68ca

parents 5e9565f9 069d68ca
Loading
Loading
Loading
Loading
+11 −4
Original line number Diff line number Diff line
@@ -68,7 +68,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;
@@ -5194,7 +5193,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;
@@ -6856,11 +6863,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
@@ -4223,9 +4223,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);