From 7e9a26fb1836fc7ab49f82b5a690e4ca2873ba1e Mon Sep 17 00:00:00 2001 From: Robin Lee Date: Tue, 14 Feb 2017 12:45:04 +0000 Subject: [PATCH] Redact GridTaskViewThumbnail This inherits from TaskViewThumbnail but has its own drawing logic that skips work redaction for locked users. This is required by CTS Verifier, so it needs to be done here as well. Test: visual, instructions -- Test: (1) set up work profile on ryu with a password Test: (2) turn screen off and on again Test: (3) go to recents, verify work apps redacted with correct color Test: (4) open a work app, unlock, go back to recents, verify work apps Test: are not redacted any more. Bug: 34836435 Change-Id: I2239fe4c035332a9c9b93d2d2b1c354f204358a8 --- .../recents/views/TaskViewThumbnail.java | 23 +++++++++++++++---- .../views/grid/GridTaskViewThumbnail.java | 13 +++++------ 2 files changed, 25 insertions(+), 11 deletions(-) diff --git a/packages/SystemUI/src/com/android/systemui/recents/views/TaskViewThumbnail.java b/packages/SystemUI/src/com/android/systemui/recents/views/TaskViewThumbnail.java index 4ac0f9eed5197..02b01136f3528 100644 --- a/packages/SystemUI/src/com/android/systemui/recents/views/TaskViewThumbnail.java +++ b/packages/SystemUI/src/com/android/systemui/recents/views/TaskViewThumbnail.java @@ -77,10 +77,11 @@ public class TaskViewThumbnail extends View { @ViewDebug.ExportedProperty(category="recents") private float mDimAlpha; private Matrix mMatrix = new Matrix(); - protected Paint mDrawPaint = new Paint(); - private Paint mLockedPaint = new Paint(); + private Paint mDrawPaint = new Paint(); + protected Paint mLockedPaint = new Paint(); protected Paint mBgFillPaint = new Paint(); protected BitmapShader mBitmapShader; + protected boolean mUserLocked = false; private LightingColorFilter mLightingColorFilter = new LightingColorFilter(0xffffffff, 0); // Clip the top of the thumbnail against the opaque header bar that overlaps this view @@ -152,7 +153,7 @@ public class TaskViewThumbnail extends View { int thumbnailHeight = Math.min(viewHeight, (int) (mThumbnailRect.height() * mThumbnailScale)); - if (mTask != null && mTask.isLocked) { + if (mUserLocked) { canvas.drawRoundRect(0, 0, viewWidth, viewHeight, mCornerRadius, mCornerRadius, mLockedPaint); } else if (mBitmapShader != null && thumbnailWidth > 0 && thumbnailHeight > 0) { @@ -343,6 +344,17 @@ public class TaskViewThumbnail extends View { updateThumbnailPaintFilter(); } + /** + * Returns the {@link Paint} used to draw a task screenshot, or {@link #mLockedPaint} if the + * thumbnail shouldn't be drawn because it belongs to a locked user. + */ + protected Paint getDrawPaint() { + if (mUserLocked) { + return mLockedPaint; + } + return mDrawPaint; + } + /** * Binds the thumbnail view to the task. */ @@ -354,7 +366,10 @@ public class TaskViewThumbnail extends View { if (t.colorBackground != 0) { mBgFillPaint.setColor(t.colorBackground); } - mLockedPaint.setColor(t.colorPrimary); + if (t.colorPrimary != 0) { + mLockedPaint.setColor(t.colorPrimary); + } + mUserLocked = t.isLocked; EventBus.getDefault().register(this); } diff --git a/packages/SystemUI/src/com/android/systemui/recents/views/grid/GridTaskViewThumbnail.java b/packages/SystemUI/src/com/android/systemui/recents/views/grid/GridTaskViewThumbnail.java index 2c3e42b6c7d78..bcf4f17d43406 100644 --- a/packages/SystemUI/src/com/android/systemui/recents/views/grid/GridTaskViewThumbnail.java +++ b/packages/SystemUI/src/com/android/systemui/recents/views/grid/GridTaskViewThumbnail.java @@ -28,7 +28,6 @@ public class GridTaskViewThumbnail extends TaskViewThumbnail { private Path mThumbnailOutline; private Path mRestBackgroundOutline; - private Path mFullBackgroundOutline; // True if either this view's size or thumbnail scale has changed and mThumbnailOutline should // be updated. private boolean mUpdateThumbnailOutline = true; @@ -145,10 +144,7 @@ public class GridTaskViewThumbnail extends TaskViewThumbnail { 90, 90, false); // F mRestBackgroundOutline.lineTo(l, t); // A mRestBackgroundOutline.close(); - } - } else { - mFullBackgroundOutline = mThumbnailOutline; } } @@ -167,7 +163,10 @@ public class GridTaskViewThumbnail extends TaskViewThumbnail { updateThumbnailOutline(); mUpdateThumbnailOutline = false; } - if (mBitmapShader != null && thumbnailWidth > 0 && thumbnailHeight > 0) { + + if (mUserLocked) { + canvas.drawPath(mThumbnailOutline, mLockedPaint); + } else if (mBitmapShader != null && thumbnailWidth > 0 && thumbnailHeight > 0) { // Draw the background, there will be some small overdraw with the thumbnail if (thumbnailWidth < viewWidth) { // Portrait thumbnail on a landscape task view @@ -177,9 +176,9 @@ public class GridTaskViewThumbnail extends TaskViewThumbnail { // Landscape thumbnail on a portrait task view canvas.drawPath(mRestBackgroundOutline, mBgFillPaint); } - canvas.drawPath(mThumbnailOutline, mDrawPaint); + canvas.drawPath(mThumbnailOutline, getDrawPaint()); } else { - canvas.drawPath(mFullBackgroundOutline, mBgFillPaint); + canvas.drawPath(mThumbnailOutline, mBgFillPaint); } } }