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

Commit f4733dd8 authored by Marin Shalamanov's avatar Marin Shalamanov Committed by Android (Google) Code Review
Browse files

Merge "Change the type of display port from byte to int"

parents 08c5f743 41cb66fa
Loading
Loading
Loading
Loading
+4 −4
Original line number Diff line number Diff line
@@ -24,6 +24,7 @@ import android.graphics.Rect;
import android.text.TextUtils;

import java.lang.annotation.Retention;
import java.util.Objects;

/**
 * Describes how the pixels of physical display device reflects the content of
@@ -73,7 +74,7 @@ public final class DisplayViewport {
    public String uniqueId;

    // The physical port that the associated display device is connected to.
    public @Nullable Byte physicalPort;
    public @Nullable Integer physicalPort;

    public @ViewportType int type;

@@ -118,7 +119,7 @@ public final class DisplayViewport {
              && deviceWidth == other.deviceWidth
              && deviceHeight == other.deviceHeight
              && TextUtils.equals(uniqueId, other.uniqueId)
              && physicalPort == other.physicalPort
              && Objects.equals(physicalPort, other.physicalPort)
              && type == other.type;
    }

@@ -144,12 +145,11 @@ public final class DisplayViewport {
    // For debugging purposes.
    @Override
    public String toString() {
        final Integer port = physicalPort == null ? null : Byte.toUnsignedInt(physicalPort);
        return "DisplayViewport{type=" + typeToString(type)
                + ", valid=" + valid
                + ", displayId=" + displayId
                + ", uniqueId='" + uniqueId + "'"
                + ", physicalPort=" + port
                + ", physicalPort=" + physicalPort
                + ", orientation=" + orientation
                + ", logicalFrame=" + logicalFrame
                + ", physicalFrame=" + physicalFrame
+11 −8
Original line number Diff line number Diff line
@@ -43,12 +43,12 @@ public abstract class DisplayAddress implements Parcelable {
    /**
     * Creates an address for a physical display given its port and model.
     *
     * @param port A port in the range [0, 255] interpreted as signed.
     * @param port A port in the range [0, 255].
     * @param model A positive integer, or {@code null} if the model cannot be identified.
     * @return The {@link Physical} address.
     */
    @NonNull
    public static Physical fromPortAndModel(byte port, Long model) {
    public static Physical fromPortAndModel(int port, Long model) {
        return new Physical(port, model);
    }

@@ -92,10 +92,10 @@ public abstract class DisplayAddress implements Parcelable {
        /**
         * Physical port to which the display is connected.
         *
         * @return A port in the range [0, 255] interpreted as signed.
         * @return A port in the range [0, 255].
         */
        public byte getPort() {
            return (byte) mPhysicalDisplayId;
        public int getPort() {
            return (int) (mPhysicalDisplayId & 0xFF);
        }

        /**
@@ -118,7 +118,7 @@ public abstract class DisplayAddress implements Parcelable {
        @Override
        public String toString() {
            final StringBuilder builder = new StringBuilder("{")
                    .append("port=").append(Byte.toUnsignedInt(getPort()));
                    .append("port=").append(getPort());

            final Long model = getModel();
            if (model != null) {
@@ -142,8 +142,11 @@ public abstract class DisplayAddress implements Parcelable {
            mPhysicalDisplayId = physicalDisplayId;
        }

        private Physical(byte port, Long model) {
            mPhysicalDisplayId = Byte.toUnsignedLong(port)
        private Physical(int port, Long model) {
            if (port < 0 || port > 255) {
                throw new IllegalArgumentException("The port should be in the interval [0, 255]");
            }
            mPhysicalDisplayId = Integer.toUnsignedLong(port)
                    | (model == null ? UNKNOWN_MODEL : (model << MODEL_SHIFT));
        }

+4 −4
Original line number Diff line number Diff line
@@ -55,8 +55,8 @@ static struct {

status_t android_hardware_display_DisplayViewport_toNative(JNIEnv* env, jobject viewportObj,
        DisplayViewport* viewport) {
    static const jclass byteClass = FindClassOrDie(env, "java/lang/Byte");
    static const jmethodID byteValue = env->GetMethodID(byteClass, "byteValue", "()B");
    static const jclass intClass = FindClassOrDie(env, "java/lang/Integer");
    static const jmethodID byteValue = env->GetMethodID(intClass, "byteValue", "()B");

    viewport->displayId = env->GetIntField(viewportObj, gDisplayViewportClassInfo.displayId);
    viewport->orientation = env->GetIntField(viewportObj, gDisplayViewportClassInfo.orientation);
@@ -122,8 +122,8 @@ int register_android_hardware_display_DisplayViewport(JNIEnv* env) {
    gDisplayViewportClassInfo.uniqueId = GetFieldIDOrDie(env,
            gDisplayViewportClassInfo.clazz, "uniqueId", "Ljava/lang/String;");

    gDisplayViewportClassInfo.physicalPort = GetFieldIDOrDie(env,
            gDisplayViewportClassInfo.clazz, "physicalPort", "Ljava/lang/Byte;");
    gDisplayViewportClassInfo.physicalPort = GetFieldIDOrDie(env, gDisplayViewportClassInfo.clazz,
                                                             "physicalPort", "Ljava/lang/Integer;");

    gDisplayViewportClassInfo.type = GetFieldIDOrDie(env,
            gDisplayViewportClassInfo.clazz, "type", "I");
+1 −1
Original line number Diff line number Diff line
@@ -987,7 +987,7 @@ final class LocalDisplayAdapter extends DisplayAdapter {
            int[] ports = res.getIntArray(
                    com.android.internal.R.array.config_localPrivateDisplayPorts);
            if (ports != null) {
                int port = Byte.toUnsignedInt(physicalAddress.getPort());
                int port = physicalAddress.getPort();
                for (int p : ports) {
                    if (p == port) {
                        return true;
+1 −2
Original line number Diff line number Diff line
@@ -642,8 +642,7 @@ class DisplayWindowSettings {
        if (mIdentifier == IDENTIFIER_PORT && displayInfo.address != null) {
            // Config suggests using port as identifier for physical displays.
            if (displayInfo.address instanceof DisplayAddress.Physical) {
                byte port = ((DisplayAddress.Physical) displayInfo.address).getPort();
                return "port:" + Byte.toUnsignedInt(port);
                return "port:" + ((DisplayAddress.Physical) displayInfo.address).getPort();
            }
        }
        return displayInfo.uniqueId;
Loading