summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author An An Yu <ananyu@google.com> 2022-10-07 21:02:22 +0000
committer Android (Google) Code Review <android-gerrit@google.com> 2022-10-07 21:02:22 +0000
commit112fa53798a614e9e0d6976b56cc5cd016044edd (patch)
tree12391ddee82a4100ff4b26bd5cf722d021492836
parent4dfa9bd55d19480bc50c08cb66fac6ebfd5cb3c7 (diff)
parent430d40eea63a908a96460726c4625a54edc7e907 (diff)
Merge "add @Override for addWindowLayoutInfoListener(context) and update prebuilts." into tm-qpr-dev
-rw-r--r--libs/WindowManager/Jetpack/src/androidx/window/extensions/layout/WindowLayoutComponentImpl.java15
-rw-r--r--libs/WindowManager/Jetpack/window-extensions-release.aarbin30713 -> 30816 bytes
2 files changed, 12 insertions, 3 deletions
diff --git a/libs/WindowManager/Jetpack/src/androidx/window/extensions/layout/WindowLayoutComponentImpl.java b/libs/WindowManager/Jetpack/src/androidx/window/extensions/layout/WindowLayoutComponentImpl.java
index c76f568e117f..0fb6ff878451 100644
--- a/libs/WindowManager/Jetpack/src/androidx/window/extensions/layout/WindowLayoutComponentImpl.java
+++ b/libs/WindowManager/Jetpack/src/androidx/window/extensions/layout/WindowLayoutComponentImpl.java
@@ -103,14 +103,23 @@ public class WindowLayoutComponentImpl implements WindowLayoutComponent {
/**
* Similar to {@link #addWindowLayoutInfoListener(Activity, Consumer)}, but takes a UI Context
* as a parameter.
+ *
+ * Jetpack {@link androidx.window.layout.ExtensionWindowLayoutInfoBackend} makes sure all
+ * consumers related to the same {@link Context} gets updated {@link WindowLayoutInfo}
+ * together. However only the first registered consumer of a {@link Context} will actually
+ * invoke {@link #addWindowLayoutInfoListener(Context, Consumer)}.
+ * Here we enforce that {@link #addWindowLayoutInfoListener(Context, Consumer)} can only be
+ * called once for each {@link Context}.
*/
- // TODO(b/204073440): Add @Override to hook the API in WM extensions library.
+ @Override
public void addWindowLayoutInfoListener(@NonNull @UiContext Context context,
@NonNull Consumer<WindowLayoutInfo> consumer) {
if (mWindowLayoutChangeListeners.containsKey(context)
+ // In theory this method can be called on the same consumer with different context.
|| mWindowLayoutChangeListeners.containsValue(consumer)) {
- // Early return if the listener or consumer has been registered.
- return;
+ throw new IllegalArgumentException(
+ "Context or Consumer has already been registered for WindowLayoutInfo"
+ + " callback.");
}
if (!context.isUiContext()) {
throw new IllegalArgumentException("Context must be a UI Context, which should be"
diff --git a/libs/WindowManager/Jetpack/window-extensions-release.aar b/libs/WindowManager/Jetpack/window-extensions-release.aar
index 2c766d81d611..b0b95f9cc871 100644
--- a/libs/WindowManager/Jetpack/window-extensions-release.aar
+++ b/libs/WindowManager/Jetpack/window-extensions-release.aar
Binary files differ