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
This commit is contained in:
Evan Rosky
2019-02-06 13:38:03 -08:00
parent 779cd543e2
commit c12c9a3bbc

View File

@@ -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);