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

Commit c12c9a3b authored by Evan Rosky's avatar Evan Rosky
Browse files

Fix layer creation metadata parceling

There were a couple issues:
- Parcel shares the same position between read/write, so the position
  had to be reset before sending to native
- Java's "native"IO ByteBuffer defaults to big-endian!? instead of
  the native endian.

Bug: 123914715
Test: sf_trace shows metadata. screenshots don't include notch/corners
      anymore

Change-Id: I27bcc54e4e81108554ba5c5009c43195902bbcf1
parent 779cd543
Loading
Loading
Loading
Loading
+4 −1
Original line number Diff line number Diff line
@@ -61,6 +61,7 @@ import libcore.util.NativeAllocationRegistry;

import java.io.Closeable;
import java.nio.ByteBuffer;
import java.nio.ByteOrder;

/**
 * Handle to an on-screen Surface managed by the system compositor. The SurfaceControl is
@@ -727,8 +728,10 @@ public final class SurfaceControl implements Parcelable {
                for (int i = 0; i < metadata.size(); ++i) {
                    metaParcel.writeInt(metadata.keyAt(i));
                    metaParcel.writeByteArray(
                            ByteBuffer.allocate(4).putInt(metadata.valueAt(i)).array());
                            ByteBuffer.allocate(4).order(ByteOrder.nativeOrder())
                                    .putInt(metadata.valueAt(i)).array());
                }
                metaParcel.setDataPosition(0);
            }
            mNativeObject = nativeCreate(session, name, w, h, format, flags,
                    parent != null ? parent.mNativeObject : 0, metaParcel);