diff options
| author | 2023-07-12 22:20:08 +0000 | |
|---|---|---|
| committer | 2023-07-13 22:36:42 +0000 | |
| commit | 3dc10e85ffe15579cae39d8bea672db8f77e75e8 (patch) | |
| tree | 98921fb0328f419dd737bd632fca87d0632020bb | |
| parent | 2500204620dd6d8321b8a893a46e459741cf12a4 (diff) | |
Add better error message when fold bounds are incorrect.
Add better error message when fold bounds are incorrect.
We need to determine why the bounds are not aligned with either
the top of the window or the left of the window.
Bug: 290112152
Bug: 289221820
Test: Manual - run samples and attach debugger.
Change-Id: I6892128febdb7db108c2d406dff0a72bf3e62c8e
| -rw-r--r-- | libs/WindowManager/Jetpack/src/androidx/window/extensions/layout/WindowLayoutComponentImpl.java | 28 |
1 files changed, 25 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 a45a8a183ac8..2eacaaf28bba 100644 --- a/libs/WindowManager/Jetpack/src/androidx/window/extensions/layout/WindowLayoutComponentImpl.java +++ b/libs/WindowManager/Jetpack/src/androidx/window/extensions/layout/WindowLayoutComponentImpl.java @@ -304,7 +304,7 @@ public class WindowLayoutComponentImpl implements WindowLayoutComponent { * {@link IllegalArgumentException} since this can cause negative UI effects down stream. * * @param context a proxy for the {@link android.view.Window} that contains the - * {@link DisplayFeature}. + * {@link DisplayFeature}. * @return a {@link List} of {@link DisplayFeature}s that are within the * {@link android.view.Window} of the {@link Activity} */ @@ -336,10 +336,32 @@ public class WindowLayoutComponentImpl implements WindowLayoutComponent { rotateRectToDisplayRotation(displayId, featureRect); transformToWindowSpaceRect(windowConfiguration, featureRect); - if (!isZero(featureRect)) { + if (isZero(featureRect)) { // TODO(b/228641877): Remove guarding when fixed. - features.add(new FoldingFeature(featureRect, baseFeature.getType(), state)); + continue; + } + if (featureRect.left != 0 && featureRect.top != 0) { + throw new IllegalArgumentException("Bounding rectangle must start at the top or " + + "left of the window. BaseFeatureRect: " + baseFeature.getRect() + + ", FeatureRect: " + featureRect + + ", WindowConfiguration: " + windowConfiguration); + + } + if (featureRect.left == 0 + && featureRect.width() != windowConfiguration.getBounds().width()) { + throw new IllegalArgumentException("Horizontal FoldingFeature must have full width." + + " BaseFeatureRect: " + baseFeature.getRect() + + ", FeatureRect: " + featureRect + + ", WindowConfiguration: " + windowConfiguration); + } + if (featureRect.top == 0 + && featureRect.height() != windowConfiguration.getBounds().height()) { + throw new IllegalArgumentException("Vertical FoldingFeature must have full height." + + " BaseFeatureRect: " + baseFeature.getRect() + + ", FeatureRect: " + featureRect + + ", WindowConfiguration: " + windowConfiguration); } + features.add(new FoldingFeature(featureRect, baseFeature.getType(), state)); } return features; } |