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

Commit b997c1f1 authored by Zach Johnson's avatar Zach Johnson
Browse files

Implement isEnabled in terms of getState

Bug: 145171640
Test: compile & check everything works normally
Change-Id: I169e220ab83546d76317e518652c66c9bd2229a2
parent eeccce5a
Loading
Loading
Loading
Loading
+1 −12
Original line number Diff line number Diff line
@@ -830,18 +830,7 @@ public final class BluetoothAdapter {
     */
    @RequiresPermission(Manifest.permission.BLUETOOTH)
    public boolean isEnabled() {
        try {
            mServiceLock.readLock().lock();
            if (mService != null) {
                return mService.isEnabled();
            }
        } catch (RemoteException e) {
            Log.e(TAG, "", e);
        } finally {
            mServiceLock.readLock().unlock();
        }

        return false;
        return getState() == BluetoothAdapter.STATE_ON;
    }

    /**
+1 −16
Original line number Diff line number Diff line
@@ -613,22 +613,7 @@ class BluetoothManagerService extends IBluetoothManager.Stub {
    }

    public boolean isEnabled() {
        if ((Binder.getCallingUid() != Process.SYSTEM_UID) && (!checkIfCallerIsForegroundUser())) {
            Slog.w(TAG, "isEnabled(): not allowed for non-active and non system user");
            return false;
        }

        try {
            mBluetoothLock.readLock().lock();
            if (mBluetooth != null) {
                return mBluetooth.isEnabled();
            }
        } catch (RemoteException e) {
            Slog.e(TAG, "isEnabled()", e);
        } finally {
            mBluetoothLock.readLock().unlock();
        }
        return false;
        return getState() == BluetoothAdapter.STATE_ON;
    }

    public int getState() {