From a05912b129748cac6957e4c4646bbdd0443b2ced Mon Sep 17 00:00:00 2001 From: Jon Eckenrode Date: Fri, 5 Nov 2021 18:34:14 +0000 Subject: [PATCH] Reconciled description of WindowManager with description of Context#createDisplayContext(). Signed-off-by: joneckenrode Change-Id: I428ab2c0303ebf6414a0e29ad844c1c52af2db43 --- core/java/android/content/Context.java | 36 ++++++++++------------- core/java/android/view/WindowManager.java | 20 ++++++------- 2 files changed, 24 insertions(+), 32 deletions(-) diff --git a/core/java/android/content/Context.java b/core/java/android/content/Context.java index 6885c10b48898..f6c8a9af2a3a8 100644 --- a/core/java/android/content/Context.java +++ b/core/java/android/content/Context.java @@ -6441,30 +6441,24 @@ public abstract class Context { @NonNull Configuration overrideConfiguration); /** - * Return a new Context object for the current Context but whose resources - * are adjusted to match the metrics of the given Display. Each call to this method - * returns a new instance of a Context object; Context objects are not - * shared, however common state (ClassLoader, other Resources for the - * same configuration) may be so the Context itself can be fairly lightweight. - * - * To obtain an instance of a {@link WindowManager} (see {@link #getSystemService(String)}) that - * is configured to show windows on the given display call - * {@link #createWindowContext(int, Bundle)} on the returned display Context or use an - * {@link android.app.Activity}. - * + * Returns a new Context object from the current context but with resources + * adjusted to match the metrics of display. Each call to this method + * returns a new instance of a context object. Context objects are not shared; however, + * common state (such as the {@link ClassLoader} and other resources for the same + * configuration) can be shared, so the Context itself is lightweight. *

- * Note that invoking #createDisplayContext(Display) from an UI context is not regarded - * as an UI context. In other words, it is not suggested to access UI components (such as - * obtain a {@link WindowManager} by {@link #getSystemService(String)}) - * from the context created from #createDisplayContext(Display). - *

+ * To obtain an instance of {@link WindowManager} configured to show windows on the given + * display, call {@link #createWindowContext(int, Bundle)} on the returned display context, + * then call {@link #getSystemService(String)} or {@link #getSystemService(Class)} on the + * returned window context. + *

+ * Note: The context returned by createDisplayContext(Display) is not a UI + * context. Do not access UI components or obtain a {@link WindowManager} from the context + * created by createDisplayContext(Display). * - * @param display A {@link Display} object specifying the display for whose metrics the - * Context's resources should be tailored. + * @param display The display to which the current context's resources are adjusted. * - * @return A {@link Context} for the display. - * - * @see #getSystemService(String) + * @return A context for the display. */ @DisplayContext public abstract Context createDisplayContext(@NonNull Display display); diff --git a/core/java/android/view/WindowManager.java b/core/java/android/view/WindowManager.java index 55beae0f7b3d9..00f4eb83bdaac 100644 --- a/core/java/android/view/WindowManager.java +++ b/core/java/android/view/WindowManager.java @@ -127,17 +127,15 @@ import java.util.function.Consumer; /** * The interface that apps use to talk to the window manager. - *

- * Each window manager instance is bound to a particular {@link Display}. - * To obtain a {@link WindowManager} for a different display, use - * {@link Context#createDisplayContext} to obtain a {@link Context} for that - * display, then use Context.getSystemService(Context.WINDOW_SERVICE) - * to get the WindowManager. - *

- * The simplest way to show a window on another display is to create a - * {@link Presentation}. The presentation will automatically obtain a - * {@link WindowManager} and {@link Context} for that display. - *

+ *

+ * Each window manager instance is bound to a {@link Display}. To obtain the + * WindowManager associated with a display, + * call {@link Context#createWindowContext(Display, int, Bundle)} to get the display's UI context, + * then call {@link Context#getSystemService(String)} or {@link Context#getSystemService(Class)} on + * the UI context. + *

+ * The simplest way to show a window on a particular display is to create a {@link Presentation}, + * which automatically obtains a WindowManager and context for the display. */ @SystemService(Context.WINDOW_SERVICE) public interface WindowManager extends ViewManager {