Workaround to use System UI Context

... for SystemGesturesPointerEventListener

This CL passes System UI Context to SystemGesturesPointerEventListener
instead of System Context's DisplayContext because DisplayContext is
not a UI context and violates IncorrectContextViolation when trying
to access GestureDetector.

Note that we should still migrate the usage to window context because it
may still an issue if device can change its display metrics at runtime.
[1] attempted to do so but hit performance issue b/181814478.

[1]: 68c3024767

Bug: 177650348
Test: atest WmTests
Change-Id: Ie7695270d2e2dd15c749c07c2bde2f6f98bc5b59
This commit is contained in:
Charles Chen
2021-03-15 20:35:45 +08:00
parent a7ee1a9a49
commit 2a1120fac4

View File

@@ -448,7 +448,8 @@ public class DisplayPolicy {
final Looper looper = UiThread.getHandler().getLooper();
mHandler = new PolicyHandler(looper);
mSystemGestures = new SystemGesturesPointerEventListener(mContext, mHandler,
// TODO(b/181821798) Migrate SystemGesturesPointerEventListener to use window context.
mSystemGestures = new SystemGesturesPointerEventListener(mUiContext, mHandler,
new SystemGesturesPointerEventListener.Callbacks() {
@Override
public void onSwipeFromTop() {