Use strong reference to parent Handle when creating layer

If LayerCreatedState holds a weak reference to the parent handle
the following can occur:
1. handleLayerCreatedLocked is called and promotes the handle to
a strong ref.

2. The client reference to that layer is removed.

3. When handleLayerCreatedLocked returns, the last reference is
dropped. The Handle dtor is called which then calls
onHandleDestroyed. That function tries to acquire the lock, but
it's already held by the caller.

4. This will cause a deadlock.

Instead, hold a strong reference in the LayerCreatedState. The
reference will be held until flushTransactionQueues finishes,
which will then clear the Handle reference. This occurs outside
the lock so there should be no issue

Fixes: 202621651
Test: Hard to reproduce, but no other issues
Change-Id: I0b1ea54b63cbdef1fcf96eedffa4fbfa6959f697
2 files changed