Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 7e9a26fb authored by Robin Lee's avatar Robin Lee
Browse files

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
parent f9a55d42
Loading
Loading
Loading
Loading
+19 −4
Original line number Diff line number Diff line
@@ -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);
        }
        if (t.colorPrimary != 0) {
            mLockedPaint.setColor(t.colorPrimary);
        }
        mUserLocked = t.isLocked;
        EventBus.getDefault().register(this);
    }

+6 −7
Original line number Diff line number Diff line
@@ -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);
        }
    }
}