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

Commit 9f4ab32b authored by Robin Lee's avatar Robin Lee
Browse files

Blank out recents for locked work tasks

Bug: 31001762
Test: WIP TaskViewThumbnailTest.java
Change-Id: I259fa95f642b83728904653c75efc7e417b0ab60
parent 0e4e96f8
Loading
Loading
Loading
Loading
+13 −0
Original line number Diff line number Diff line
@@ -74,6 +74,7 @@ import android.view.WindowManager;
import android.view.WindowManager.KeyboardShortcutsReceiver;
import android.view.WindowManagerGlobal;
import android.view.accessibility.AccessibilityManager;
import android.app.KeyguardManager;

import com.android.internal.app.AssistUtils;
import com.android.internal.os.BackgroundThread;
@@ -124,6 +125,7 @@ public class SystemServicesProxy {
    AssistUtils mAssistUtils;
    WindowManager mWm;
    IWindowManager mIwm;
    KeyguardManager mKgm;
    UserManager mUm;
    Display mDisplay;
    String mRecentsPackage;
@@ -212,6 +214,7 @@ public class SystemServicesProxy {
        mAssistUtils = new AssistUtils(context);
        mWm = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
        mIwm = WindowManagerGlobal.getWindowManagerService();
        mKgm = (KeyguardManager) context.getSystemService(Context.KEYGUARD_SERVICE);
        mUm = UserManager.get(context);
        mDisplay = mWm.getDefaultDisplay();
        mRecentsPackage = context.getPackageName();
@@ -862,6 +865,16 @@ public class SystemServicesProxy {
        return label;
    }

    /**
     * Returns whether the provided {@param userId} is currently locked (and showing Keyguard).
     */
    public boolean isDeviceLocked(int userId) {
        if (mKgm == null) {
            return false;
        }
        return mKgm.isDeviceLocked(userId);
    }

    /** Returns the package name of the home activity. */
    public String getHomeActivityPackageName() {
        if (mPm == null) return null;
+8 −1
Original line number Diff line number Diff line
@@ -28,6 +28,7 @@ import android.os.UserHandle;
import android.os.UserManager;
import android.util.ArraySet;
import android.util.SparseArray;
import android.util.SparseBooleanArray;
import android.util.SparseIntArray;

import com.android.systemui.Prefs;
@@ -130,6 +131,7 @@ public class RecentsTaskLoadPlan {

        SparseArray<Task.TaskKey> affiliatedTasks = new SparseArray<>();
        SparseIntArray affiliatedTaskCounts = new SparseIntArray();
        SparseBooleanArray lockedUsers = new SparseBooleanArray();
        String dismissDescFormat = mContext.getString(
                R.string.accessibility_recents_item_will_be_dismissed);
        String appInfoDescFormat = mContext.getString(
@@ -177,12 +179,17 @@ public class RecentsTaskLoadPlan {
            int backgroundColor = loader.getActivityBackgroundColor(t.taskDescription);
            boolean isSystemApp = (info != null) &&
                    ((info.applicationInfo.flags & ApplicationInfo.FLAG_SYSTEM) != 0);
            if (lockedUsers.indexOfKey(t.userId) < 0) {
                lockedUsers.put(t.userId, Recents.getSystemServices().isDeviceLocked(t.userId));
            }
            boolean isLocked = lockedUsers.get(t.userId);

            // Add the task to the stack
            Task task = new Task(taskKey, t.affiliatedTaskId, t.affiliatedTaskColor, icon,
                    thumbnail, title, titleDescription, dismissDescription, appInfoDescription,
                    activityColor, backgroundColor, isLaunchTarget, isStackTask, isSystemApp,
                    t.isDockable, t.bounds, t.taskDescription, t.resizeMode, t.topActivity);
                    t.isDockable, t.bounds, t.taskDescription, t.resizeMode, t.topActivity,
                    isLocked);

            allTasks.add(task);
            affiliatedTaskCounts.put(taskKey.id, affiliatedTaskCounts.get(taskKey.id, 0) + 1);
+9 −1
Original line number Diff line number Diff line
@@ -189,6 +189,9 @@ public class Task {
    @ViewDebug.ExportedProperty(category="recents")
    public ComponentName topActivity;

    @ViewDebug.ExportedProperty(category="recents")
    public boolean isLocked;

    private ArrayList<TaskCallbacks> mCallbacks = new ArrayList<>();

    public Task() {
@@ -200,7 +203,7 @@ public class Task {
                String appInfoDescription, int colorPrimary, int colorBackground,
                boolean isLaunchTarget, boolean isStackTask, boolean isSystemApp,
                boolean isDockable, Rect bounds, ActivityManager.TaskDescription taskDescription,
                int resizeMode, ComponentName topActivity) {
                int resizeMode, ComponentName topActivity, boolean isLocked) {
        boolean isInAffiliationGroup = (affiliationTaskId != key.id);
        boolean hasAffiliationGroupColor = isInAffiliationGroup && (affiliationColor != 0);
        this.key = key;
@@ -224,6 +227,7 @@ public class Task {
        this.isDockable = isDockable;
        this.resizeMode = resizeMode;
        this.topActivity = topActivity;
        this.isLocked = isLocked;
    }

    /**
@@ -250,6 +254,7 @@ public class Task {
        this.isSystemApp = o.isSystemApp;
        this.isDockable = o.isDockable;
        this.resizeMode = o.resizeMode;
        this.isLocked = o.isLocked;
        this.topActivity = o.topActivity;
    }

@@ -355,6 +360,9 @@ public class Task {
        if (isFreeformTask()) {
            writer.print(" freeform=Y");
        }
        if (isLocked) {
            writer.print(" locked=Y");
        }
        writer.print(" "); writer.print(title);
        writer.println();
    }
+10 −1
Original line number Diff line number Diff line
@@ -67,6 +67,7 @@ public class TaskViewThumbnail extends View {
    private float mDimAlpha;
    private Matrix mScaleMatrix = new Matrix();
    private Paint mDrawPaint = new Paint();
    private Paint mLockedPaint = new Paint();
    private Paint mBgFillPaint = new Paint();
    private BitmapShader mBitmapShader;
    private LightingColorFilter mLightingColorFilter = new LightingColorFilter(0xffffffff, 0);
@@ -102,6 +103,7 @@ public class TaskViewThumbnail extends View {
        mCornerRadius = getResources().getDimensionPixelSize(
                R.dimen.recents_task_view_rounded_corners_radius);
        mBgFillPaint.setColor(Color.WHITE);
        mLockedPaint.setColor(Color.WHITE);
        mFullscreenThumbnailScale = context.getResources().getFraction(
                com.android.internal.R.fraction.thumbnail_fullscreen_scale, 1, 1);
    }
@@ -133,7 +135,11 @@ public class TaskViewThumbnail extends View {
                (int) (mThumbnailRect.width() * mThumbnailScale));
        int thumbnailHeight = Math.min(viewHeight,
                (int) (mThumbnailRect.height() * mThumbnailScale));
        if (mBitmapShader != null && thumbnailWidth > 0 && thumbnailHeight > 0) {

        if (mTask.isLocked) {
            canvas.drawRoundRect(0, 0, viewWidth, viewHeight, mCornerRadius, mCornerRadius,
                    mLockedPaint);
        } else if (mBitmapShader != null && thumbnailWidth > 0 && thumbnailHeight > 0) {
            int topOffset = mTaskBar != null
                    ? mTaskBar.getHeight() - mCornerRadius
                    : 0;
@@ -200,11 +206,13 @@ public class TaskViewThumbnail extends View {
                ColorMatrixColorFilter filter = new ColorMatrixColorFilter(TMP_FILTER_COLOR_MATRIX);
                mDrawPaint.setColorFilter(filter);
                mBgFillPaint.setColorFilter(filter);
                mLockedPaint.setColorFilter(filter);
            } else {
                mLightingColorFilter.setColorMultiply(Color.argb(255, mul, mul, mul));
                mDrawPaint.setColorFilter(mLightingColorFilter);
                mDrawPaint.setColor(0xFFffffff);
                mBgFillPaint.setColorFilter(mLightingColorFilter);
                mLockedPaint.setColorFilter(mLightingColorFilter);
            }
        } else {
            int grey = mul;
@@ -299,6 +307,7 @@ public class TaskViewThumbnail extends View {
        if (t.colorBackground != 0) {
            mBgFillPaint.setColor(t.colorBackground);
        }
        mLockedPaint.setColor(t.colorPrimary);
    }

    /**