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

Commit 30e984ca authored by Rob Carr's avatar Rob Carr Committed by Android (Google) Code Review
Browse files

Merge changes from topic "remove-scoped-connection"

* changes:
  Remove usage of scoped connections.
  Allow SurfaceControl to be passed over AIDL.
parents 3b1ce723 5fea55b2
Loading
Loading
Loading
Loading
+2 −1
Original line number Original line Diff line number Diff line
@@ -321,7 +321,7 @@ public class ActivityView extends ViewGroup {
        public void surfaceCreated(SurfaceHolder surfaceHolder) {
        public void surfaceCreated(SurfaceHolder surfaceHolder) {
            mTmpSurface = new Surface();
            mTmpSurface = new Surface();
            if (mVirtualDisplay == null) {
            if (mVirtualDisplay == null) {
                initVirtualDisplay(new SurfaceSession(surfaceHolder.getSurface()));
                initVirtualDisplay(new SurfaceSession());
                if (mVirtualDisplay != null && mActivityViewCallback != null) {
                if (mVirtualDisplay != null && mActivityViewCallback != null) {
                    mActivityViewCallback.onActivityViewReady(ActivityView.this);
                    mActivityViewCallback.onActivityViewReady(ActivityView.this);
                }
                }
@@ -389,6 +389,7 @@ public class ActivityView extends ViewGroup {


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


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


        SurfaceControl mSurfaceControl = new SurfaceControl();

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


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


    /*
    /*
+41 −5
Original line number Original line Diff line number Diff line
@@ -67,6 +67,7 @@ public class SurfaceControl implements Parcelable {
            int w, int h, int format, int flags, long parentObject, int windowType, int ownerUid)
            int w, int h, int format, int flags, long parentObject, int windowType, int ownerUid)
            throws OutOfResourcesException;
            throws OutOfResourcesException;
    private static native long nativeReadFromParcel(Parcel in);
    private static native long nativeReadFromParcel(Parcel in);
    private static native long nativeCopyFromSurfaceControl(long nativeObject);
    private static native void nativeWriteToParcel(long nativeObject, Parcel out);
    private static native void nativeWriteToParcel(long nativeObject, Parcel out);
    private static native void nativeRelease(long nativeObject);
    private static native void nativeRelease(long nativeObject);
    private static native void nativeDestroy(long nativeObject);
    private static native void nativeDestroy(long nativeObject);
@@ -169,7 +170,7 @@ public class SurfaceControl implements Parcelable {
            IBinder toToken);
            IBinder toToken);


    private final CloseGuard mCloseGuard = CloseGuard.get();
    private final CloseGuard mCloseGuard = CloseGuard.get();
    private final String mName;
    private String mName;
    long mNativeObject; // package visibility only for Surface.java access
    long mNativeObject; // package visibility only for Surface.java access


    // TODO: Move this to native.
    // TODO: Move this to native.
@@ -359,6 +360,13 @@ public class SurfaceControl implements Parcelable {
     */
     */
    public static final int WINDOW_TYPE_DONT_SCREENSHOT = 441731;
    public static final int WINDOW_TYPE_DONT_SCREENSHOT = 441731;


    public void copyFrom(SurfaceControl other) {
        mName = other.mName;
        mWidth = other.mWidth;
        mHeight = other.mHeight;
        mNativeObject = nativeCopyFromSurfaceControl(other.mNativeObject);
    }

    /**
    /**
     * Builder class for {@link SurfaceControl} objects.
     * Builder class for {@link SurfaceControl} objects.
     */
     */
@@ -660,14 +668,29 @@ public class SurfaceControl implements Parcelable {
    }
    }


    private SurfaceControl(Parcel in) {
    private SurfaceControl(Parcel in) {
        readFromParcel(in);
        mCloseGuard.open("release");
    }

    public SurfaceControl() {
        mCloseGuard.open("release");
    }

    public void readFromParcel(Parcel in) {
        if (in == null) {
            throw new IllegalArgumentException("source must not be null");
        }

        mName = in.readString();
        mName = in.readString();
        mWidth = in.readInt();
        mWidth = in.readInt();
        mHeight = in.readInt();
        mHeight = in.readInt();

        release();
        if (in.readInt() != 0) {
            mNativeObject = nativeReadFromParcel(in);
            mNativeObject = nativeReadFromParcel(in);
        if (mNativeObject == 0) {
        } else {
            throw new IllegalArgumentException("Couldn't read SurfaceControl from parcel=" + in);
            mNativeObject = 0;
        }
        }
        mCloseGuard.open("release");
    }
    }


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

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


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


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

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


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


@@ -40,15 +39,6 @@ public final class SurfaceSession {
        mNativeClient = nativeCreate();
        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 ... */
    /* no user serviceable parts here ... */
    @Override
    @Override
    protected void finalize() throws Throwable {
    protected void finalize() throws Throwable {
Loading