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

Commit 0d407f4f authored by Garfield Tan's avatar Garfield Tan
Browse files

Don't touch system_ce until the first user unlock.

This CL does the following things:
1) Only start PersistQueue when the first user unlocked.
2) Only create recent task folder when we need to write the first file
to it.

Bug: 124697664
Test: Manual test -- checked recent_tasks, recent_images and
launch_params folders are still created correctly. No encryption policy
log seen.
Change-Id: I5b8bf712a3c45092b463622731d58f90d76fec58
parent 76e49c8b
Loading
Loading
Loading
Loading
+8 −1
Original line number Diff line number Diff line
@@ -450,10 +450,17 @@ public class ActivityStackSupervisor implements RecentTasks.Callbacks {
    }

    void onSystemReady() {
        mPersisterQueue.startPersisting();
        mLaunchParamsPersister.onSystemReady();
    }

    void onUserUnlocked(int userId) {
        // Only start persisting when the first user is unlocked. The method call is
        // idempotent so there is no side effect to call it again when the second user is
        // unlocked.
        mPersisterQueue.startPersisting();
        mLaunchParamsPersister.onUnlockUser(userId);
    }

    public ActivityMetricsLogger getActivityMetricsLogger() {
        return mActivityMetricsLogger;
    }
+1 −1
Original line number Diff line number Diff line
@@ -948,7 +948,7 @@ public class ActivityTaskManagerService extends IActivityTaskManager.Stub {
        @Override
        public void onUnlockUser(int userId) {
            synchronized (mService.getGlobalLock()) {
                mService.mStackSupervisor.mLaunchParamsPersister.onUnlockUser(userId);
                mService.mStackSupervisor.onUserUnlocked(userId);
            }
        }

+2 −8
Original line number Diff line number Diff line
@@ -131,10 +131,8 @@ class PersisterQueue {
    }

    /**
     *
     * @param item
     * @param flush
     * @param <T>
     * Updates the last item found in the queue that matches the given item, or adds it to the end
     * of the queue if no such item is found.
     */
    synchronized <T extends WriteQueueItem> void updateLastOrAddItem(T item, boolean flush) {
        final T itemToUpdate = findLastItem(item::matches, (Class<T>) item.getClass());
@@ -149,10 +147,6 @@ class PersisterQueue {

    /**
     * Removes all items with which given predicate returns {@code true}.
     *
     * @param predicate the predicate
     * @param clazz
     * @param <T>
     */
    synchronized <T extends WriteQueueItem> void removeItems(Predicate<T> predicate,
            Class<T> clazz) {
+9 −12
Original line number Diff line number Diff line
@@ -492,16 +492,8 @@ public class TaskPersister implements PersisterQueue.Listener {
        return new File(userTaskIdsDir, PERSISTED_TASK_IDS_FILENAME);
    }

    static File getUserTasksDir(int userId) {
        File userTasksDir = new File(Environment.getDataSystemCeDirectory(userId), TASKS_DIRNAME);

        if (!userTasksDir.exists()) {
            if (!userTasksDir.mkdir()) {
                Slog.e(TAG, "Failure creating tasks directory for user " + userId + ": "
                        + userTasksDir);
            }
        }
        return userTasksDir;
    private static File getUserTasksDir(int userId) {
        return new File(Environment.getDataSystemCeDirectory(userId), TASKS_DIRNAME);
    }

    static File getUserImagesDir(int userId) {
@@ -568,8 +560,13 @@ public class TaskPersister implements PersisterQueue.Listener {
                FileOutputStream file = null;
                AtomicFile atomicFile = null;
                try {
                    atomicFile = new AtomicFile(new File(
                            getUserTasksDir(task.userId),
                    File userTasksDir = getUserTasksDir(task.userId);
                    if (!userTasksDir.isDirectory() && !userTasksDir.mkdirs()) {
                        Slog.e(TAG, "Failure creating tasks directory for user " + task.userId
                                + ": " + userTasksDir + " Dropping persistence for task " + task);
                        return;
                    }
                    atomicFile = new AtomicFile(new File(userTasksDir,
                            String.valueOf(task.taskId) + TASK_FILENAME_SUFFIX));
                    file = atomicFile.startWrite();
                    file.write(stringWriter.toString().getBytes());