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

Commit 34459252 authored by Vishnu Nair's avatar Vishnu Nair
Browse files

Allow creating ASurfaceControl from NativeActivity Surface

When generating a Surface, we have the option to include the
associated SurfaceControl handle. This handle is necessary
for creating child ASurfaceControl parented to a ANW.
Previously, the SurfaceControl handle was only included in
the SurfaceView surface, but not in the viewrootimpl surface.
This meant NativeActivity users could not attach child
surfaces. Fix this by including the surfacecontrol handle
into the VRI surface.

Bug: 320706287
Test: atest FrameworksCoreTests:ViewRootImplTest
Change-Id: I0af8c1b53f616f2ec5fb4c927553d197d1192daa
parent 0552660d
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -835,8 +835,8 @@ public class Surface implements Parcelable {
    @Override
    public String toString() {
        synchronized (mLock) {
            return "Surface(name=" + mName + ")/@0x" +
                    Integer.toHexString(System.identityHashCode(this));
            return "Surface(name=" + mName + " mNativeObject=" + mNativeObject + ")/@0x"
                    + Integer.toHexString(System.identityHashCode(this));
        }
    }

+7 −1
Original line number Diff line number Diff line
@@ -111,6 +111,7 @@ import static android.view.WindowManagerGlobal.RELAYOUT_RES_SURFACE_CHANGED;
import static android.view.accessibility.Flags.fixMergedContentChangeEventV2;
import static android.view.accessibility.Flags.forceInvertColor;
import static android.view.accessibility.Flags.reduceWindowContentChangedEventThrottle;
import static android.view.flags.Flags.addSchandleToVriSurface;
import static android.view.flags.Flags.sensitiveContentAppProtection;
import static android.view.flags.Flags.toolkitFrameRateFunctionEnablingReadOnly;
import static android.view.flags.Flags.toolkitFrameRateTypingReadOnly;
@@ -2635,7 +2636,12 @@ public final class ViewRootImpl implements ViewParent,
        mBlastBufferQueue = new BLASTBufferQueue(mTag, mSurfaceControl,
                mSurfaceSize.x, mSurfaceSize.y, mWindowAttributes.format);
        mBlastBufferQueue.setTransactionHangCallback(sTransactionHangCallback);
        Surface blastSurface = mBlastBufferQueue.createSurface();
        Surface blastSurface;
        if (addSchandleToVriSurface()) {
            blastSurface = mBlastBufferQueue.createSurfaceWithHandle();
        } else {
            blastSurface = mBlastBufferQueue.createSurface();
        }
        // Only call transferFrom if the surface has changed to prevent inc the generation ID and
        // causing EGL resources to be recreated.
        mSurface.transferFrom(blastSurface);
+11 −0
Original line number Diff line number Diff line
@@ -59,3 +59,14 @@ flag {
    bug: "333752000"
    is_fixed_read_only: true
}

flag {
    name: "add_schandle_to_vri_surface"
    namespace: "window_surfaces"
    description: "Add surface control handle to VRI Surface"
    bug: "320706287"
    is_fixed_read_only: true
    metadata {
        purpose: PURPOSE_BUGFIX
    }
}
 No newline at end of file
+1 −0
Original line number Diff line number Diff line
@@ -116,6 +116,7 @@ android_test {
    ],
    jni_libs: [
        "libpowermanagertest_jni",
        "libviewRootImplTest_jni",
        "libworksourceparceltest_jni",
    ],

+24 −0
Original line number Diff line number Diff line
@@ -67,3 +67,27 @@ cc_test_library {
    ],
    gtest: false,
}

cc_test_library {
    name: "libviewRootImplTest_jni",
    srcs: [
        "ViewRootImplTestJni.cpp",
    ],
    shared_libs: [
        "libandroid",
        "libandroid_runtime_lazy",
        "libbase",
        "libbinder",
        "liblog",
        "libnativehelper",
        "libpowermanager",
        "libutils",
    ],
    header_libs: ["jni_headers"],
    stl: "libc++_static",
    cflags: [
        "-Werror",
        "-Wall",
    ],
    gtest: false,
}
Loading