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

Commit 125db3f9 authored by Fyodor Kupolov's avatar Fyodor Kupolov Committed by Android (Google) Code Review
Browse files

Merge "Prevent NPE when syncing recent tasks" into nyc-dev

parents 92cfb7fc c4b46dd1
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);
            }
        }