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

Commit c4b46dd1 authored by Fyodor Kupolov's avatar Fyodor Kupolov
Browse files

Prevent NPE when syncing recent tasks

Temporary fix to unblock GTS tests for ryu.

Bug: 27686987
Change-Id: Id9398cd8615bf90aecf02051f26db10f39d598b0
parent 943c68ae
Loading
Loading
Loading
Loading
+7 −0
Original line number Diff line number Diff line
@@ -116,6 +116,7 @@ class RecentTasks extends ArrayList<TaskRecord> {
        // on file when we loaded them.
        if (mPersistedTaskIds.get(userId) == null) {
            mPersistedTaskIds.put(userId, mTaskPersister.loadPersistedTaskIdsForUser(userId));
            Slog.i(TAG, "Loaded persisted task ids for user " + userId);
        }
    }

@@ -146,6 +147,12 @@ class RecentTasks extends ArrayList<TaskRecord> {
            TaskRecord task = get(i);
            if (task.isPersistable && (task.stack == null || !task.stack.isHomeStack())) {
                // Set of persisted taskIds for task.userId should not be null here
                // TODO Investigate why it can happen. For now initialize with an empty set
                if (mPersistedTaskIds.get(task.userId) == null) {
                    Slog.wtf(TAG, "No task ids found for userId " + task.userId + ". task=" + task
                            + " mPersistedTaskIds=" + mPersistedTaskIds);
                    mPersistedTaskIds.put(task.userId, new SparseBooleanArray());
                }
                mPersistedTaskIds.get(task.userId).put(task.taskId, true);
            }
        }