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

Commit 1c287376 authored by jonerlin's avatar jonerlin Committed by android-build-merger
Browse files

Merge "AdapterService: Only bind HeadsetService in ON state."

am: 44bafe68

Change-Id: I1b6c2afc09c5eefd44efb0137fa4e466239839ca
parents b958fc80 44bafe68
Loading
Loading
Loading
Loading
+20 −0
Original line number Original line Diff line number Diff line
@@ -1161,6 +1161,26 @@ class BluetoothManagerService extends IBluetoothManager.Stub {
        }
        }


        private boolean bindService() {
        private boolean bindService() {
            int state = BluetoothAdapter.STATE_OFF;
            try {
                mBluetoothLock.readLock().lock();
                if (mBluetooth != null) {
                    state = mBluetooth.getState();
                }
            } catch (RemoteException e) {
                Slog.e(TAG, "Unable to call getState", e);
                return false;
            } finally {
                mBluetoothLock.readLock().unlock();
            }

            if (!mEnable || state != BluetoothAdapter.STATE_ON) {
                if (DBG) {
                    Slog.d(TAG, "Unable to bindService while Bluetooth is disabled");
                }
                return false;
            }

            if (mIntent != null && mService == null && doBind(mIntent, this, 0,
            if (mIntent != null && mService == null && doBind(mIntent, this, 0,
                    UserHandle.CURRENT_OR_SELF)) {
                    UserHandle.CURRENT_OR_SELF)) {
                Message msg = mHandler.obtainMessage(MESSAGE_BIND_PROFILE_SERVICE);
                Message msg = mHandler.obtainMessage(MESSAGE_BIND_PROFILE_SERVICE);