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

Commit 5fea55b2 authored by Robert Carr's avatar Robert Carr
Browse files

Remove usage of scoped connections.

Tracking SurfaceFlinger changes. Now to construct a child surface
we need the SurfaceControl as opposed to just the surface, and so
we parcel the SurfaceControl across relayout.

Test: Manual
Bug: 62536731
Bug: 111373437
Bug: 111297488
Change-Id: I0a034767e92becec63071d7b1e3e71b95d505b77
parent beb7a0cf
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
@@ -320,7 +320,7 @@ public class ActivityView extends ViewGroup {
        public void surfaceCreated(SurfaceHolder surfaceHolder) {
            mTmpSurface = new Surface();
            if (mVirtualDisplay == null) {
                initVirtualDisplay(new SurfaceSession(surfaceHolder.getSurface()));
                initVirtualDisplay(new SurfaceSession());
                if (mVirtualDisplay != null && mActivityViewCallback != null) {
                    mActivityViewCallback.onActivityViewReady(ActivityView.this);
                }
@@ -382,6 +382,7 @@ public class ActivityView extends ViewGroup {

        mRootSurfaceControl = new SurfaceControl.Builder(surfaceSession)
                .setContainerLayer(true)
                .setParent(mSurfaceView.getSurfaceControl())
                .setName(DISPLAY_NAME)
                .build();

+8 −1
Original line number Diff line number Diff line
@@ -56,6 +56,7 @@ import android.view.InputEvent;
import android.view.InputEventReceiver;
import android.view.InsetsState;
import android.view.MotionEvent;
import android.view.SurfaceControl;
import android.view.SurfaceHolder;
import android.view.View;
import android.view.ViewGroup;
@@ -217,6 +218,8 @@ public abstract class WallpaperService extends Service {
        private Context mDisplayContext;
        private int mDisplayState;

        SurfaceControl mSurfaceControl = new SurfaceControl();

        final BaseSurfaceHolder mSurfaceHolder = new BaseSurfaceHolder() {
            {
                mRequestedFormat = PixelFormat.RGBX_8888;
@@ -843,8 +846,12 @@ public abstract class WallpaperService extends Service {
                        mWindow, mWindow.mSeq, mLayout, mWidth, mHeight,
                            View.VISIBLE, 0, -1, mWinFrame, mOverscanInsets, mContentInsets,
                            mVisibleInsets, mStableInsets, mOutsets, mBackdropFrame,
                            mDisplayCutout, mMergedConfiguration, mSurfaceHolder.mSurface,
                            mDisplayCutout, mMergedConfiguration, mSurfaceControl,
                            mInsetsState);
                    if (mSurfaceControl.isValid()) {
                        mSurfaceHolder.mSurface.copyFrom(mSurfaceControl);
                        mSurfaceControl.release();
                    }

                    if (DEBUG) Log.v(TAG, "New surface: " + mSurfaceHolder.mSurface
                            + ", frame=" + mWinFrame);
+1 −1
Original line number Diff line number Diff line
@@ -99,7 +99,7 @@ interface IWindowSession {
            out Rect outContentInsets, out Rect outVisibleInsets, out Rect outStableInsets,
            out Rect outOutsets, out Rect outBackdropFrame,
            out DisplayCutout.ParcelableWrapper displayCutout,
            out MergedConfiguration outMergedConfiguration, out Surface outSurface,
            out MergedConfiguration outMergedConfiguration, out SurfaceControl outSurfaceControl,
            out InsetsState insetsState);

    /*
+20 −1
Original line number Diff line number Diff line
@@ -683,7 +683,13 @@ public class SurfaceControl implements Parcelable {
        mName = in.readString();
        mWidth = in.readInt();
        mHeight = in.readInt();

        release();
        if (in.readInt() != 0) {
            mNativeObject = nativeReadFromParcel(in);
        } else {
            mNativeObject = 0;
        }
    }

    @Override
@@ -696,7 +702,16 @@ public class SurfaceControl implements Parcelable {
        dest.writeString(mName);
        dest.writeInt(mWidth);
        dest.writeInt(mHeight);
        if (mNativeObject == 0) {
            dest.writeInt(0);
        } else {
            dest.writeInt(1);
        }
        nativeWriteToParcel(mNativeObject, dest);

        if ((flags & Parcelable.PARCELABLE_WRITE_RETURN_VALUE) != 0) {
            release();
        }
    }

    /**
@@ -779,6 +794,10 @@ public class SurfaceControl implements Parcelable {
                "mNativeObject is null. Have you called release() already?");
    }

    public boolean isValid() {
        return mNativeObject != 0;
    }

    /*
     * set surface parameters.
     * needs to be inside open/closeTransaction block
+0 −10
Original line number Diff line number Diff line
@@ -30,7 +30,6 @@ public final class SurfaceSession {
    private long mNativeClient; // SurfaceComposerClient*

    private static native long nativeCreate();
    private static native long nativeCreateScoped(long surfacePtr);
    private static native void nativeDestroy(long ptr);
    private static native void nativeKill(long ptr);

@@ -40,15 +39,6 @@ public final class SurfaceSession {
        mNativeClient = nativeCreate();
    }

    public SurfaceSession(Surface root) {
        synchronized (root.mLock) {
            if (root.mNativeObject == 0) {
                throw new IllegalStateException("Surface is not initialized or has been released");
            }
            mNativeClient = nativeCreateScoped(root.mNativeObject);
        }
    }

    /* no user serviceable parts here ... */
    @Override
    protected void finalize() throws Throwable {
Loading