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

Commit 85c2da6a authored by Scott Mertz's avatar Scott Mertz Committed by Steve Kondik
Browse files

Close zips when through with them

Change-Id: Ib13d6b84ae29210cfcbaaca41a6ec538202ff9f0
parent 784d816e
Loading
Loading
Loading
Loading
+20 −3
Original line number Diff line number Diff line
@@ -1057,9 +1057,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();
@@ -1073,6 +1073,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>();
@@ -1081,8 +1089,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();
@@ -1095,6 +1104,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;
    }