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

Commit fcfaf5d6 authored by wilsonshih's avatar wilsonshih
Browse files

Invalidate task snapshot for protected apps.

Apps in background may have an unprotected recents screenshot available
for launchers that needs to be cleared out when app protection is
applied during screenshare.
Clear the task snapshot in core, also notify recents to invalidate the
original thumbnail in TaskThumbnailCache.

Bug: 329337332
Test: manual
Flag: ACONFIG android.permission.flags.sensitive_content_recents_screenshot_bugfix DEVELOPMENT
Change-Id: Iab342c504fe5e5b76191e9f0aee65c523e6630ca
parent b0133d13
Loading
Loading
Loading
Loading
+5 −0
Original line number Diff line number Diff line
@@ -144,6 +144,11 @@ oneway interface ITaskStackListener {
     */
    void onTaskSnapshotChanged(int taskId, in TaskSnapshot snapshot);

    /**
     * Called when a task snapshot become invalidated.
     */
    void onTaskSnapshotInvalidated(int taskId);

    /**
     * Reports that an Activity received a back key press when there were no additional activities
     * on the back stack.
+3 −0
Original line number Diff line number Diff line
@@ -177,6 +177,9 @@ public abstract class TaskStackListener extends ITaskStackListener.Stub {
        }
    }

    @Override
    public void onTaskSnapshotInvalidated(int taskId) { }

    @Override
    public void onBackPressedOnTaskRoot(RunningTaskInfo taskInfo)
            throws RemoteException {
+16 −0
Original line number Diff line number Diff line
@@ -141,6 +141,7 @@ public class TaskStackChangeListeners {
        private static final int ON_TASK_DESCRIPTION_CHANGED = 21;
        private static final int ON_ACTIVITY_ROTATION = 22;
        private static final int ON_LOCK_TASK_MODE_CHANGED = 23;
        private static final int ON_TASK_SNAPSHOT_INVALIDATED = 24;

        /**
         * List of {@link TaskStackChangeListener} registered from {@link #addListener}.
@@ -271,6 +272,12 @@ public class TaskStackChangeListeners {
            mHandler.obtainMessage(ON_TASK_SNAPSHOT_CHANGED, taskId, 0, snapshot).sendToTarget();
        }

        @Override
        public void onTaskSnapshotInvalidated(int taskId) {
            mHandler.obtainMessage(ON_TASK_SNAPSHOT_INVALIDATED, taskId, 0 /* unused */)
                    .sendToTarget();
        }

        @Override
        public void onTaskCreated(int taskId, ComponentName componentName) {
            mHandler.obtainMessage(ON_TASK_CREATED, taskId, 0, componentName).sendToTarget();
@@ -496,6 +503,15 @@ public class TaskStackChangeListeners {
                        }
                        break;
                    }
                    case ON_TASK_SNAPSHOT_INVALIDATED: {
                        Trace.beginSection("onTaskSnapshotInvalidated");
                        final ThumbnailData thumbnail = new ThumbnailData();
                        for (int i = mTaskStackListeners.size() - 1; i >= 0; i--) {
                            mTaskStackListeners.get(i).onTaskSnapshotChanged(msg.arg1, thumbnail);
                        }
                        Trace.endSection();
                        break;
                    }
                }
            }
            if (msg.obj instanceof SomeArgs) {
+5 −0
Original line number Diff line number Diff line
@@ -3206,6 +3206,11 @@ class Task extends TaskFragment {
                mTaskId, snapshot);
    }

    void onSnapshotInvalidated() {
        mAtmService.getTaskChangeNotificationController().notifyTaskSnapshotInvalidated(mTaskId);
    }


    TaskDescription getTaskDescription() {
        return mTaskDescription;
    }
+17 −0
Original line number Diff line number Diff line
@@ -61,6 +61,7 @@ class TaskChangeNotificationController {
    private static final int NOTIFY_ACTIVITY_ROTATED_MSG = 26;
    private static final int NOTIFY_TASK_MOVED_TO_BACK_LISTENERS_MSG = 27;
    private static final int NOTIFY_LOCK_TASK_MODE_CHANGED_MSG = 28;
    private static final int NOTIFY_TASK_SNAPSHOT_INVALIDATED_LISTENERS_MSG = 29;

    // Delay in notifying task stack change listeners (in millis)
    private static final int NOTIFY_TASK_STACK_CHANGE_LISTENERS_DELAY = 100;
@@ -150,6 +151,9 @@ class TaskChangeNotificationController {
    private final TaskStackConsumer mNotifyTaskSnapshotChanged = (l, m) -> {
        l.onTaskSnapshotChanged(m.arg1, (TaskSnapshot) m.obj);
    };
    private final TaskStackConsumer mNotifyTaskSnapshotInvalidated = (l, m) -> {
        l.onTaskSnapshotInvalidated(m.arg1);
    };

    private final TaskStackConsumer mNotifyTaskDisplayChanged = (l, m) -> {
        l.onTaskDisplayChanged(m.arg1, m.arg2);
@@ -271,6 +275,9 @@ class TaskChangeNotificationController {
                case NOTIFY_LOCK_TASK_MODE_CHANGED_MSG:
                    forAllRemoteListeners(mNotifyLockTaskModeChanged, msg);
                    break;
                case NOTIFY_TASK_SNAPSHOT_INVALIDATED_LISTENERS_MSG:
                    forAllRemoteListeners(mNotifyTaskSnapshotInvalidated, msg);
                    break;
            }
            if (msg.obj instanceof SomeArgs) {
                ((SomeArgs) msg.obj).recycle();
@@ -484,6 +491,16 @@ class TaskChangeNotificationController {
        msg.sendToTarget();
    }

    /**
     * Notify listeners that the snapshot of a task is invalidated.
     */
    void notifyTaskSnapshotInvalidated(int taskId) {
        final Message msg = mHandler.obtainMessage(NOTIFY_TASK_SNAPSHOT_INVALIDATED_LISTENERS_MSG,
                taskId, 0 /* unused */);
        forAllLocalListeners(mNotifyTaskSnapshotInvalidated, msg);
        msg.sendToTarget();
    }

    /**
     * Notify listeners that an activity received a back press when there are no other activities
     * in the back stack.
Loading