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

Commit e3c63100 authored by Chun-Ku Lin's avatar Chun-Ku Lin
Browse files

Clear the messages and callbacks in the

AccessibilityInteractionController when the ViewRootImpl is detached
from the window.

Bug: 320701910
Test: atest AccessibilityInteractionControllerTest
Test: atest ViewRootImplTest
Flag: aconfig android.view.accessibility.prevent_leaking_viewrootimpl
DEVELOPMENT

Change-Id: Ia5ec32d82cc2a4d6d77b0539eec69d366defb5cd
parent 4487bc7f
Loading
Loading
Loading
Loading
+10 −0
Original line number Diff line number Diff line
@@ -48,6 +48,7 @@ import android.view.accessibility.AccessibilityNodeInfo;
import android.view.accessibility.AccessibilityNodeInfo.AccessibilityAction;
import android.view.accessibility.AccessibilityNodeProvider;
import android.view.accessibility.AccessibilityRequestPreparer;
import android.view.accessibility.Flags;
import android.view.accessibility.IAccessibilityInteractionConnectionCallback;
import android.window.ScreenCapture;

@@ -1285,6 +1286,15 @@ public final class AccessibilityInteractionController {
                (int) (sourceRectF.right + 0.5), (int) (sourceRectF.bottom + 0.5));
    }

    /**
     * Destroy {@link AccessibilityInteractionController} and clean up the pending actions.
     */
    public void destroy() {
        if (Flags.preventLeakingViewrootimpl()) {
            mHandler.removeCallbacksAndMessages(null);
        }
    }

    /**
     * This class encapsulates a prefetching strategy for the accessibility APIs for
     * querying window content. It is responsible to prefetch a batch of
+5 −0
Original line number Diff line number Diff line
@@ -6074,6 +6074,11 @@ public final class ViewRootImpl implements ViewParent,
        mAccessibilityInteractionConnectionManager.ensureNoConnection();
        mAccessibilityInteractionConnectionManager.ensureNoDirectConnection();
        removeSendWindowContentChangedCallback();
        if (android.view.accessibility.Flags.preventLeakingViewrootimpl()
                && mAccessibilityInteractionController != null) {
            mAccessibilityInteractionController.destroy();
            mAccessibilityInteractionController = null;
        }
        destroyHardwareRenderer();
+10 −0
Original line number Diff line number Diff line
@@ -141,6 +141,16 @@ flag {
    bug: "283323770"
}

flag {
    name: "prevent_leaking_viewrootimpl"
    namespace: "accessibility"
    description: "Clear pending messages and callbacks of the handler in AccessibilityInteractionController when the ViewRootImpl is detached from Window to prevent leaking ViewRootImpl"
    bug: "320701910"
    metadata {
        purpose: PURPOSE_BUGFIX
    }
}

flag {
    name: "support_system_pinch_zoom_opt_out_apis"
    namespace: "accessibility"