[RESTRICT AUTOMERGE] Add relative address to DeviceProductInfo.
This CL adds a field relativeAddress to DeviceProductInfo which contains the device address in the display network. For example, for HDMI connections the field is populated with the physical address. Bug: 147994746 Test: adb shell dumpsys display Change-Id: I87d9fd00bd16abc7594dc3f6b6d4e00c8968af07
This commit is contained in:
@@ -19,6 +19,7 @@ package android.hardware.display;
|
||||
import android.os.Parcel;
|
||||
import android.os.Parcelable;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
@@ -33,18 +34,21 @@ public final class DeviceProductInfo implements Parcelable {
|
||||
private final String mProductId;
|
||||
private final Integer mModelYear;
|
||||
private final ManufactureDate mManufactureDate;
|
||||
private final int[] mRelativeAddress;
|
||||
|
||||
public DeviceProductInfo(
|
||||
String name,
|
||||
String manufacturerPnpId,
|
||||
String productId,
|
||||
Integer modelYear,
|
||||
ManufactureDate manufactureDate) {
|
||||
ManufactureDate manufactureDate,
|
||||
int[] relativeAddress) {
|
||||
this.mName = name;
|
||||
this.mManufacturerPnpId = manufacturerPnpId;
|
||||
this.mProductId = productId;
|
||||
this.mModelYear = modelYear;
|
||||
this.mManufactureDate = manufactureDate;
|
||||
this.mRelativeAddress = relativeAddress;
|
||||
}
|
||||
|
||||
private DeviceProductInfo(Parcel in) {
|
||||
@@ -53,6 +57,7 @@ public final class DeviceProductInfo implements Parcelable {
|
||||
mProductId = (String) in.readValue(null);
|
||||
mModelYear = (Integer) in.readValue(null);
|
||||
mManufactureDate = (ManufactureDate) in.readValue(null);
|
||||
mRelativeAddress = in.createIntArray();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -92,6 +97,14 @@ public final class DeviceProductInfo implements Parcelable {
|
||||
return mManufactureDate;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Relative address in the display network. For example, for HDMI connected devices this
|
||||
* can be its physical address. Each component of the address is in the range [0, 255].
|
||||
*/
|
||||
public int[] getRelativeAddress() {
|
||||
return mRelativeAddress;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "DeviceProductInfo{"
|
||||
@@ -105,6 +118,8 @@ public final class DeviceProductInfo implements Parcelable {
|
||||
+ mModelYear
|
||||
+ ", manufactureDate="
|
||||
+ mManufactureDate
|
||||
+ ", relativeAddress="
|
||||
+ Arrays.toString(mRelativeAddress)
|
||||
+ '}';
|
||||
}
|
||||
|
||||
@@ -117,12 +132,14 @@ public final class DeviceProductInfo implements Parcelable {
|
||||
&& Objects.equals(mManufacturerPnpId, that.mManufacturerPnpId)
|
||||
&& Objects.equals(mProductId, that.mProductId)
|
||||
&& Objects.equals(mModelYear, that.mModelYear)
|
||||
&& Objects.equals(mManufactureDate, that.mManufactureDate);
|
||||
&& Objects.equals(mManufactureDate, that.mManufactureDate)
|
||||
&& Arrays.equals(mRelativeAddress, that.mRelativeAddress);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash(mName, mManufacturerPnpId, mProductId, mModelYear, mManufactureDate);
|
||||
return Objects.hash(mName, mManufacturerPnpId, mProductId, mModelYear, mManufactureDate,
|
||||
mRelativeAddress);
|
||||
}
|
||||
|
||||
public static final Creator<DeviceProductInfo> CREATOR =
|
||||
@@ -150,6 +167,7 @@ public final class DeviceProductInfo implements Parcelable {
|
||||
dest.writeValue(mProductId);
|
||||
dest.writeValue(mModelYear);
|
||||
dest.writeValue(mManufactureDate);
|
||||
dest.writeIntArray(mRelativeAddress);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -848,8 +848,18 @@ static jobject convertDeviceProductInfoToJavaObject(
|
||||
LOG_FATAL("Unknown alternative for variant DeviceProductInfo::ManufactureOrModelDate");
|
||||
}
|
||||
|
||||
jintArray relativeAddress = nullptr;
|
||||
if (info->relativeAddress != DeviceProductInfo::NO_RELATIVE_ADDRESS) {
|
||||
relativeAddress = env->NewIntArray(info->relativeAddress.size());
|
||||
jint* relativeAddressData = env->GetIntArrayElements(relativeAddress, nullptr);
|
||||
for (size_t i = 0; i < info->relativeAddress.size(); i++) {
|
||||
relativeAddressData[i] = static_cast<jint>(info->relativeAddress[i]);
|
||||
}
|
||||
env->ReleaseIntArrayElements(relativeAddress, relativeAddressData, 0);
|
||||
}
|
||||
return env->NewObject(gDeviceProductInfoClassInfo.clazz, gDeviceProductInfoClassInfo.ctor, name,
|
||||
manufacturerPnpId, productId, modelYear, manufactureDate);
|
||||
manufacturerPnpId, productId, modelYear, manufactureDate,
|
||||
relativeAddress);
|
||||
}
|
||||
|
||||
static jobject nativeGetDisplayInfo(JNIEnv* env, jclass clazz, jobject tokenObj) {
|
||||
@@ -1684,7 +1694,8 @@ int register_android_view_SurfaceControl(JNIEnv* env)
|
||||
"Ljava/lang/String;"
|
||||
"Ljava/lang/String;"
|
||||
"Ljava/lang/Integer;"
|
||||
"Landroid/hardware/display/DeviceProductInfo$ManufactureDate;)V");
|
||||
"Landroid/hardware/display/DeviceProductInfo$ManufactureDate;"
|
||||
"[I)V");
|
||||
|
||||
jclass deviceProductInfoManufactureDateClazz =
|
||||
FindClassOrDie(env, "android/hardware/display/DeviceProductInfo$ManufactureDate");
|
||||
|
||||
Reference in New Issue
Block a user