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

Commit bc962505 authored by Amith Yamasani's avatar Amith Yamasani
Browse files

Make sure that the owner user is marked initialized.

This is required for upgrades from previous versions of JB.

Bug: 7547639
Change-Id: I21de14a70d6ba2ab21437b5f0721321df45226d2
parent 674a131c
Loading
Loading
Loading
Loading
+12 −3
Original line number Diff line number Diff line
@@ -88,7 +88,7 @@ public class UserManagerService extends IUserManager.Stub {

    private static final int MIN_USER_ID = 10;

    private static final int USER_VERSION = 1;
    private static final int USER_VERSION = 2;

    private static final long EPOCH_PLUS_30_YEARS = 30L * 365 * 24 * 60 * 60 * 1000L; // ms

@@ -484,8 +484,7 @@ public class UserManagerService extends IUserManager.Stub {
    }

    /**
     * This fixes an incorrect initialization of user name for the owner.
     * TODO: Remove in the next release.
     * Upgrade steps between versions, either for fixing bugs or changing the data format.
     */
    private void upgradeIfNecessary() {
        int userVersion = mUserVersion;
@@ -499,6 +498,16 @@ public class UserManagerService extends IUserManager.Stub {
            userVersion = 1;
        }

        if (userVersion < 2) {
            // Owner should be marked as initialized
            UserInfo user = mUsers.get(UserHandle.USER_OWNER);
            if ((user.flags & UserInfo.FLAG_INITIALIZED) == 0) {
                user.flags |= UserInfo.FLAG_INITIALIZED;
                writeUserLocked(user);
            }
            userVersion = 2;
        }

        if (userVersion < USER_VERSION) {
            Slog.w(LOG_TAG, "User version " + mUserVersion + " didn't upgrade as expected to "
                    + USER_VERSION);