summaryrefslogtreecommitdiffstats
path: root/core/java/android/os/RecoverySystem.java
diff options
context:
space:
mode:
authorDoug Zongker <dougz@android.com>2010-03-11 10:27:21 -0800
committerDoug Zongker <dougz@android.com>2010-03-11 11:07:24 -0800
commitcb95657326add53f81cd2f8a0ae0a1a0527ae799 (patch)
tree1b9fa58dc471ecfdfad3c5b1181d6a8f3f05222a /core/java/android/os/RecoverySystem.java
parent3802141d17631183b6638d8e66630750f75daf38 (diff)
downloadframeworks_base-cb95657326add53f81cd2f8a0ae0a1a0527ae799.zip
frameworks_base-cb95657326add53f81cd2f8a0ae0a1a0527ae799.tar.gz
frameworks_base-cb95657326add53f81cd2f8a0ae0a1a0527ae799.tar.bz2
make RecoverySystem.verifyPackage interruptible
Change-Id: I09f6746914ef63c81312efd3a8959b0c28f6003a
Diffstat (limited to 'core/java/android/os/RecoverySystem.java')
-rw-r--r--core/java/android/os/RecoverySystem.java12
1 files changed, 11 insertions, 1 deletions
diff --git a/core/java/android/os/RecoverySystem.java b/core/java/android/os/RecoverySystem.java
index 3dd3918..b827af8 100644
--- a/core/java/android/os/RecoverySystem.java
+++ b/core/java/android/os/RecoverySystem.java
@@ -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");
}