From 9bbd9661c05cbf0895e9468519ebf8effa655617 Mon Sep 17 00:00:00 2001 From: Adrian Roos Date: Fri, 2 Mar 2018 14:31:37 +0100 Subject: [PATCH] DisplayCutout API: Make constructor public and adjust javadoc Change-Id: I093cf4f9ea60f00e187aeb4a548f3f5789d87fa1 Fixes: 73953880 Test: make update-api (cherry picked from commit d61db603fecefc72ce6454d34b24bab821337295) --- api/current.txt | 1 + core/java/android/view/DisplayCutout.java | 28 +++++++++++++++++------ 2 files changed, 22 insertions(+), 7 deletions(-) diff --git a/api/current.txt b/api/current.txt index 7bdff3f7c7942..01117c9c27161 100644 --- a/api/current.txt +++ b/api/current.txt @@ -46575,6 +46575,7 @@ package android.view { } public final class DisplayCutout { + ctor public DisplayCutout(android.graphics.Rect, android.graphics.Region); method public android.graphics.Region getBounds(); method public int getSafeInsetBottom(); method public int getSafeInsetLeft(); diff --git a/core/java/android/view/DisplayCutout.java b/core/java/android/view/DisplayCutout.java index f5b7068998d6d..bb16afddcd63e 100644 --- a/core/java/android/view/DisplayCutout.java +++ b/core/java/android/view/DisplayCutout.java @@ -89,7 +89,21 @@ public final class DisplayCutout { private final Rect mSafeInsets; private final Region mBounds; - private final Size mFrameSize; + private final Size mFrameSize; // TODO: move frameSize, calculateRelativeTo, etc. into WM. + + /** + * Creates a DisplayCutout instance. + * + * @param safeInsets the insets from each edge which avoid the display cutout as returned by + * {@link #getSafeInsetTop()} etc. + * @param bounds the bounds of the display cutout as returned by {@link #getBounds()}. + */ + // TODO(b/73953958): @VisibleForTesting(visibility = PRIVATE) + public DisplayCutout(Rect safeInsets, Region bounds) { + this(safeInsets != null ? new Rect(safeInsets) : ZERO_RECT, + bounds != null ? Region.obtain(bounds) : Region.obtain(), + null /* frameSize */); + } /** * Creates a DisplayCutout instance. @@ -114,28 +128,28 @@ public final class DisplayCutout { return mSafeInsets.equals(ZERO_RECT); } - /** Returns the inset from the top which avoids the display cutout. */ + /** Returns the inset from the top which avoids the display cutout in pixels. */ public int getSafeInsetTop() { return mSafeInsets.top; } - /** Returns the inset from the bottom which avoids the display cutout. */ + /** Returns the inset from the bottom which avoids the display cutout in pixels. */ public int getSafeInsetBottom() { return mSafeInsets.bottom; } - /** Returns the inset from the left which avoids the display cutout. */ + /** Returns the inset from the left which avoids the display cutout in pixels. */ public int getSafeInsetLeft() { return mSafeInsets.left; } - /** Returns the inset from the right which avoids the display cutout. */ + /** Returns the inset from the right which avoids the display cutout in pixels. */ public int getSafeInsetRight() { return mSafeInsets.right; } /** - * Returns the safe insets in a rect. + * Returns the safe insets in a rect in pixel units. * * @return a rect which is set to the safe insets. * @hide @@ -148,7 +162,7 @@ public final class DisplayCutout { * Returns the bounding region of the cutout. * * @return the bounding region of the cutout. Coordinates are relative - * to the top-left corner of the content view. + * to the top-left corner of the content view and in pixel units. */ public Region getBounds() { return Region.obtain(mBounds);