diff options
| author | Jeff Brown <jeffbrown@google.com> | 2013-06-04 00:02:38 -0700 |
|---|---|---|
| committer | Jeff Brown <jeffbrown@google.com> | 2013-06-18 15:32:41 -0700 |
| commit | a506a6ec94863a35acca9feb165db76ddac3892c (patch) | |
| tree | 703825e9e8d3d4928b4d36185244c22b425be04c /core/java/android/view/DisplayInfo.java | |
| parent | 012416fdbb279f291b43e9d6bf565750752e6a41 (diff) | |
Add an API to allow for creating private virtual displays.
This change enables applications to create a private virtual
display that renders its content to a surface of its own creation.
The display is private in the sense that only the application
that owns the display is allowed to place windows upon it.
Mirroring and blanking is also disabled for these displays.
Bug: 9192512
Change-Id: I852ea07f0c7df1d244e354e3daca3a6960285ca0
Diffstat (limited to 'core/java/android/view/DisplayInfo.java')
| -rw-r--r-- | core/java/android/view/DisplayInfo.java | 47 |
1 files changed, 44 insertions, 3 deletions
diff --git a/core/java/android/view/DisplayInfo.java b/core/java/android/view/DisplayInfo.java index 9fcd9b1c8ac9..1442cb72ed59 100644 --- a/core/java/android/view/DisplayInfo.java +++ b/core/java/android/view/DisplayInfo.java @@ -19,6 +19,7 @@ package android.view; import android.content.res.CompatibilityInfo; import android.os.Parcel; import android.os.Parcelable; +import android.os.Process; import android.util.DisplayMetrics; import libcore.util.Objects; @@ -177,6 +178,23 @@ public final class DisplayInfo implements Parcelable { */ public float physicalYDpi; + /** + * The UID of the application that owns this display, or zero if it is owned by the system. + * <p> + * If the display is private, then only the owner can use it. + * </p> + */ + public int ownerUid; + + /** + * The package name of the application that owns this display, or null if it is + * owned by the system. + * <p> + * If the display is private, then only the owner can use it. + * </p> + */ + public String ownerPackageName; + public static final Creator<DisplayInfo> CREATOR = new Creator<DisplayInfo>() { @Override public DisplayInfo createFromParcel(Parcel source) { @@ -228,7 +246,9 @@ public final class DisplayInfo implements Parcelable { && refreshRate == other.refreshRate && logicalDensityDpi == other.logicalDensityDpi && physicalXDpi == other.physicalXDpi - && physicalYDpi == other.physicalYDpi; + && physicalYDpi == other.physicalYDpi + && ownerUid == other.ownerUid + && Objects.equal(ownerPackageName, other.ownerPackageName); } @Override @@ -259,6 +279,8 @@ public final class DisplayInfo implements Parcelable { logicalDensityDpi = other.logicalDensityDpi; physicalXDpi = other.physicalXDpi; physicalYDpi = other.physicalYDpi; + ownerUid = other.ownerUid; + ownerPackageName = other.ownerPackageName; } public void readFromParcel(Parcel source) { @@ -284,6 +306,8 @@ public final class DisplayInfo implements Parcelable { logicalDensityDpi = source.readInt(); physicalXDpi = source.readFloat(); physicalYDpi = source.readFloat(); + ownerUid = source.readInt(); + ownerPackageName = source.readString(); } @Override @@ -310,6 +334,8 @@ public final class DisplayInfo implements Parcelable { dest.writeInt(logicalDensityDpi); dest.writeFloat(physicalXDpi); dest.writeFloat(physicalYDpi); + dest.writeInt(ownerUid); + dest.writeString(ownerPackageName); } @Override @@ -335,6 +361,13 @@ public final class DisplayInfo implements Parcelable { logicalHeight : logicalWidth; } + /** + * Returns true if the specified UID has access to this display. + */ + public boolean hasAccess(int uid) { + return Display.hasAccess(uid, flags, ownerUid); + } + private void getMetricsWithSize(DisplayMetrics outMetrics, CompatibilityInfoHolder cih, int width, int height) { outMetrics.densityDpi = outMetrics.noncompatDensityDpi = logicalDensityDpi; @@ -402,8 +435,13 @@ public final class DisplayInfo implements Parcelable { sb.append(layerStack); sb.append(", type "); sb.append(Display.typeToString(type)); - sb.append(", address "); - sb.append(address); + if (address != null) { + sb.append(", address ").append(address); + } + if (ownerUid != 0 || ownerPackageName != null) { + sb.append(", owner ").append(ownerPackageName); + sb.append(" (uid ").append(ownerUid).append(")"); + } sb.append(flagsToString(flags)); sb.append("}"); return sb.toString(); @@ -417,6 +455,9 @@ public final class DisplayInfo implements Parcelable { if ((flags & Display.FLAG_SUPPORTS_PROTECTED_BUFFERS) != 0) { result.append(", FLAG_SUPPORTS_PROTECTED_BUFFERS"); } + if ((flags & Display.FLAG_PRIVATE) != 0) { + result.append(", FLAG_PRIVATE"); + } return result.toString(); } } |
