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

Commit c0177cf0 authored by Christine Hallstrom's avatar Christine Hallstrom Committed by android-build-merger
Browse files

Merge "Properly check if BT is off when shutting down radios" into nyc-mr1-dev

am: 0f760e0815

* commit '0f760e081570cb7fe3ac7dd6a86125a8f79e5b34':
  Properly check if BT is off when shutting down radios

Change-Id: I7d3b2d40664115555db897b46b3debc5b2c04f8d
parents 96de3487 302a1abc
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -37,6 +37,7 @@ interface IBluetoothManager
    boolean enable();
    boolean enableNoAutoConnect();
    boolean disable(boolean persist);
    int getState();
    IBluetoothGatt getBluetoothGatt();

    boolean bindBluetoothProfileService(int profile, IBluetoothProfileServiceConnection proxy);
+18 −0
Original line number Diff line number Diff line
@@ -425,6 +425,24 @@ class BluetoothManagerService extends IBluetoothManager.Stub {
        return false;
    }

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

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

    class ClientDeathRecipient implements IBinder.DeathRecipient {
        public void binderDied() {
            if (DBG) Slog.d(TAG, "Binder is dead -  unregister Ble App");