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

Commit 6829591c authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Automerger Merge Worker
Browse files

Merge "Revert "Fix exception handling in getState() binder cache"" into...

Merge "Revert "Fix exception handling in getState() binder cache"" into rvc-dev am: 58de85c4 am: 409b13db am: ae22de61 am: 3af7d8f0

Change-Id: I68f0bdf60a285e7bd1b811fdeea0a95c6e8c1d87
parents 05d5fc62 3af7d8f0
Loading
Loading
Loading
Loading
+9 −23
Original line number Original line Diff line number Diff line
@@ -979,14 +979,17 @@ public final class BluetoothAdapter {
                8, BLUETOOTH_GET_STATE_CACHE_PROPERTY) {
                8, BLUETOOTH_GET_STATE_CACHE_PROPERTY) {
                @Override
                @Override
                protected Integer recompute(Void query) {
                protected Integer recompute(Void query) {
                    // This function must be called while holding the
                    // mServiceLock, and with mService not null. The public
                    // getState() method makes this guarantee.
                    try {
                    try {
                        mServiceLock.readLock().lock();
                        if (mService != null) {
                            return mService.getState();
                            return mService.getState();
                        }
                    } catch (RemoteException e) {
                    } catch (RemoteException e) {
                        throw e.rethrowFromSystemServer();
                        Log.e(TAG, "", e);
                    } finally {
                        mServiceLock.readLock().unlock();
                    }
                    }
                    return BluetoothAdapter.STATE_OFF;
                }
                }
            };
            };


@@ -1013,24 +1016,7 @@ public final class BluetoothAdapter {
    @RequiresPermission(Manifest.permission.BLUETOOTH)
    @RequiresPermission(Manifest.permission.BLUETOOTH)
    @AdapterState
    @AdapterState
    public int getState() {
    public int getState() {
        int state = BluetoothAdapter.STATE_OFF;
        int state = mBluetoothGetStateCache.query(null);

        try {
            mServiceLock.readLock().lock();
            // The test for mService must either be outside the cache, or
            // the cache must be invalidated when mService changes.
            if (mService != null) {
                state = mBluetoothGetStateCache.query(null);
            }
        } catch (RuntimeException e) {
            if (e.getCause() instanceof RemoteException) {
                Log.e(TAG, "", e.getCause());
            } else {
                throw e;
            }
        } finally {
            mServiceLock.readLock().unlock();
        }


        // Consider all internal states as OFF
        // Consider all internal states as OFF
        if (state == BluetoothAdapter.STATE_BLE_ON || state == BluetoothAdapter.STATE_BLE_TURNING_ON
        if (state == BluetoothAdapter.STATE_BLE_ON || state == BluetoothAdapter.STATE_BLE_TURNING_ON