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

Commit fe0e8d4d authored by Anton Hansson's avatar Anton Hansson Committed by Automerger Merge Worker
Browse files

Merge "Revert "Adding public API to expose DisplayInfo.deviceProductInfo""...

Merge "Revert "Adding public API to expose DisplayInfo.deviceProductInfo"" into sc-dev am: eaeaf0ac

Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/13676776

MUST ONLY BE SUBMITTED BY AUTOMERGER

Change-Id: Ib7778af2a641459fc79e93ab5d8497ad1790a09d
parents 4e6c1e95 eaeaf0ac
Loading
Loading
Loading
Loading
+0 −18
Original line number Original line Diff line number Diff line
@@ -18559,23 +18559,6 @@ package android.hardware.camera2.params {
package android.hardware.display {
package android.hardware.display {
  public final class DeviceProductInfo implements android.os.Parcelable {
    method public int describeContents();
    method public int getConnectionToSinkType();
    method public int getManufactureWeek();
    method public int getManufactureYear();
    method @NonNull public String getManufacturerPnpId();
    method public int getModelYear();
    method @Nullable public String getName();
    method @NonNull public String getProductId();
    method public void writeToParcel(@NonNull android.os.Parcel, int);
    field public static final int CONNECTION_TO_SINK_BUILT_IN = 1; // 0x1
    field public static final int CONNECTION_TO_SINK_DIRECT = 2; // 0x2
    field public static final int CONNECTION_TO_SINK_TRANSITIVE = 3; // 0x3
    field public static final int CONNECTION_TO_SINK_UNKNOWN = 0; // 0x0
    field @NonNull public static final android.os.Parcelable.Creator<android.hardware.display.DeviceProductInfo> CREATOR;
  }
  public final class DisplayManager {
  public final class DisplayManager {
    method public android.hardware.display.VirtualDisplay createVirtualDisplay(@NonNull String, int, int, int, @Nullable android.view.Surface, int);
    method public android.hardware.display.VirtualDisplay createVirtualDisplay(@NonNull String, int, int, int, @Nullable android.view.Surface, int);
    method public android.hardware.display.VirtualDisplay createVirtualDisplay(@NonNull String, int, int, int, @Nullable android.view.Surface, int, @Nullable android.hardware.display.VirtualDisplay.Callback, @Nullable android.os.Handler);
    method public android.hardware.display.VirtualDisplay createVirtualDisplay(@NonNull String, int, int, int, @Nullable android.view.Surface, int, @Nullable android.hardware.display.VirtualDisplay.Callback, @Nullable android.os.Handler);
@@ -46713,7 +46696,6 @@ package android.view {
    method public long getAppVsyncOffsetNanos();
    method public long getAppVsyncOffsetNanos();
    method public void getCurrentSizeRange(android.graphics.Point, android.graphics.Point);
    method public void getCurrentSizeRange(android.graphics.Point, android.graphics.Point);
    method @Nullable public android.view.DisplayCutout getCutout();
    method @Nullable public android.view.DisplayCutout getCutout();
    method @Nullable public android.hardware.display.DeviceProductInfo getDeviceProductInfo();
    method public int getDisplayId();
    method public int getDisplayId();
    method public int getFlags();
    method public int getFlags();
    method public android.view.Display.HdrCapabilities getHdrCapabilities();
    method public android.view.Display.HdrCapabilities getHdrCapabilities();
+21 −78
Original line number Original line Diff line number Diff line
@@ -16,69 +16,40 @@


package android.hardware.display;
package android.hardware.display;


import android.annotation.IntDef;
import android.annotation.NonNull;
import android.annotation.Nullable;
import android.annotation.Nullable;
import android.os.Parcel;
import android.os.Parcel;
import android.os.Parcelable;
import android.os.Parcelable;


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


/**
/**
 * Product-specific information about the display or the directly connected device on the
 * Product-specific information about the display or the directly connected device on the
 * display chain. For example, if the display is transitively connected, this field may contain
 * display chain. For example, if the display is transitively connected, this field may contain
 * product information about the intermediate device.
 * product information about the intermediate device.
 * @hide
 */
 */
public final class DeviceProductInfo implements Parcelable {
public final class DeviceProductInfo implements Parcelable {
    /** @hide */
    @IntDef(prefix = {"CONNECTION_TO_SINK_"}, value = {
            CONNECTION_TO_SINK_UNKNOWN,
            CONNECTION_TO_SINK_BUILT_IN,
            CONNECTION_TO_SINK_DIRECT,
            CONNECTION_TO_SINK_TRANSITIVE
    })
    @Retention(RetentionPolicy.SOURCE)
    public @interface ConnectionToSinkType { }

    /** The device connection to the display sink is unknown. */
    public static final int CONNECTION_TO_SINK_UNKNOWN =
            IDeviceProductInfoConstants.CONNECTION_TO_SINK_UNKNOWN;

    /** The display sink is built-in to the device */
    public static final int CONNECTION_TO_SINK_BUILT_IN =
            IDeviceProductInfoConstants.CONNECTION_TO_SINK_BUILT_IN;

    /** The device is directly connected to the display sink. */
    public static final int CONNECTION_TO_SINK_DIRECT =
            IDeviceProductInfoConstants.CONNECTION_TO_SINK_DIRECT;

    /** The device is transitively connected to the display sink. */
    public static final int CONNECTION_TO_SINK_TRANSITIVE =
            IDeviceProductInfoConstants.CONNECTION_TO_SINK_TRANSITIVE;

    private final String mName;
    private final String mName;
    private final String mManufacturerPnpId;
    private final String mManufacturerPnpId;
    private final String mProductId;
    private final String mProductId;
    private final Integer mModelYear;
    private final Integer mModelYear;
    private final ManufactureDate mManufactureDate;
    private final ManufactureDate mManufactureDate;
    private final @ConnectionToSinkType int mConnectionToSinkType;
    private final int[] mRelativeAddress;


    /** @hide */
    public DeviceProductInfo(
    public DeviceProductInfo(
            String name,
            String name,
            String manufacturerPnpId,
            String manufacturerPnpId,
            String productId,
            String productId,
            Integer modelYear,
            Integer modelYear,
            ManufactureDate manufactureDate,
            ManufactureDate manufactureDate,
            int connectionToSinkType) {
            int[] relativeAddress) {
        this.mName = name;
        this.mName = name;
        this.mManufacturerPnpId = manufacturerPnpId;
        this.mManufacturerPnpId = manufacturerPnpId;
        this.mProductId = productId;
        this.mProductId = productId;
        this.mModelYear = modelYear;
        this.mModelYear = modelYear;
        this.mManufactureDate = manufactureDate;
        this.mManufactureDate = manufactureDate;
        this.mConnectionToSinkType = connectionToSinkType;
        this.mRelativeAddress = relativeAddress;
    }
    }


    private DeviceProductInfo(Parcel in) {
    private DeviceProductInfo(Parcel in) {
@@ -87,13 +58,12 @@ public final class DeviceProductInfo implements Parcelable {
        mProductId = (String) in.readValue(null);
        mProductId = (String) in.readValue(null);
        mModelYear = (Integer) in.readValue(null);
        mModelYear = (Integer) in.readValue(null);
        mManufactureDate = (ManufactureDate) in.readValue(null);
        mManufactureDate = (ManufactureDate) in.readValue(null);
        mConnectionToSinkType = in.readInt();
        mRelativeAddress = in.createIntArray();
    }
    }


    /**
    /**
     * @return Display name.
     * @return Display name.
     */
     */
    @Nullable
    public String getName() {
    public String getName() {
        return mName;
        return mName;
    }
    }
@@ -101,7 +71,6 @@ public final class DeviceProductInfo implements Parcelable {
    /**
    /**
     * @return Manufacturer Plug and Play ID.
     * @return Manufacturer Plug and Play ID.
     */
     */
    @NonNull
    public String getManufacturerPnpId() {
    public String getManufacturerPnpId() {
        return mManufacturerPnpId;
        return mManufacturerPnpId;
    }
    }
@@ -109,58 +78,32 @@ public final class DeviceProductInfo implements Parcelable {
    /**
    /**
     * @return Manufacturer product ID.
     * @return Manufacturer product ID.
     */
     */
    @NonNull
    public String getProductId() {
    public String getProductId() {
        return mProductId;
        return mProductId;
    }
    }


    /**
    /**
     * @return Model year of the device. Return -1 if not available. Typically,
     * @return Model year of the device. Typically exactly one of model year or
     * one of model year or manufacture year is available.
     *      manufacture date will be present.
     */
     */
    public int getModelYear()  {
    public Integer getModelYear() {
        return mModelYear != null ? mModelYear : -1;
        return mModelYear;
    }

    /**
     * @return The year of manufacture, or -1 it is not available. Typically,
     * one of model year or manufacture year is available.
     */
    public int getManufactureYear()  {
        if (mManufactureDate == null) {
            return -1;
        }
        return mManufactureDate.mYear != null ? mManufactureDate.mYear : -1;
    }

    /**
     * @return The week of manufacture, or -1 it is not available. Typically,
     * not present if model year is available.
     */
    public int getManufactureWeek() {
        if (mManufactureDate == null) {
            return -1;
        }
        return mManufactureDate.mWeek != null ?  mManufactureDate.mWeek : -1;
    }
    }


    /**
    /**
     * @return Manufacture date. Typically exactly one of model year or manufacture
     * @return Manufacture date. Typically exactly one of model year or manufacture
     * date will be present.
     * date will be present.
     *
     * @hide
     */
     */
    public ManufactureDate getManufactureDate() {
    public ManufactureDate getManufactureDate() {
        return mManufactureDate;
        return mManufactureDate;
    }
    }


    /**
    /**
     * @return How the current device is connected to the display sink. For example, the display
     * @return Relative address in the display network. For example, for HDMI connected devices this
     * can be connected immediately to the device or there can be a receiver in between.
     * can be its physical address. Each component of the address is in the range [0, 255].
     */
     */
    @ConnectionToSinkType
    public int[] getRelativeAddress() {
    public int getConnectionToSinkType() {
        return mRelativeAddress;
        return mConnectionToSinkType;
    }
    }


    @Override
    @Override
@@ -176,8 +119,8 @@ public final class DeviceProductInfo implements Parcelable {
                + mModelYear
                + mModelYear
                + ", manufactureDate="
                + ", manufactureDate="
                + mManufactureDate
                + mManufactureDate
                + ", connectionToSinkType="
                + ", relativeAddress="
                + mConnectionToSinkType
                + Arrays.toString(mRelativeAddress)
                + '}';
                + '}';
    }
    }


@@ -191,16 +134,16 @@ public final class DeviceProductInfo implements Parcelable {
                && Objects.equals(mProductId, that.mProductId)
                && Objects.equals(mProductId, that.mProductId)
                && Objects.equals(mModelYear, that.mModelYear)
                && Objects.equals(mModelYear, that.mModelYear)
                && Objects.equals(mManufactureDate, that.mManufactureDate)
                && Objects.equals(mManufactureDate, that.mManufactureDate)
                && mConnectionToSinkType == that.mConnectionToSinkType;
                && Arrays.equals(mRelativeAddress, that.mRelativeAddress);
    }
    }


    @Override
    @Override
    public int hashCode() {
    public int hashCode() {
        return Objects.hash(mName, mManufacturerPnpId, mProductId, mModelYear, mManufactureDate,
        return Objects.hash(mName, mManufacturerPnpId, mProductId, mModelYear, mManufactureDate,
                mConnectionToSinkType);
            Arrays.hashCode(mRelativeAddress));
    }
    }


    @NonNull public static final Creator<DeviceProductInfo> CREATOR =
    public static final Creator<DeviceProductInfo> CREATOR =
            new Creator<DeviceProductInfo>() {
            new Creator<DeviceProductInfo>() {
                @Override
                @Override
                public DeviceProductInfo createFromParcel(Parcel in) {
                public DeviceProductInfo createFromParcel(Parcel in) {
@@ -219,13 +162,13 @@ public final class DeviceProductInfo implements Parcelable {
    }
    }


    @Override
    @Override
    public void writeToParcel(@NonNull Parcel dest, int flags) {
    public void writeToParcel(Parcel dest, int flags) {
        dest.writeString(mName);
        dest.writeString(mName);
        dest.writeString(mManufacturerPnpId);
        dest.writeString(mManufacturerPnpId);
        dest.writeValue(mProductId);
        dest.writeValue(mProductId);
        dest.writeValue(mModelYear);
        dest.writeValue(mModelYear);
        dest.writeValue(mManufactureDate);
        dest.writeValue(mManufactureDate);
        dest.writeInt(mConnectionToSinkType);
        dest.writeIntArray(mRelativeAddress);
    }
    }


    /**
    /**
+0 −13
Original line number Original line Diff line number Diff line
@@ -34,7 +34,6 @@ import android.graphics.ColorSpace;
import android.graphics.PixelFormat;
import android.graphics.PixelFormat;
import android.graphics.Point;
import android.graphics.Point;
import android.graphics.Rect;
import android.graphics.Rect;
import android.hardware.display.DeviceProductInfo;
import android.hardware.display.DisplayManager;
import android.hardware.display.DisplayManager;
import android.hardware.display.DisplayManagerGlobal;
import android.hardware.display.DisplayManagerGlobal;
import android.os.Build;
import android.os.Build;
@@ -1181,18 +1180,6 @@ public final class Display {
        }
        }
    }
    }


    /**
     * Returns the product-specific information about the display or the directly connected
     * device on the display chain.
     * For example, if the display is transitively connected, this field may contain product
     * information about the intermediate device.
     * Returns {@code null} if product information is not available.
     */
    @Nullable
    public DeviceProductInfo getDeviceProductInfo() {
        return mDisplayInfo.deviceProductInfo;
    }

    /**
    /**
     * Gets display metrics that describe the size and density of this display.
     * Gets display metrics that describe the size and density of this display.
     * The size returned by this method does not necessarily represent the
     * The size returned by this method does not necessarily represent the
+7 −16
Original line number Original line Diff line number Diff line
@@ -27,7 +27,6 @@
#include <android-base/chrono_utils.h>
#include <android-base/chrono_utils.h>
#include <android/graphics/region.h>
#include <android/graphics/region.h>
#include <android/gui/BnScreenCaptureListener.h>
#include <android/gui/BnScreenCaptureListener.h>
#include <android/hardware/display/IDeviceProductInfoConstants.h>
#include <android/os/IInputConstants.h>
#include <android/os/IInputConstants.h>
#include <android_runtime/AndroidRuntime.h>
#include <android_runtime/AndroidRuntime.h>
#include <android_runtime/android_hardware_HardwareBuffer.h>
#include <android_runtime/android_hardware_HardwareBuffer.h>
@@ -1023,24 +1022,16 @@ static jobject convertDeviceProductInfoToJavaObject(
    } else {
    } else {
        LOG_FATAL("Unknown alternative for variant DeviceProductInfo::ManufactureOrModelDate");
        LOG_FATAL("Unknown alternative for variant DeviceProductInfo::ManufactureOrModelDate");
    }
    }
    jint connectionToSinkType;
    auto relativeAddress = env->NewIntArray(info->relativeAddress.size());
    // Relative address maps to HDMI physical address. All addresses are 4 digits long allowing
    auto relativeAddressData = env->GetIntArrayElements(relativeAddress, nullptr);
    // for a 5–device-deep hierarchy. For more information, refer:
    for (int i = 0; i < info->relativeAddress.size(); i++) {
    // Section 8.7 - Physical Address of HDMI Specification Version 1.3a
        relativeAddressData[i] = info->relativeAddress[i];
    using android::hardware::display::IDeviceProductInfoConstants;
    if (info->relativeAddress.size() != 4) {
        connectionToSinkType = IDeviceProductInfoConstants::CONNECTION_TO_SINK_UNKNOWN;
    } else if (info->relativeAddress[0] == 0) {
        connectionToSinkType = IDeviceProductInfoConstants::CONNECTION_TO_SINK_BUILT_IN;
    } else if (info->relativeAddress[1] == 0) {
        connectionToSinkType = IDeviceProductInfoConstants::CONNECTION_TO_SINK_DIRECT;
    } else {
        connectionToSinkType = IDeviceProductInfoConstants::CONNECTION_TO_SINK_TRANSITIVE;
    }
    }
    env->ReleaseIntArrayElements(relativeAddress, relativeAddressData, 0);


    return env->NewObject(gDeviceProductInfoClassInfo.clazz, gDeviceProductInfoClassInfo.ctor, name,
    return env->NewObject(gDeviceProductInfoClassInfo.clazz, gDeviceProductInfoClassInfo.ctor, name,
                          manufacturerPnpId, productId, modelYear, manufactureDate,
                          manufacturerPnpId, productId, modelYear, manufactureDate,
                          connectionToSinkType);
                          relativeAddress);
}
}


static jobject nativeGetStaticDisplayInfo(JNIEnv* env, jclass clazz, jobject tokenObj) {
static jobject nativeGetStaticDisplayInfo(JNIEnv* env, jclass clazz, jobject tokenObj) {
@@ -1979,7 +1970,7 @@ int register_android_view_SurfaceControl(JNIEnv* env)
                             "Ljava/lang/String;"
                             "Ljava/lang/String;"
                             "Ljava/lang/Integer;"
                             "Ljava/lang/Integer;"
                             "Landroid/hardware/display/DeviceProductInfo$ManufactureDate;"
                             "Landroid/hardware/display/DeviceProductInfo$ManufactureDate;"
                             "I)V");
                             "[I)V");


    jclass deviceProductInfoManufactureDateClazz =
    jclass deviceProductInfoManufactureDateClazz =
            FindClassOrDie(env, "android/hardware/display/DeviceProductInfo$ManufactureDate");
            FindClassOrDie(env, "android/hardware/display/DeviceProductInfo$ManufactureDate");