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

Commit 2d5a2ae8 authored by Danny Baumann's avatar Danny Baumann Committed by Gerrit Code Review
Browse files

Merge "Fix resource leaks" into cm-11.0

parents 8e3290e6 f62c6e38
Loading
Loading
Loading
Loading
+24 −17
Original line number Diff line number Diff line
@@ -53,7 +53,6 @@ import java.security.spec.EncodedKeySpec;
import java.security.spec.InvalidKeySpecException;
import java.security.spec.X509EncodedKeySpec;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Enumeration;
import java.util.HashMap;
import java.util.HashSet;
@@ -659,6 +658,7 @@ public class PackageParser {

        try {
            final ZipFile privateZip = new ZipFile(originalFile.getPath());
            try {
                final Enumeration<? extends ZipEntry> privateZipEntries = privateZip.entries();
                while (privateZipEntries.hasMoreElements()) {
                    final ZipEntry zipEntry = privateZipEntries.nextElement();
@@ -669,6 +669,9 @@ public class PackageParser {
                        overlayTargets.add(subdirs[2]);
                    }
                }
            } finally {
                privateZip.close();
            }
        } catch(Exception e) {
            e.printStackTrace();
            overlayTargets.clear();
@@ -682,15 +685,20 @@ public class PackageParser {
    private boolean packageHasIconPack(File originalFile) {
        try {
            final ZipFile privateZip = new ZipFile(originalFile.getPath());
            try {
                final Enumeration<? extends ZipEntry> privateZipEntries = privateZip.entries();
                while (privateZipEntries.hasMoreElements()) {
                    final ZipEntry zipEntry = privateZipEntries.nextElement();
                    final String zipEntryName = zipEntry.getName();

                if (zipEntryName.startsWith(ICON_PATH) && zipEntryName.length() > ICON_PATH.length()) {
                    if (zipEntryName.startsWith(ICON_PATH)
                            && zipEntryName.length() > ICON_PATH.length()) {
                        return true;
                    }
                }
            } finally {
                privateZip.close();
            }
        } catch(Exception e) {
            Log.e(TAG, "Could not read zip entries while checking if apk has icon pack", e);
        }
@@ -798,7 +806,6 @@ public class PackageParser {
     * @return True if the asset was successfully processed
     */
    private Map<String, String> getResourceRedirections(String name, String pkg, Resources themeResources, String themePkgName) {
        AssetManager am = themeResources.getAssets();
        if (!name.startsWith("res/"))
            name = "res/" + name;
        if (!name.endsWith(".xml"))