Bug 684443 - Make unpacking files from the APK faster [r=dougt]
authorMark Finkle <mfinkle@mozilla.com>
Mon, 05 Sep 2011 10:09:05 -0400
changeset 76557 c8139d06468245139aa4a55184c667d5169a8d23
parent 76556 e00b68fc6df9637e2de1c433788cf1422bdd0241
child 76558 d2c6783fa7153ef892236c16dd39c3da198b3064
child 76559 b38795f5d13ba43408eaaecdae7a80d8ddff6b24
push id3
push userfelipc@gmail.com
push dateFri, 30 Sep 2011 20:09:13 +0000
reviewersdougt
bugs684443
milestone9.0a1
Bug 684443 - Make unpacking files from the APK faster [r=dougt]
embedding/android/GeckoApp.java
--- a/embedding/android/GeckoApp.java
+++ b/embedding/android/GeckoApp.java
@@ -462,19 +462,25 @@ abstract public class GeckoApp
         File applicationPackage = new File(getApplication().getPackageResourcePath());
         File componentsDir = new File(sGREDir, "components");
         if (componentsDir.lastModified() == applicationPackage.lastModified())
             return;
 
         componentsDir.mkdir();
         componentsDir.setLastModified(applicationPackage.lastModified());
 
+        surfaceView.mSplashStatusMsg =
+                    getResources().getString(R.string.splash_firstrun);
+        surfaceView.drawSplashScreen();
+
+        GeckoAppShell.killAnyZombies();
+
         ZipFile zip = new ZipFile(applicationPackage);
 
-        byte[] buf = new byte[8192];
+        byte[] buf = new byte[32768];
         try {
             if (unpackFile(zip, buf, null, "removed-files"))
                 removeFiles();
         } catch (Exception ex) {
             // This file may not be there, so just log any errors and move on
             Log.w(LOG_FILE_NAME, "error removing files", ex);
         }
         unpackFile(zip, buf, null, "application.ini");
@@ -515,45 +521,33 @@ abstract public class GeckoApp
                     removedFile.delete();
             }
         } finally {
             reader.close();
         }
         
     }
 
-    boolean haveKilledZombies = false;
-
     private boolean unpackFile(ZipFile zip, byte[] buf, ZipEntry fileEntry,
                             String name)
         throws IOException, FileNotFoundException
     {
         if (fileEntry == null)
             fileEntry = zip.getEntry(name);
         if (fileEntry == null)
             throw new FileNotFoundException("Can't find " + name + " in " +
                                             zip.getName());
 
         File outFile = new File(sGREDir, name);
-        if (outFile.exists() &&
-            outFile.lastModified() == fileEntry.getTime() &&
+        if (outFile.lastModified() == fileEntry.getTime() &&
             outFile.length() == fileEntry.getSize())
             return false;
 
-        surfaceView.mSplashStatusMsg =
-                    getResources().getString(R.string.splash_firstrun);
-        surfaceView.drawSplashScreen();
-
-        if (!haveKilledZombies) {
-            haveKilledZombies = true;
-            GeckoAppShell.killAnyZombies();
-        }
-
         File dir = outFile.getParentFile();
-        if (!outFile.exists())
+        if (!dir.exists())
             dir.mkdirs();
 
         InputStream fileStream;
         fileStream = zip.getInputStream(fileEntry);
 
         OutputStream outStream = new FileOutputStream(outFile);
 
         while (fileStream.available() > 0) {