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

Commit 7dffa0cc authored by Chavi Weingarten's avatar Chavi Weingarten
Browse files

Request embedded focus if a SurfacePackage was added to SV

If the SV was already focus when a SurfacePackage is attached, it should
request focus to the embedded. This allows focus to work better for the
developer perspective since they don't have to understand the timing of
when a SurfacePackage is attached vs when a view gains focus.

Test: SurfaceControlViewHostTests
Bug: 230340812
Change-Id: If55b33e92769e37794bd258e7f41da40decbef8c
parent 0706346f
Loading
Loading
Loading
Loading
+9 −1
Original line number Diff line number Diff line
@@ -1854,6 +1854,10 @@ public class SurfaceView extends View implements ViewRootImpl.SurfaceChangedCall
            applyTransactionOnVriDraw(transaction);
        }
        mSurfacePackage = p;

        if (isFocused()) {
            requestEmbeddedFocus(true);
        }
        invalidate();
    }

@@ -1949,6 +1953,10 @@ public class SurfaceView extends View implements ViewRootImpl.SurfaceChangedCall
    protected void onFocusChanged(boolean gainFocus, @FocusDirection int direction,
            @Nullable Rect previouslyFocusedRect) {
        super.onFocusChanged(gainFocus, direction, previouslyFocusedRect);
        requestEmbeddedFocus(gainFocus);
    }

    private void requestEmbeddedFocus(boolean gainFocus) {
        final ViewRootImpl viewRoot = getViewRootImpl();
        if (mSurfacePackage == null || viewRoot == null) {
            return;