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

Commit 35630d26 authored by android-build-team Robot's avatar android-build-team Robot
Browse files

Snap for 6374687 from 1ff0d350eb768ca44e0b0d5fdf117c0819ec810d to rvc-release

Change-Id: I77ac8c79681f06386e56e99c80c6b93835491615
parents 079ff576 96914087
Loading
Loading
Loading
Loading
+23 −9
Original line number Diff line number Diff line
@@ -979,17 +979,14 @@ public final class BluetoothAdapter {
                8, BLUETOOTH_GET_STATE_CACHE_PROPERTY) {
                @Override
                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 {
                        mServiceLock.readLock().lock();
                        if (mService != null) {
                        return mService.getState();
                        }
                    } catch (RemoteException e) {
                        Log.e(TAG, "", e);
                    } finally {
                        mServiceLock.readLock().unlock();
                        throw e.rethrowFromSystemServer();
                    }
                    return BluetoothAdapter.STATE_OFF;
                }
            };

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

        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
        if (state == BluetoothAdapter.STATE_BLE_ON || state == BluetoothAdapter.STATE_BLE_TURNING_ON