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

Commit bede7f6a authored by Felipe Leme's avatar Felipe Leme
Browse files

Fixed readUserListLP() so it recovers when user 0 data is corrupted.

Test: echo DOH > 0.xml && adb push 0.xml /data/system/users/ && \
      adb shell stop && adb shell start
Bug: 159350797

Change-Id: I3865cd98c19ae2670511d96ad020a833f74e6512
parent 6f417b3e
Loading
Loading
Loading
Loading
+8 −5
Original line number Diff line number Diff line
@@ -2528,7 +2528,12 @@ public class UserManagerService extends IUserManager.Stub {
                    if (name.equals(TAG_USER)) {
                        String id = parser.getAttributeValue(null, ATTR_ID);

                        UserData userData = readUserLP(Integer.parseInt(id));
                        int userId = Integer.parseInt(id);
                        UserData userData = readUserLP(userId);
                        if (userData == null && userId == UserHandle.USER_SYSTEM) {
                            fallbackToSingleUserLP();
                            return;
                        }

                        if (userData != null) {
                            synchronized (mUsersLock) {
@@ -2994,10 +2999,8 @@ public class UserManagerService extends IUserManager.Stub {
                    new AtomicFile(new File(mUsersDir, Integer.toString(id) + XML_SUFFIX));
            fis = userFile.openRead();
            return readUserLP(id, fis);
        } catch (IOException ioe) {
            Slog.e(LOG_TAG, "Error reading user list");
        } catch (XmlPullParserException pe) {
            Slog.e(LOG_TAG, "Error reading user list");
        } catch (IOException | XmlPullParserException e) {
            Slog.e(LOG_TAG, "Error reading user " + id + ": " + e);
        } finally {
            IoUtils.closeQuietly(fis);
        }