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

Commit f9f19c82 authored by Treehugger Robot's avatar Treehugger Robot Committed by Gerrit Code Review
Browse files

Merge "No longer call service to know its state"

parents fb5da8e9 1b715a66
Loading
Loading
Loading
Loading
+5 −46
Original line number Diff line number Diff line
@@ -491,16 +491,7 @@ class BluetoothManagerService {
                }
            }

            int st = STATE_OFF;
            try {
                mBluetoothLock.readLock().lock();
                st = synchronousGetState();
            } catch (RemoteException | TimeoutException e) {
                Log.e(TAG, "Unable to call getState", e);
                return;
            } finally {
                mBluetoothLock.readLock().unlock();
            }
            int st = mState.get();

            Log.d(
                    TAG,
@@ -1026,14 +1017,6 @@ class BluetoothManagerService {
        return recv.awaitResultNoInterrupt(getSyncTimeout()).getValue(null);
    }

    @GuardedBy("mBluetoothLock")
    private int synchronousGetState() throws RemoteException, TimeoutException {
        if (mBluetooth == null) return STATE_OFF;
        final SynchronousResultReceiver<Integer> recv = SynchronousResultReceiver.get();
        mBluetooth.getState(recv);
        return recv.awaitResultNoInterrupt(getSyncTimeout()).getValue(STATE_OFF);
    }

    @GuardedBy("mBluetoothLock")
    private void synchronousOnBrEdrDown(AttributionSource attributionSource)
            throws RemoteException, TimeoutException {
@@ -1111,17 +1094,7 @@ class BluetoothManagerService {
    }

    int getState() {
        mBluetoothLock.readLock().lock();
        try {
            if (mBluetooth != null) {
                return synchronousGetState();
            }
        } catch (RemoteException | TimeoutException e) {
            Log.e(TAG, "getState()", e);
        } finally {
            mBluetoothLock.readLock().unlock();
        }
        return STATE_OFF;
        return mState.get();
    }

    class ClientDeathRecipient implements IBinder.DeathRecipient {
@@ -1209,14 +1182,12 @@ class BluetoothManagerService {
    private void disableBleScanMode() {
        mBluetoothLock.writeLock().lock();
        try {
            if (mBluetooth != null && synchronousGetState() != STATE_ON) {
            if (mBluetooth != null && mState.oneOf(STATE_ON)) {
                if (DBG) {
                    Log.d(TAG, "Resetting the mEnable flag for clean disable");
                }
                mEnable = false;
            }
        } catch (RemoteException | TimeoutException e) {
            Log.e(TAG, "getState()", e);
        } finally {
            mBluetoothLock.writeLock().unlock();
        }
@@ -1765,18 +1736,7 @@ class BluetoothManagerService {
        }

        private boolean bindService(int rebindCount) {
            int state = STATE_OFF;
            try {
                mBluetoothLock.readLock().lock();
                state = synchronousGetState();
            } catch (RemoteException | TimeoutException e) {
                Log.e(TAG, "Unable to call getState", e);
                return false;
            } finally {
                mBluetoothLock.readLock().unlock();
            }

            if (state != STATE_ON) {
            if (!mState.oneOf(STATE_ON)) {
                if (DBG) {
                    Log.d(TAG, "Unable to bindService while Bluetooth is disabled");
                }
@@ -2138,8 +2098,7 @@ class BluetoothManagerService {
                    try {
                        if (mBluetooth != null) {
                            boolean isHandled = true;
                            int state = synchronousGetState();
                            switch (state) {
                            switch (mState.get()) {
                                case STATE_BLE_ON:
                                    if (isBle == 1) {
                                        Log.i(TAG, "Already at BLE_ON State");