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

Commit 99e2b6c1 authored by Daniel's avatar Daniel Committed by Daniel Kim
Browse files

Fix deadlock by not acquiring lock when reporting proximity

There is a deadlock situation from AttentionManagerService acquiring
lock before callings back to its clients with the proximity update. This
can cause a deadlock because the clients, while holding their own locks,
can call AttentionManagerService again.

Thread 1:
  Acquires attention lock -> AttentionManager Service reports proximityUpdate to VoiceInteraction -> tries to acquire voice lock

Thread 2:
  Acquires voice lock -> VoiceService tries to cancel proximity updates
  -> tries to acquire attention lock

The deadlock can be fixed by removing the acquiring attention lock step
before reporting proximityUpdates to the clients.

Bug: 261143716
Test: atest CtsAttentionServiceDeviceTestCases
Change-Id: I9f7d520cbcfd57032a9476853acad025fd7a6b95
Merged-In: I9f7d520cbcfd57032a9476853acad025fd7a6b95
(cherry picked from commit a28af297)
parent fa71876c
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -668,8 +668,8 @@ public class AttentionManagerService extends SystemService {
            mIProximityUpdateCallback = new IProximityUpdateCallback.Stub() {
                @Override
                public void onProximityUpdate(double distance) {
                    synchronized (mLock) {
                    mCallbackInternal.onProximityUpdate(distance);
                    synchronized (mLock) {
                        freeIfInactiveLocked();
                    }
                }