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

Commit 71b89708 authored by Fyodor Kupolov's avatar Fyodor Kupolov Committed by android-build-merger
Browse files

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

am: 125db3f9

* commit '125db3f9':
  Prevent NPE when syncing recent tasks
parents ef18bbac 125db3f9
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);
            }
        }