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

Commit 4618898c authored by Scott Mertz's avatar Scott Mertz Committed by Gerrit Code Review
Browse files

Close zips when through with them

Change-Id: Ib13d6b84ae29210cfcbaaca41a6ec538202ff9f0
parent ea232370
Loading
Loading
Loading
Loading
+20 −3
Original line number Diff line number Diff line
@@ -1041,9 +1041,9 @@ public class PackageParser {

    private ArrayList<String> scanPackageOverlays(File originalFile) {
        Set<String> overlayTargets = new HashSet<String>();

        ZipFile privateZip = null;
        try {
            final ZipFile privateZip = new ZipFile(originalFile.getPath());
            privateZip = new ZipFile(originalFile.getPath());
            final Enumeration<? extends ZipEntry> privateZipEntries = privateZip.entries();
            while (privateZipEntries.hasMoreElements()) {
                final ZipEntry zipEntry = privateZipEntries.nextElement();
@@ -1057,6 +1057,14 @@ public class PackageParser {
        } catch(Exception e) {
            e.printStackTrace();
            overlayTargets.clear();
        } finally {
            if (privateZip != null) {
                try {
                    privateZip.close();
                } catch (Exception e) {
                    //Ignore
                }
            }
        }

        ArrayList<String> overlays = new ArrayList<String>();
@@ -1065,8 +1073,9 @@ public class PackageParser {
    }

    private boolean packageHasIconPack(File originalFile) {
        ZipFile privateZip = null;
        try {
            final ZipFile privateZip = new ZipFile(originalFile.getPath());
            privateZip = new ZipFile(originalFile.getPath());
            final Enumeration<? extends ZipEntry> privateZipEntries = privateZip.entries();
            while (privateZipEntries.hasMoreElements()) {
                final ZipEntry zipEntry = privateZipEntries.nextElement();
@@ -1079,6 +1088,14 @@ public class PackageParser {
            }
        } catch(Exception e) {
            Log.e(TAG, "Could not read zip entries while checking if apk has icon pack", e);
        } finally {
            if (privateZip != null) {
                try {
                    privateZip.close();
                } catch (Exception e) {
                    //Ignore
                }
            }
        }
        return false;
    }