diff options
author | Scott Mertz <scott@cyngn.com> | 2015-02-19 16:49:37 -0800 |
---|---|---|
committer | Clark Scheff <clark@cyngn.com> | 2015-10-27 10:40:31 -0700 |
commit | d12db22f546d6d55f9c6d1ec729875282c6f4097 (patch) | |
tree | e9d6af631775952e83b7a632c022cfb03303492d /core/java/android/content/pm | |
parent | c3cee4ab7da24ce0a3066c43971fbb7403fff032 (diff) | |
download | frameworks_base-d12db22f546d6d55f9c6d1ec729875282c6f4097.zip frameworks_base-d12db22f546d6d55f9c6d1ec729875282c6f4097.tar.gz frameworks_base-d12db22f546d6d55f9c6d1ec729875282c6f4097.tar.bz2 |
Close zips when through with them
Change-Id: Ib13d6b84ae29210cfcbaaca41a6ec538202ff9f0
Diffstat (limited to 'core/java/android/content/pm')
-rw-r--r-- | core/java/android/content/pm/PackageParser.java | 23 |
1 files changed, 20 insertions, 3 deletions
diff --git a/core/java/android/content/pm/PackageParser.java b/core/java/android/content/pm/PackageParser.java index b5fcfe9..4f280ca 100644 --- a/core/java/android/content/pm/PackageParser.java +++ b/core/java/android/content/pm/PackageParser.java @@ -1065,9 +1065,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(); @@ -1081,6 +1081,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>(); @@ -1089,8 +1097,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(); @@ -1103,6 +1112,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; } |