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 Diff line number Diff line
@@ -321,7 +321,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);
                }
@@ -389,6 +389,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);

    /*
+41 −5
Original line number 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)
            throws OutOfResourcesException;
    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 nativeRelease(long nativeObject);
    private static native void nativeDestroy(long nativeObject);
@@ -169,7 +170,7 @@ public class SurfaceControl implements Parcelable {
            IBinder toToken);

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

    // TODO: Move this to native.
@@ -359,6 +360,13 @@ public class SurfaceControl implements Parcelable {
     */
    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.
     */
@@ -660,14 +668,29 @@ public class SurfaceControl implements Parcelable {
    }

    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();
        mWidth = in.readInt();
        mHeight = in.readInt();

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

    @Override
@@ -680,7 +703,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();
        }
    }

    /**
@@ -763,6 +795,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