Skip to content

Commit cdfc56a

Browse files
Jeff BrownAndroid (Google) Code Review
authored andcommitted
Merge "Add preliminary API for reporting display capabilities." into jb-mr1-dev
2 parents 1f1f597 + c5df37c commit cdfc56a

File tree

9 files changed

+90
-15
lines changed

9 files changed

+90
-15
lines changed

core/java/android/view/Display.java

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,40 @@ public final class Display {
7878
*/
7979
public static final int DEFAULT_DISPLAY = 0;
8080

81+
/**
82+
* Display flag: Indicates that the display supports secure video output.
83+
* <p>
84+
* This flag is used to indicate that the display supports content protection
85+
* mechanisms for secure video output at the display interface, such as HDCP.
86+
* These mechanisms may be used to protect secure content as it leaves the device.
87+
* </p><p>
88+
* While mirroring content to multiple displays, it can happen that certain
89+
* display devices support secure video output while other display devices do not.
90+
* The secure content will be shown only on the display devices that support
91+
* secure video output and will be blanked on other display devices that do
92+
* not support secure video output.
93+
* </p><p>
94+
* This flag mainly applies to external display devices such as HDMI or
95+
* Wifi display. Built-in display devices are usually considered secure.
96+
* </p>
97+
*
98+
* @hide pending review
99+
*/
100+
public static final int FLAG_SUPPORTS_SECURE_VIDEO_OUTPUT = 1 << 0;
101+
102+
/**
103+
* Display flag: Indicates that the display supports secure in-memory video buffers.
104+
* <p>
105+
* This flag is used to indicate that the display supports content protection
106+
* mechanisms for decrypted in-memory video buffers, such as secure memory areas.
107+
* These mechanisms may be used to protect secure video buffers in memory from
108+
* the video decoder to the display compositor and the video interface.
109+
* </p>
110+
*
111+
* @hide pending review
112+
*/
113+
public static final int FLAG_SUPPORTS_SECURE_VIDEO_BUFFERS = 1 << 1;
114+
81115
/**
82116
* Internal method to create a display.
83117
* Applications should use {@link android.view.WindowManager#getDefaultDisplay()}
@@ -157,6 +191,20 @@ public int getLayerStack() {
157191
return mLayerStack;
158192
}
159193

194+
/**
195+
* Returns a combination of flags that describe the capabilities of the display.
196+
*
197+
* @return The display flags.
198+
*
199+
* @hide pending review
200+
*/
201+
public int getFlags() {
202+
synchronized (this) {
203+
updateDisplayInfoLocked();
204+
return mDisplayInfo.flags;
205+
}
206+
}
207+
160208
/**
161209
* Gets the compatibility info used by this display instance.
162210
*

core/java/android/view/DisplayInfo.java

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,11 @@ public final class DisplayInfo implements Parcelable {
3333
*/
3434
public int layerStack;
3535

36+
/**
37+
* Display flags.
38+
*/
39+
public int flags;
40+
3641
/**
3742
* The human-readable name of the display.
3843
*/
@@ -189,6 +194,7 @@ public int hashCode() {
189194

190195
public void copyFrom(DisplayInfo other) {
191196
layerStack = other.layerStack;
197+
flags = other.flags;
192198
name = other.name;
193199
appWidth = other.appWidth;
194200
appHeight = other.appHeight;
@@ -207,6 +213,7 @@ public void copyFrom(DisplayInfo other) {
207213

208214
public void readFromParcel(Parcel source) {
209215
layerStack = source.readInt();
216+
flags = source.readInt();
210217
name = source.readString();
211218
appWidth = source.readInt();
212219
appHeight = source.readInt();
@@ -226,6 +233,7 @@ public void readFromParcel(Parcel source) {
226233
@Override
227234
public void writeToParcel(Parcel dest, int flags) {
228235
dest.writeInt(layerStack);
236+
dest.writeInt(flags);
229237
dest.writeString(name);
230238
dest.writeInt(appWidth);
231239
dest.writeInt(appHeight);
@@ -286,6 +294,17 @@ public String toString() {
286294
+ ", rotation " + rotation
287295
+ ", density " + logicalDensityDpi
288296
+ ", " + physicalXDpi + " x " + physicalYDpi + " dpi"
289-
+ ", layerStack " + layerStack + "}";
297+
+ ", layerStack " + layerStack + flagsToString(flags) + "}";
298+
}
299+
300+
private static String flagsToString(int flags) {
301+
StringBuilder result = new StringBuilder();
302+
if ((flags & Display.FLAG_SUPPORTS_SECURE_VIDEO_OUTPUT) != 0) {
303+
result.append(", FLAG_SUPPORTS_SECURE_VIDEO_OUTPUT");
304+
}
305+
if ((flags & Display.FLAG_SUPPORTS_SECURE_VIDEO_BUFFERS) != 0) {
306+
result.append(", FLAG_SUPPORTS_SECURE_VIDEO_BUFFERS");
307+
}
308+
return result.toString();
290309
}
291310
}

services/java/com/android/server/display/DisplayDeviceInfo.java

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -30,17 +30,17 @@ final class DisplayDeviceInfo {
3030
*/
3131
public static final int FLAG_DEFAULT_DISPLAY = 1 << 0;
3232

33-
/**
34-
* Flag: Indicates that this display device can show secure surfaces.
35-
*/
36-
public static final int FLAG_SECURE = 1 << 1;
37-
3833
/**
3934
* Flag: Indicates that this display device can rotate to show contents in a
4035
* different orientation. Otherwise the rotation is assumed to be fixed in the
4136
* natural orientation and the display manager should transform the content to fit.
4237
*/
43-
public static final int FLAG_SUPPORTS_ROTATION = 1 << 2;
38+
public static final int FLAG_SUPPORTS_ROTATION = 1 << 1;
39+
40+
/**
41+
* Flag: Indicates that this display device can show secure surfaces.
42+
*/
43+
public static final int FLAG_SUPPORTS_SECURE_VIDEO_OUTPUT = 1 << 2;
4444

4545
/**
4646
* Touch attachment: Display does not receive touch.
@@ -179,8 +179,11 @@ private static String flagsToString(int flags) {
179179
if ((flags & FLAG_DEFAULT_DISPLAY) != 0) {
180180
msg.append(", FLAG_DEFAULT_DISPLAY");
181181
}
182-
if ((flags & FLAG_SECURE) != 0) {
183-
msg.append(", FLAG_SECURE");
182+
if ((flags & FLAG_SUPPORTS_ROTATION) != 0) {
183+
msg.append(", FLAG_DEFAULT_DISPLAY");
184+
}
185+
if ((flags & FLAG_SUPPORTS_SECURE_VIDEO_OUTPUT) != 0) {
186+
msg.append(", FLAG_SUPPORTS_SECURE_VIDEO_OUTPUT");
184187
}
185188
return msg.toString();
186189
}

services/java/com/android/server/display/HeadlessDisplayAdapter.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ public DisplayDeviceInfo getDisplayDeviceInfoLocked() {
6060
mInfo.xDpi = 160;
6161
mInfo.yDpi = 160;
6262
mInfo.flags = DisplayDeviceInfo.FLAG_DEFAULT_DISPLAY
63-
| DisplayDeviceInfo.FLAG_SECURE;
63+
| DisplayDeviceInfo.FLAG_SUPPORTS_SECURE_VIDEO_OUTPUT;
6464
mInfo.touch = DisplayDeviceInfo.TOUCH_NONE;
6565
}
6666
return mInfo;

services/java/com/android/server/display/LocalDisplayAdapter.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ public DisplayDeviceInfo getDisplayDeviceInfoLocked() {
124124
mInfo.name = getContext().getResources().getString(
125125
com.android.internal.R.string.display_manager_built_in_display_name);
126126
mInfo.flags = DisplayDeviceInfo.FLAG_DEFAULT_DISPLAY
127-
| DisplayDeviceInfo.FLAG_SECURE
127+
| DisplayDeviceInfo.FLAG_SUPPORTS_SECURE_VIDEO_OUTPUT
128128
| DisplayDeviceInfo.FLAG_SUPPORTS_ROTATION;
129129
mInfo.densityDpi = (int)(mPhys.density * 160 + 0.5f);
130130
mInfo.xDpi = mPhys.xDpi;
@@ -133,7 +133,7 @@ public DisplayDeviceInfo getDisplayDeviceInfoLocked() {
133133
} else {
134134
mInfo.name = getContext().getResources().getString(
135135
com.android.internal.R.string.display_manager_hdmi_display_name);
136-
mInfo.flags = DisplayDeviceInfo.FLAG_SECURE;
136+
mInfo.flags = DisplayDeviceInfo.FLAG_SUPPORTS_SECURE_VIDEO_OUTPUT;
137137
mInfo.touch = DisplayDeviceInfo.TOUCH_EXTERNAL;
138138
mInfo.setAssumedDensityForExternalDisplay(mPhys.width, mPhys.height);
139139
}

services/java/com/android/server/display/LogicalDisplay.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
package com.android.server.display;
1818

1919
import android.graphics.Rect;
20+
import android.view.Display;
2021
import android.view.DisplayInfo;
2122
import android.view.Surface;
2223

@@ -177,6 +178,10 @@ public void updateLocked(List<DisplayDevice> devices) {
177178
DisplayDeviceInfo deviceInfo = mPrimaryDisplayDevice.getDisplayDeviceInfoLocked();
178179
if (!Objects.equal(mPrimaryDisplayDeviceInfo, deviceInfo)) {
179180
mBaseDisplayInfo.layerStack = mLayerStack;
181+
mBaseDisplayInfo.flags = 0;
182+
if ((deviceInfo.flags & DisplayDeviceInfo.FLAG_SUPPORTS_SECURE_VIDEO_OUTPUT) != 0) {
183+
mBaseDisplayInfo.flags |= Display.FLAG_SUPPORTS_SECURE_VIDEO_OUTPUT;
184+
}
180185
mBaseDisplayInfo.name = deviceInfo.name;
181186
mBaseDisplayInfo.appWidth = deviceInfo.width;
182187
mBaseDisplayInfo.appHeight = deviceInfo.height;

services/java/com/android/server/display/OverlayDisplayAdapter.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -227,7 +227,7 @@ public DisplayDeviceInfo getDisplayDeviceInfoLocked() {
227227
mInfo.densityDpi = mDensityDpi;
228228
mInfo.xDpi = mDensityDpi;
229229
mInfo.yDpi = mDensityDpi;
230-
mInfo.flags = DisplayDeviceInfo.FLAG_SECURE;
230+
mInfo.flags = DisplayDeviceInfo.FLAG_SUPPORTS_SECURE_VIDEO_OUTPUT;
231231
mInfo.touch = DisplayDeviceInfo.TOUCH_NONE;
232232
}
233233
return mInfo;

services/java/com/android/server/display/WifiDisplayAdapter.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ private void handleConnectLocked(WifiDisplay display,
149149

150150
int deviceFlags = 0;
151151
if ((flags & RemoteDisplay.DISPLAY_FLAG_SECURE) != 0) {
152-
deviceFlags |= DisplayDeviceInfo.FLAG_SECURE;
152+
deviceFlags |= DisplayDeviceInfo.FLAG_SUPPORTS_SECURE_VIDEO_OUTPUT;
153153
}
154154

155155
float refreshRate = 60.0f; // TODO: get this for real

services/java/com/android/server/display/WifiDisplayController.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@
6262
*/
6363
final class WifiDisplayController implements DumpUtils.Dump {
6464
private static final String TAG = "WifiDisplayController";
65-
private static final boolean DEBUG = true;
65+
private static final boolean DEBUG = false;
6666

6767
private static final int DEFAULT_CONTROL_PORT = 7236;
6868
private static final int MAX_THROUGHPUT = 50;

0 commit comments

Comments
 (0)