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

Commit 34c69cb3 authored by Gurpreet Ghai's avatar Gurpreet Ghai Committed by Gerrit - the friendly Code Review server
Browse files

BT: Limiting the thread lock to critical part of state update

Issue: ANR occurs due to UI wait for long time waiting to
acquire thread lock.

Cause: The synchronized function that updates state also
read paired devices as an additional operation. When the
number of devices is cached list is large, the block time
for other threads waiting for same lock tends to increase
causing ANR in case of UI thread.

Measure: Limited the synchronized block to the part where
actual update of local state takes place.

CRs-Fixed: 1053291
Change-Id: I69ff9f8a032b3772bf3d048d8db70181319ad31d
parent b81e5ee8
Loading
Loading
Loading
Loading
+7 −2
Original line number Diff line number Diff line
@@ -186,8 +186,13 @@ public final class LocalBluetoothAdapter {
        return mState;
    }

    synchronized void setBluetoothStateInt(int state) {
    void setBluetoothStateInt(int state) {
        synchronized(this) {
            if(mState == state){
                return;
            }
            mState = state;
        }

        if (state == BluetoothAdapter.STATE_ON) {
            // if mProfileManager hasn't been constructed yet, it will