Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(584)

Unified Diff: ui/android/java/src/org/chromium/ui/display/DisplayAndroid.java

Issue 2455653002: Make clear that WindowAndroid::getDisplay must be used when supporting multi-display. (Closed)
Patch Set: Revert change that snuck in from other branch Created 4 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: ui/android/java/src/org/chromium/ui/display/DisplayAndroid.java
diff --git a/ui/android/java/src/org/chromium/ui/display/DisplayAndroid.java b/ui/android/java/src/org/chromium/ui/display/DisplayAndroid.java
index 075754c76eb64468255b561e9b672d44ef45acac..686946293b2db01635b583cd84e20d51ee7e7394 100644
--- a/ui/android/java/src/org/chromium/ui/display/DisplayAndroid.java
+++ b/ui/android/java/src/org/chromium/ui/display/DisplayAndroid.java
@@ -87,12 +87,22 @@ public class DisplayAndroid {
}
/**
- * Get the DisplayAndroid for this context. It's safe to call this with any type of context
- * including the Application. However to support multi-display, prefer to use the Activity
- * context if available, or obtain DisplayAndroid from WindowAndroid instead.
+ * Get the non-multi-display DisplayAndroid for the given context. It's safe to call this with
+ * any type of context, including the Application.
+ *
+ * To support multi-display, obtain DisplayAndroid from WindowAndroid instead.
+ *
+ * This function is intended to be analogous to GetPrimaryDisplay() for other platforms.
+ * However, Android has historically had no real concept of a Primary Display, and instead uses
+ * the notion of a default display for an Activity. Under normal circumstances, this function,
+ * called with the correct context, will return the expected display for an Activity. However,
+ * virtual, or "fake", displays that are not associated with any context may be used in special
+ * cases, like Virtual Reality, and will lead to this function returning the incorrect display.
+ *
+ * @return What the Android WindowManager considers to be the default display for this context.
*/
- public static DisplayAndroid get(Context context) {
- Display display = DisplayAndroidManager.getDisplayFromContext(context);
+ public static DisplayAndroid getNonMultiDisplay(Context context) {
+ Display display = DisplayAndroidManager.getDefaultDisplayForContext(context);
return getManager().getDisplayAndroid(display);
}

Powered by Google App Engine
This is Rietveld 408576698