Fix NPE in app hibernation dump command.

Incorrectly used index instead of the user id to key into the
SparseArray, causing a null value to be returned instead of the actual
states map for the user. This fixes the issue.

Bug: 199935092
Test: Make a new user; adb shell dumpsys app_hibernation
Change-Id: I3f6fcfbaa7a5e83bcf2be46c9e05e5f2f76adf52
(cherry picked from commit 984ea4250d)
This commit is contained in:
Kevin Han
2021-09-14 16:07:43 -07:00
parent 1f01265024
commit b2eea3ed0f

View File

@@ -696,7 +696,7 @@ public final class AppHibernationService extends SystemService {
idpw.print("User Level Hibernation States, ");
idpw.printPair("user", userId);
idpw.println();
Map<String, UserLevelState> stateMap = mUserStates.get(i);
Map<String, UserLevelState> stateMap = mUserStates.get(userId);
idpw.increaseIndent();
for (UserLevelState state : stateMap.values()) {
idpw.print(state);