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

Commit 6bff8c79 authored by Rich Cannings's avatar Rich Cannings Committed by Android (Google) Code Review
Browse files

Merge "Remove the use of FileInputStream.available()" into gingerbread

parents ff4c57ad 8d578836
Loading
Loading
Loading
Loading
+7 −12
Original line number Diff line number Diff line
@@ -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();
        return InputStreamHelper.readFullyAndClose(fis);
    }

    public void deleteKey(String keyName) {
+5 −0
Original line number Diff line number Diff line
@@ -9408,7 +9408,12 @@ class PackageManagerService extends IPackageManager.Stub {
        } catch (NoSuchAlgorithmException nsae) {
            Slog.e(TAG, "Failed to create encryption keys with exception: " + nsae);
            return null;
        } catch (IOException ioe) {
            Slog.e(TAG, "Failed to retrieve encryption keys with exception: "
                      + ioe);
            return null;
        }

    }

    /* package */ static String getTempContainerId() {