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

Commit 39593580 authored by Mark Renouf's avatar Mark Renouf
Browse files

Check that the root view exists

Bug: 325469181
Test: NA - protection against an unknown race condition
Flag: NONE - low risk bug fix
Change-Id: I78ef3f0319147ea12333b7eba39488c9fc99aae0
parent b04d4f17
Loading
Loading
Loading
Loading
+28 −5
Original line number Diff line number Diff line
@@ -11502,12 +11502,24 @@ public final class ViewRootImpl implements ViewParent,
        // Search through View-tree
        View rootView = getView();
        if (rootView != null) {
        if (rootView == null) {
            ScrollCaptureResponse.Builder response = new ScrollCaptureResponse.Builder();
            response.setWindowTitle(getTitle().toString());
            response.setPackageName(mContext.getPackageName());
            response.setDescription("The root view was null");
            try {
                listener.onScrollCaptureResponse(response.build());
            } catch (RemoteException e) {
                Log.e(TAG, "Failed to send scroll capture search result", e);
            }
            return;
        }
        Point point = new Point();
        Rect rect = new Rect(0, 0, rootView.getWidth(), rootView.getHeight());
        getChildVisibleRect(rootView, rect, point);
        rootView.dispatchScrollCaptureSearch(rect, point, results::addTarget);
        }
        Runnable onComplete = () -> dispatchScrollCaptureSearchResponse(listener, results);
        results.setOnCompleteListener(onComplete);
        if (!results.isComplete()) {
@@ -11532,6 +11544,16 @@ public final class ViewRootImpl implements ViewParent,
        pw.flush();
        response.addMessage(writer.toString());
        if (mView == null) {
            response.setDescription("The root view disappeared!");
            try {
                listener.onScrollCaptureResponse(response.build());
            } catch (RemoteException e) {
                Log.e(TAG, "Failed to send scroll capture search result", e);
            }
            return;
        }
        if (selectedTarget == null) {
            response.setDescription("No scrollable targets found in window");
            try {
@@ -11558,6 +11580,7 @@ public final class ViewRootImpl implements ViewParent,
        boundsOnScreen.set(0, 0, mView.getWidth(), mView.getHeight());
        boundsOnScreen.offset(mAttachInfo.mTmpLocation[0], mAttachInfo.mTmpLocation[1]);
        response.setWindowBounds(boundsOnScreen);
        Log.d(TAG, "ScrollCaptureSearchResponse: " + response);
        // Create a connection and return it to the caller
        ScrollCaptureConnection connection = new ScrollCaptureConnection(