Bug 609366 - Switching from 3G to Wifi stops the nightly update download and then restarting Fennec shows you the package installer for the partial package. r=blassey a=blocking-fennec
authorAlex Pakhotin <alexp@mozilla.com>
Thu, 18 Nov 2010 14:13:31 -0800
changeset 58005 f021e21f74aee962917addb8194028a6ba8b9f06
parent 58004 372e38d12c5ef4c2af0f300b35d80f3dccf7b21d
child 58006 74b4a2f97e232121f2710a3a101fe9488df68f15
push id17127
push userblassey@mozilla.com
push dateMon, 22 Nov 2010 21:33:43 +0000
treeherdermozilla-central@f021e21f74ae [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersblassey, blocking-fennec
bugs609366
milestone2.0b8pre
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 609366 - Switching from 3G to Wifi stops the nightly update download and then restarting Fennec shows you the package installer for the partial package. r=blassey a=blocking-fennec
embedding/android/GeckoApp.java
--- a/embedding/android/GeckoApp.java
+++ b/embedding/android/GeckoApp.java
@@ -494,16 +494,20 @@ abstract public class GeckoApp
 
     private void checkAndLaunchUpdate() {
         Log.i("GeckoAppJava", "Checking for an update");
 
         int statusCode = 8; // UNEXPECTED_ERROR
 
         String updateDir = Environment.getExternalStorageDirectory().getPath() + "/downloads/updates/0/";
         File updateFile = new File(updateDir + "update.apk");
+        File statusFile = new File(updateDir + "update.status");
+
+        if (!statusFile.exists() || !readUpdateStatus(statusFile).equals("pending"))
+            return;
 
         if (!updateFile.exists())
             return;
 
         Log.i("GeckoAppJava", "Update is available!");
 
         // Launch APK
         File updateFileToRun = new File(updateDir + getAppName() + "-update.apk");
@@ -521,31 +525,42 @@ abstract public class GeckoApp
             }
         } catch (Exception e) {
             Log.i("GeckoAppJava", e.toString());
         }
 
         // Update the status file
         String status = statusCode == 0 ? "succeeded\n" : "failed: "+ statusCode + "\n";
 
-        File statusFile = new File(updateDir + "update.status");
         OutputStream outStream;
         try {
             byte[] buf = status.getBytes("UTF-8");
             outStream = new FileOutputStream(statusFile);
             outStream.write(buf, 0, buf.length);
             outStream.close();
         } catch (Exception e) {
             Log.i("GeckoAppJava", e.toString());
         }
 
         if (statusCode == 0)
             System.exit(0);
     }
 
+    private String readUpdateStatus(File statusFile) {
+        String status = "";
+        try {
+            BufferedReader reader = new BufferedReader(new FileReader(statusFile));
+            status = reader.readLine();
+            reader.close();
+        } catch (Exception e) {
+            Log.i("GeckoAppJava", e.toString());
+        }
+        return status;
+    }
+
     static final int FILE_PICKER_REQUEST = 1;
 
     private SynchronousQueue<String> mFilePickerResult = new SynchronousQueue();
     public String showFilePicker(String aMimeType) {
         Intent intent = new Intent(Intent.ACTION_GET_CONTENT);
         intent.addCategory(Intent.CATEGORY_OPENABLE);
         intent.setType(aMimeType);
         GeckoApp.this.