diff options
author | Rich Cannings <richc@google.com> | 2010-09-09 15:12:40 -0700 |
---|---|---|
committer | Rich Cannings <richc@google.com> | 2010-09-09 16:28:48 -0700 |
commit | 8d578836dc4f9fb41532b8b3dd7a6b168d6f4f9d (patch) | |
tree | 0b1d4c4c5f51e723f9139244d9ac05d0a77fa847 /keystore | |
parent | 76e4fa19264793e3ed7e2ee7afccfc808a1a7458 (diff) | |
download | frameworks_base-8d578836dc4f9fb41532b8b3dd7a6b168d6f4f9d.zip frameworks_base-8d578836dc4f9fb41532b8b3dd7a6b168d6f4f9d.tar.gz frameworks_base-8d578836dc4f9fb41532b8b3dd7a6b168d6f4f9d.tar.bz2 |
Remove the use of FileInputStream.available()
Bug: 2976294
Change-Id: I34b13cedbf1d2338163ef74454817c318a3a24f5
Diffstat (limited to 'keystore')
-rw-r--r-- | keystore/java/android/security/SystemKeyStore.java | 19 |
1 files changed, 7 insertions, 12 deletions
diff --git a/keystore/java/android/security/SystemKeyStore.java b/keystore/java/android/security/SystemKeyStore.java index abdb0ae..1093219 100644 --- a/keystore/java/android/security/SystemKeyStore.java +++ b/keystore/java/android/security/SystemKeyStore.java @@ -20,6 +20,8 @@ import android.os.Environment; import android.os.FileUtils; import android.os.Process; +import org.apache.harmony.luni.util.InputStreamHelper; + import java.io.File; import java.io.FileInputStream; import java.io.FileOutputStream; @@ -108,26 +110,19 @@ public class SystemKeyStore { return keyFile; } - public String retrieveKeyHexString(String keyName) { + public String retrieveKeyHexString(String keyName) throws IOException { return toHexString(retrieveKey(keyName)); } - public byte[] retrieveKey(String keyName) { - + public byte[] retrieveKey(String keyName) throws IOException { File keyFile = getKeyFile(keyName); + if (!keyFile.exists()) { return null; } - try { - FileInputStream fis = new FileInputStream(keyFile); - int keyLen = fis.available(); - byte[] retKey = new byte[keyLen]; - fis.read(retKey); - fis.close(); - return retKey; - } catch (IOException ioe) { } - throw new IllegalArgumentException(); + FileInputStream fis = new FileInputStream(keyFile); + return InputStreamHelper.readFullyAndClose(fis); } public void deleteKey(String keyName) { |