Commits

Anonymous committed bb0e621

Fix Settings app crash after enabled multi-user

Bug: 8128225
Change-Id: I2918a5ec36e861a1ce4b2e67cf7607929732a7bf

Comments (0)

Files changed (1)

src/com/android/settings/Settings.java

                 }
             }
 
-            if (target.get(i) == header
+            if (i < target.size() && target.get(i) == header
                     && UserHandle.MU_ENABLED && UserHandle.myUserId() != 0
                     && !ArrayUtils.contains(SETTINGS_FOR_RESTRICTED, id)) {
                 target.remove(i);
             }
 
             // Increment if the current one wasn't removed by the Utils code.
-            if (target.get(i) == header) {
+            if (i < target.size() && target.get(i) == header) {
                 // Hold on to the first header, when we need to reset to the top-level
                 if (mFirstHeader == null &&
                         HeaderAdapter.getHeaderType(header) != HeaderAdapter.HEADER_TYPE_CATEGORY) {