Make circular mask thickness configurable
Obtain the circular mask thickness as a dimension so that it can
be customized per-device.
Change-Id: Ied88f91424c5cf4f25dd1e78cf22f0fd7ea7b0a4
Signed-off-by: Prashant Malani <pmalani@google.com>
diff --git a/core/res/res/values/dimens.xml b/core/res/res/values/dimens.xml
index 30ea7c1..181bdf2 100644
--- a/core/res/res/values/dimens.xml
+++ b/core/res/res/values/dimens.xml
@@ -414,6 +414,10 @@
to 0 -->
<dimen name="circular_display_mask_offset">0px</dimen>
+ <!-- Amount to reduce the size of the circular mask by (to compensate for aliasing
+ effects). This is only used on circular displays. -->
+ <dimen name="circular_display_mask_thickness">1px</dimen>
+
<dimen name="lock_pattern_dot_line_width">3dp</dimen>
<dimen name="lock_pattern_dot_size">12dp</dimen>
<dimen name="lock_pattern_dot_size_activated">28dp</dimen>
diff --git a/core/res/res/values/symbols.xml b/core/res/res/values/symbols.xml
index 464e4d3..e7bd90a 100755
--- a/core/res/res/values/symbols.xml
+++ b/core/res/res/values/symbols.xml
@@ -420,6 +420,7 @@
<java-symbol type="dimen" name="immersive_mode_cling_width" />
<java-symbol type="dimen" name="circular_display_mask_offset" />
<java-symbol type="dimen" name="accessibility_magnification_indicator_width" />
+ <java-symbol type="dimen" name="circular_display_mask_thickness" />
<java-symbol type="string" name="add_account_button_label" />
<java-symbol type="string" name="addToDictionary" />
diff --git a/services/core/java/com/android/server/wm/CircularDisplayMask.java b/services/core/java/com/android/server/wm/CircularDisplayMask.java
index 9fdfc47..7c2da2d 100644
--- a/services/core/java/com/android/server/wm/CircularDisplayMask.java
+++ b/services/core/java/com/android/server/wm/CircularDisplayMask.java
@@ -50,9 +50,10 @@
private int mRotation;
private boolean mVisible;
private boolean mDimensionsUnequal = false;
+ private int mMaskThickness;
public CircularDisplayMask(Display display, SurfaceSession session, int zOrder,
- int screenOffset) {
+ int screenOffset, int maskThickness) {
mScreenSize = new Point();
display.getSize(mScreenSize);
if (mScreenSize.x != mScreenSize.y) {
@@ -84,6 +85,7 @@
mPaint.setAntiAlias(true);
mPaint.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.CLEAR));
mScreenOffset = screenOffset;
+ mMaskThickness = maskThickness;
}
private void drawIfNeeded() {
@@ -121,8 +123,8 @@
int circleRadius = mScreenSize.x / 2;
c.drawColor(Color.BLACK);
- // The radius is reduced by 1 to provide an anti aliasing effect on the display edges.
- c.drawCircle(circleRadius, circleRadius, circleRadius - 1, mPaint);
+ // The radius is reduced by mMaskThickness to provide an anti aliasing effect on the display edges.
+ c.drawCircle(circleRadius, circleRadius, circleRadius - mMaskThickness, mPaint);
mSurface.unlockCanvasAndPost(c);
}
diff --git a/services/core/java/com/android/server/wm/WindowManagerService.java b/services/core/java/com/android/server/wm/WindowManagerService.java
index 5ca9ef7..0cda6fd 100644
--- a/services/core/java/com/android/server/wm/WindowManagerService.java
+++ b/services/core/java/com/android/server/wm/WindowManagerService.java
@@ -5944,13 +5944,15 @@
if (mCircularDisplayMask == null) {
int screenOffset = mContext.getResources().getDimensionPixelSize(
com.android.internal.R.dimen.circular_display_mask_offset);
+ int maskThickness = mContext.getResources().getDimensionPixelSize(
+ com.android.internal.R.dimen.circular_display_mask_thickness);
mCircularDisplayMask = new CircularDisplayMask(
getDefaultDisplayContentLocked().getDisplay(),
mFxSession,
mPolicy.windowTypeToLayerLw(
WindowManager.LayoutParams.TYPE_POINTER)
- * TYPE_LAYER_MULTIPLIER + 10, screenOffset);
+ * TYPE_LAYER_MULTIPLIER + 10, screenOffset, maskThickness);
}
mCircularDisplayMask.setVisibility(true);
} else if (mCircularDisplayMask != null) {