Skip to content

Commit bcbe9cf

Browse files
Jeff BrownAndroid (Google) Code Review
authored andcommitted
Merge "Add new Display API for secure video capabilities." into jb-mr1-dev
2 parents 9c614bf + 77aebfd commit bcbe9cf

File tree

12 files changed

+69
-47
lines changed

12 files changed

+69
-47
lines changed

api/17.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23714,6 +23714,7 @@ package android.view {
2371423714
public final class Display {
2371523715
method public void getCurrentSizeRange(android.graphics.Point, android.graphics.Point);
2371623716
method public int getDisplayId();
23717+
method public int getFlags();
2371723718
method public deprecated int getHeight();
2371823719
method public void getMetrics(android.util.DisplayMetrics);
2371923720
method public java.lang.String getName();
@@ -23728,6 +23729,7 @@ package android.view {
2372823729
method public deprecated int getWidth();
2372923730
method public boolean isValid();
2373023731
field public static final int DEFAULT_DISPLAY = 0; // 0x0
23732+
field public static final int FLAG_SUPPORTS_PROTECTED_BUFFERS = 1; // 0x1
2373123733
}
2373223734

2373323735
public class DragEvent implements android.os.Parcelable {

api/current.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23719,6 +23719,7 @@ package android.view {
2371923719
public final class Display {
2372023720
method public void getCurrentSizeRange(android.graphics.Point, android.graphics.Point);
2372123721
method public int getDisplayId();
23722+
method public int getFlags();
2372223723
method public deprecated int getHeight();
2372323724
method public void getMetrics(android.util.DisplayMetrics);
2372423725
method public java.lang.String getName();
@@ -23733,6 +23734,7 @@ package android.view {
2373323734
method public deprecated int getWidth();
2373423735
method public boolean isValid();
2373523736
field public static final int DEFAULT_DISPLAY = 0; // 0x0
23737+
field public static final int FLAG_SUPPORTS_PROTECTED_BUFFERS = 1; // 0x1
2373623738
}
2373723739

2373823740
public class DragEvent implements android.os.Parcelable {

core/java/android/view/Display.java

Lines changed: 14 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -79,38 +79,23 @@ public final class Display {
7979
public static final int DEFAULT_DISPLAY = 0;
8080

8181
/**
82-
* Display flag: Indicates that the display supports secure video output.
82+
* Display flag: Indicates that the display supports compositing content
83+
* that is stored in protected graphics buffers.
8384
* <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.
85+
* Secure (DRM) video decoders may allocate protected graphics buffers to request that
86+
* a hardware-protected path be provided between the video decoder and the external
87+
* display sink. If a hardware-protected path is not available, then content stored
88+
* in protected graphics buffers may not be composited.
8789
* </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 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.
90+
* If this flag is not set, then the display device does not support compositing
91+
* protected buffers; the user may see a blank region on the screen instead of
92+
* the protected content. An application can use this flag as a hint that it should
93+
* select an alternate content stream or adopt a different strategy for decoding
94+
* content that does not rely on protected buffers so as to ensure that the user
95+
* can view the content on the display as expected.
10996
* </p>
110-
*
111-
* @hide pending review
11297
*/
113-
public static final int FLAG_SUPPORTS_SECURE_VIDEO_BUFFERS = 1 << 1;
98+
public static final int FLAG_SUPPORTS_PROTECTED_BUFFERS = 1 << 0;
11499

115100
/**
116101
* Internal method to create a display.
@@ -196,7 +181,7 @@ public int getLayerStack() {
196181
*
197182
* @return The display flags.
198183
*
199-
* @hide pending review
184+
* @see #FLAG_SUPPORTS_PROTECTED_BUFFERS
200185
*/
201186
public int getFlags() {
202187
synchronized (this) {

core/java/android/view/DisplayInfo.java

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -299,11 +299,8 @@ public String toString() {
299299

300300
private static String flagsToString(int flags) {
301301
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");
302+
if ((flags & Display.FLAG_SUPPORTS_PROTECTED_BUFFERS) != 0) {
303+
result.append(", FLAG_SUPPORTS_PROTECTED_BUFFERS");
307304
}
308305
return result.toString();
309306
}

core/res/res/values/config.xml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -967,4 +967,18 @@
967967
<!-- Whether safe headphone volume is enabled or not (country specific). -->
968968
<bool name="config_safe_media_volume_enabled">true</bool>
969969

970+
<!-- Set to true if the wifi display supports compositing content stored
971+
in gralloc protected buffers. For this to be true, there must exist
972+
a protected hardware path for surface flinger to composite and send
973+
protected buffers to the wifi display video encoder.
974+
975+
If this flag is false, we advise applications not to use protected
976+
buffers (if possible) when presenting content to a wifi display because
977+
the content may be blanked.
978+
979+
This flag controls whether the {@link Display#FLAG_SUPPORTS_PROTECTED_BUFFERS}
980+
flag is set for wifi displays.
981+
-->
982+
<bool name="config_wifiDisplaySupportsProtectedBuffers">false</bool>
983+
970984
</resources>

core/res/res/values/symbols.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -261,6 +261,7 @@
261261
<java-symbol type="bool" name="config_ui_enableFadingMarquee" />
262262
<java-symbol type="bool" name="config_use_strict_phone_number_comparation" />
263263
<java-symbol type="bool" name="config_voice_capable" />
264+
<java-symbol type="bool" name="config_wifiDisplaySupportsProtectedBuffers" />
264265
<java-symbol type="bool" name="preferences_prefer_dual_pane" />
265266
<java-symbol type="bool" name="skip_restoring_network_selection" />
266267
<java-symbol type="bool" name="split_action_bar_is_narrow" />

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

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,15 @@ final class DisplayDeviceInfo {
3838
public static final int FLAG_SUPPORTS_ROTATION = 1 << 1;
3939

4040
/**
41-
* Flag: Indicates that this display device can show secure surfaces.
41+
* Flag: Indicates that this display device has secure video output, such as HDCP.
4242
*/
43-
public static final int FLAG_SUPPORTS_SECURE_VIDEO_OUTPUT = 1 << 2;
43+
public static final int FLAG_SECURE = 1 << 2;
44+
45+
/**
46+
* Flag: Indicates that this display device supports compositing
47+
* from gralloc protected buffers.
48+
*/
49+
public static final int FLAG_SUPPORTS_PROTECTED_BUFFERS = 1 << 3;
4450

4551
/**
4652
* Touch attachment: Display does not receive touch.
@@ -182,8 +188,11 @@ private static String flagsToString(int flags) {
182188
if ((flags & FLAG_SUPPORTS_ROTATION) != 0) {
183189
msg.append(", FLAG_SUPPORTS_ROTATION");
184190
}
185-
if ((flags & FLAG_SUPPORTS_SECURE_VIDEO_OUTPUT) != 0) {
186-
msg.append(", FLAG_SUPPORTS_SECURE_VIDEO_OUTPUT");
191+
if ((flags & FLAG_SECURE) != 0) {
192+
msg.append(", FLAG_SECURE");
193+
}
194+
if ((flags & FLAG_SUPPORTS_PROTECTED_BUFFERS) != 0) {
195+
msg.append(", FLAG_SUPPORTS_PROTECTED_BUFFERS");
187196
}
188197
return msg.toString();
189198
}

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,8 @@ public DisplayDeviceInfo getDisplayDeviceInfoLocked() {
6060
mInfo.xDpi = 160;
6161
mInfo.yDpi = 160;
6262
mInfo.flags = DisplayDeviceInfo.FLAG_DEFAULT_DISPLAY
63-
| DisplayDeviceInfo.FLAG_SUPPORTS_SECURE_VIDEO_OUTPUT;
63+
| DisplayDeviceInfo.FLAG_SECURE
64+
| DisplayDeviceInfo.FLAG_SUPPORTS_PROTECTED_BUFFERS;
6465
mInfo.touch = DisplayDeviceInfo.TOUCH_NONE;
6566
}
6667
return mInfo;

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

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -124,11 +124,16 @@ public DisplayDeviceInfo getDisplayDeviceInfoLocked() {
124124
mInfo.width = mPhys.width;
125125
mInfo.height = mPhys.height;
126126
mInfo.refreshRate = mPhys.refreshRate;
127+
128+
// Assume that all built-in displays have secure output (eg. HDCP) and
129+
// support compositing from gralloc protected buffers.
130+
mInfo.flags = DisplayDeviceInfo.FLAG_SECURE
131+
| DisplayDeviceInfo.FLAG_SUPPORTS_PROTECTED_BUFFERS;
132+
127133
if (mBuiltInDisplayId == Surface.BUILT_IN_DISPLAY_ID_MAIN) {
128134
mInfo.name = getContext().getResources().getString(
129135
com.android.internal.R.string.display_manager_built_in_display_name);
130-
mInfo.flags = DisplayDeviceInfo.FLAG_DEFAULT_DISPLAY
131-
| DisplayDeviceInfo.FLAG_SUPPORTS_SECURE_VIDEO_OUTPUT
136+
mInfo.flags |= DisplayDeviceInfo.FLAG_DEFAULT_DISPLAY
132137
| DisplayDeviceInfo.FLAG_SUPPORTS_ROTATION;
133138
mInfo.densityDpi = (int)(mPhys.density * 160 + 0.5f);
134139
mInfo.xDpi = mPhys.xDpi;
@@ -137,7 +142,6 @@ public DisplayDeviceInfo getDisplayDeviceInfoLocked() {
137142
} else {
138143
mInfo.name = getContext().getResources().getString(
139144
com.android.internal.R.string.display_manager_hdmi_display_name);
140-
mInfo.flags = DisplayDeviceInfo.FLAG_SUPPORTS_SECURE_VIDEO_OUTPUT;
141145
mInfo.touch = DisplayDeviceInfo.TOUCH_EXTERNAL;
142146
mInfo.setAssumedDensityForExternalDisplay(mPhys.width, mPhys.height);
143147
}

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -179,8 +179,8 @@ public void updateLocked(List<DisplayDevice> devices) {
179179
if (!Objects.equal(mPrimaryDisplayDeviceInfo, deviceInfo)) {
180180
mBaseDisplayInfo.layerStack = mLayerStack;
181181
mBaseDisplayInfo.flags = 0;
182-
if ((deviceInfo.flags & DisplayDeviceInfo.FLAG_SUPPORTS_SECURE_VIDEO_OUTPUT) != 0) {
183-
mBaseDisplayInfo.flags |= Display.FLAG_SUPPORTS_SECURE_VIDEO_OUTPUT;
182+
if ((deviceInfo.flags & DisplayDeviceInfo.FLAG_SUPPORTS_PROTECTED_BUFFERS) != 0) {
183+
mBaseDisplayInfo.flags |= Display.FLAG_SUPPORTS_PROTECTED_BUFFERS;
184184
}
185185
mBaseDisplayInfo.name = deviceInfo.name;
186186
mBaseDisplayInfo.appWidth = deviceInfo.width;

0 commit comments

Comments
 (0)