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

Commit b5957a3a authored by Doug Zongker's avatar Doug Zongker Committed by Android (Google) Code Review
Browse files

Merge "make RecoverySystem.verifyPackage interruptible"

parents b51132cb cb956573
Loading
Loading
Loading
Loading
+11 −1
Original line number Diff line number Diff line
@@ -117,7 +117,10 @@ public class RecoverySystem {
     * exception.
     *
     * Verification of a package can take significant time, so this
     * function should not be called from a UI thread.
     * function should not be called from a UI thread.  Interrupting
     * the thread while this function is in progress will result in a
     * SecurityException being thrown (and the thread's interrupt flag
     * will be cleared).
     *
     * @param packageFile  the package to be verified
     * @param listener     an object to receive periodic progress
@@ -259,7 +262,10 @@ public class RecoverySystem {
            long soFar = 0;
            raf.seek(0);
            byte[] buffer = new byte[4096];
            boolean interrupted = false;
            while (soFar < toRead) {
                interrupted = Thread.interrupted();
                if (interrupted) break;
                int size = buffer.length;
                if (soFar + size > toRead) {
                    size = (int)(toRead - soFar);
@@ -283,6 +289,10 @@ public class RecoverySystem {
                listener.onProgress(100);
            }

            if (interrupted) {
                throw new SignatureException("verification was interrupted");
            }

            if (!sig.verify(sigInfo.getEncryptedDigest())) {
                throw new SignatureException("signature digest verification failed");
            }