Loading services/java/com/android/server/pm/PackageManagerService.java +33 −33 Original line number Diff line number Diff line Loading @@ -141,6 +141,7 @@ import java.util.zip.ZipFile; import java.util.zip.ZipOutputStream; import libcore.io.ErrnoException; import libcore.io.IoUtils; import libcore.io.Libcore; /** Loading Loading @@ -6946,9 +6947,8 @@ public class PackageManagerService extends IPackageManager.Stub { } catch (IOException e) { Slog.e(TAG, "Couldn't create a new zip file for the public parts of a" + " forward-locked app."); destResourceFile.delete(); return PackageManager.INSTALL_FAILED_INSUFFICIENT_STORAGE; } finally { //TODO clean up the extracted public files } retCode = mInstaller.setForwardLockPerm(getApkName(newPackage.mPath), newPackage.applicationInfo.uid); Loading Loading @@ -6990,8 +6990,9 @@ public class PackageManagerService extends IPackageManager.Stub { File publicZipFile) throws IOException { final FileOutputStream fstr = new FileOutputStream(publicZipFile); final ZipOutputStream publicZipOutStream = new ZipOutputStream(fstr); try { final ZipFile privateZip = new ZipFile(newPackage.mPath); try { // Copy manifest, resources.arsc and res directory to public zip final Enumeration<? extends ZipEntry> privateZipEntries = privateZip.entries(); Loading @@ -7001,27 +7002,22 @@ public class PackageManagerService extends IPackageManager.Stub { if ("AndroidManifest.xml".equals(zipEntryName) || "resources.arsc".equals(zipEntryName) || zipEntryName.startsWith("res/")) { try { copyZipEntry(zipEntry, privateZip, publicZipOutStream); } catch (IOException e) { try { publicZipOutStream.close(); throw e; } finally { publicZipFile.delete(); } } } } finally { try { privateZip.close(); } catch (IOException e) { } } publicZipOutStream.finish(); publicZipOutStream.flush(); FileUtils.sync(fstr); publicZipOutStream.close(); FileUtils.setPermissions( publicZipFile.getAbsolutePath(), FileUtils.S_IRUSR|FileUtils.S_IWUSR|FileUtils.S_IRGRP|FileUtils.S_IROTH, -1, -1); FileUtils.setPermissions(publicZipFile.getAbsolutePath(), FileUtils.S_IRUSR | FileUtils.S_IWUSR | FileUtils.S_IRGRP | FileUtils.S_IROTH, -1, -1); } finally { IoUtils.closeQuietly(publicZipOutStream); } } private static void copyZipEntry(ZipEntry zipEntry, Loading @@ -7040,11 +7036,15 @@ public class PackageManagerService extends IPackageManager.Stub { } outZipStream.putNextEntry(newEntry); InputStream data = inZipFile.getInputStream(zipEntry); final InputStream data = inZipFile.getInputStream(zipEntry); try { while ((num = data.read(buffer)) > 0) { outZipStream.write(buffer, 0, num); } outZipStream.flush(); } finally { IoUtils.closeQuietly(data); } } private void deleteTempPackageFiles() { Loading Loading
services/java/com/android/server/pm/PackageManagerService.java +33 −33 Original line number Diff line number Diff line Loading @@ -141,6 +141,7 @@ import java.util.zip.ZipFile; import java.util.zip.ZipOutputStream; import libcore.io.ErrnoException; import libcore.io.IoUtils; import libcore.io.Libcore; /** Loading Loading @@ -6946,9 +6947,8 @@ public class PackageManagerService extends IPackageManager.Stub { } catch (IOException e) { Slog.e(TAG, "Couldn't create a new zip file for the public parts of a" + " forward-locked app."); destResourceFile.delete(); return PackageManager.INSTALL_FAILED_INSUFFICIENT_STORAGE; } finally { //TODO clean up the extracted public files } retCode = mInstaller.setForwardLockPerm(getApkName(newPackage.mPath), newPackage.applicationInfo.uid); Loading Loading @@ -6990,8 +6990,9 @@ public class PackageManagerService extends IPackageManager.Stub { File publicZipFile) throws IOException { final FileOutputStream fstr = new FileOutputStream(publicZipFile); final ZipOutputStream publicZipOutStream = new ZipOutputStream(fstr); try { final ZipFile privateZip = new ZipFile(newPackage.mPath); try { // Copy manifest, resources.arsc and res directory to public zip final Enumeration<? extends ZipEntry> privateZipEntries = privateZip.entries(); Loading @@ -7001,27 +7002,22 @@ public class PackageManagerService extends IPackageManager.Stub { if ("AndroidManifest.xml".equals(zipEntryName) || "resources.arsc".equals(zipEntryName) || zipEntryName.startsWith("res/")) { try { copyZipEntry(zipEntry, privateZip, publicZipOutStream); } catch (IOException e) { try { publicZipOutStream.close(); throw e; } finally { publicZipFile.delete(); } } } } finally { try { privateZip.close(); } catch (IOException e) { } } publicZipOutStream.finish(); publicZipOutStream.flush(); FileUtils.sync(fstr); publicZipOutStream.close(); FileUtils.setPermissions( publicZipFile.getAbsolutePath(), FileUtils.S_IRUSR|FileUtils.S_IWUSR|FileUtils.S_IRGRP|FileUtils.S_IROTH, -1, -1); FileUtils.setPermissions(publicZipFile.getAbsolutePath(), FileUtils.S_IRUSR | FileUtils.S_IWUSR | FileUtils.S_IRGRP | FileUtils.S_IROTH, -1, -1); } finally { IoUtils.closeQuietly(publicZipOutStream); } } private static void copyZipEntry(ZipEntry zipEntry, Loading @@ -7040,11 +7036,15 @@ public class PackageManagerService extends IPackageManager.Stub { } outZipStream.putNextEntry(newEntry); InputStream data = inZipFile.getInputStream(zipEntry); final InputStream data = inZipFile.getInputStream(zipEntry); try { while ((num = data.read(buffer)) > 0) { outZipStream.write(buffer, 0, num); } outZipStream.flush(); } finally { IoUtils.closeQuietly(data); } } private void deleteTempPackageFiles() { Loading