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

Commit 5e00534c authored by Andres Morales's avatar Andres Morales Committed by Android Git Automerger
Browse files

am c8f952ce: Write correct checksum when formatting partition

* commit 'c8f952ce':
  Write correct checksum when formatting partition
parents 14f58eac c8f952ce
Loading
Loading
Loading
Loading
+4 −5
Original line number Original line Diff line number Diff line
@@ -110,8 +110,7 @@ public class PersistentDataBlockService extends SystemService {
    private void formatIfOemUnlockEnabled() {
    private void formatIfOemUnlockEnabled() {
        if (doGetOemUnlockEnabled()) {
        if (doGetOemUnlockEnabled()) {
            synchronized (mLock) {
            synchronized (mLock) {
                formatPartitionLocked();
                formatPartitionLocked(true);
                doSetOemUnlockEnabledLocked(true);
            }
            }
        }
        }
    }
    }
@@ -165,7 +164,7 @@ public class PersistentDataBlockService extends SystemService {
            byte[] digest = computeDigestLocked(storedDigest);
            byte[] digest = computeDigestLocked(storedDigest);
            if (digest == null || !Arrays.equals(storedDigest, digest)) {
            if (digest == null || !Arrays.equals(storedDigest, digest)) {
                Slog.i(TAG, "Formatting FRP partition...");
                Slog.i(TAG, "Formatting FRP partition...");
                formatPartitionLocked();
                formatPartitionLocked(false);
                return false;
                return false;
            }
            }
        }
        }
@@ -242,7 +241,7 @@ public class PersistentDataBlockService extends SystemService {
        return md.digest();
        return md.digest();
    }
    }


    private void formatPartitionLocked() {
    private void formatPartitionLocked(boolean setOemUnlockEnabled) {
        DataOutputStream outputStream;
        DataOutputStream outputStream;
        try {
        try {
            outputStream = new DataOutputStream(new FileOutputStream(new File(mDataBlockFile)));
            outputStream = new DataOutputStream(new FileOutputStream(new File(mDataBlockFile)));
@@ -264,7 +263,7 @@ public class PersistentDataBlockService extends SystemService {
            IoUtils.closeQuietly(outputStream);
            IoUtils.closeQuietly(outputStream);
        }
        }


        doSetOemUnlockEnabledLocked(false);
        doSetOemUnlockEnabledLocked(setOemUnlockEnabled);
        computeAndWriteDigestLocked();
        computeAndWriteDigestLocked();
    }
    }