summaryrefslogtreecommitdiff
path: root/core/java/android/view/DisplayAddress.java
diff options
context:
space:
mode:
Diffstat (limited to 'core/java/android/view/DisplayAddress.java')
-rw-r--r--core/java/android/view/DisplayAddress.java19
1 files changed, 11 insertions, 8 deletions
diff --git a/core/java/android/view/DisplayAddress.java b/core/java/android/view/DisplayAddress.java
index e0d9a4dd1df0..92f1adcd928b 100644
--- a/core/java/android/view/DisplayAddress.java
+++ b/core/java/android/view/DisplayAddress.java
@@ -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));
}