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

Commit 8570c5a1 authored by Xiaohui Niu's avatar Xiaohui Niu Committed by Daniel Norman
Browse files

Fix NPE in UiAutomationManager

Fix a race condition that UiAutomationService is
destroyed just before main thread processes the
connection.

Bug: 328277279
Test: UiAutomationManagerTest
Change-Id: I0352ad255930ed58c111d5733e7ca2ae75fdf8fa
parent 056e11e8
Loading
Loading
Loading
Loading
+4 −2
Original line number Diff line number Diff line
@@ -272,8 +272,10 @@ class UiAutomationManager {
            mMainHandler.post(() -> {
                try {
                    final IAccessibilityServiceClient serviceInterface;
                    final UiAutomationService uiAutomationService;
                    synchronized (mLock) {
                        serviceInterface = mServiceInterface;
                        uiAutomationService = mUiAutomationService;
                        if (serviceInterface == null) {
                            mService = null;
                        } else {
@@ -283,8 +285,8 @@ class UiAutomationManager {
                    }
                    // If the serviceInterface is null, the UiAutomation has been shut down on
                    // another thread.
                    if (serviceInterface != null) {
                        mUiAutomationService.addWindowTokensForAllDisplays();
                    if (serviceInterface != null && uiAutomationService != null) {
                        uiAutomationService.addWindowTokensForAllDisplays();
                        if (mTrace.isA11yTracingEnabledForTypes(
                                AccessibilityTrace.FLAGS_ACCESSIBILITY_SERVICE_CLIENT)) {
                            mTrace.logTrace("UiAutomationService.connectServiceUnknownThread",