Closed Bug 609366 Opened 9 years ago Closed 9 years ago

Switching from 3G to Wifi stops the nightly update download and then restarting Fennec shows you the package installer for the partial package

Categories

(Firefox for Android Graveyard :: General, defect)

All
Android
defect
Not set

Tracking

(fennec2.0+)

VERIFIED FIXED
Firefox 4.0
Tracking Status
fennec 2.0+ ---

People

(Reporter: mossop, Assigned: alexp)

References

Details

Attachments

(2 files, 3 obsolete files)

I started downloading today's nightly and then my phone spotted the wifi and switched to it. The nightly update stuck, no further progress increases. After that I restarted Fennec and it opened the package installer which told me the package was broken.

Switching to a different network shouldn't break the download.

Fennec shouldn't attempt to launch the package installer until it has the full package.
blocking2.0: --- → ?
blocking2.0: ? → ---
tracking-fennec: --- → ?
OS: Mac OS X → Android
Hardware: x86 → All
Assignee: nobody → alexp
tracking-fennec: ? → 2.0b3+
tracking-fennec: 2.0b3+ → 2.0+
Attached patch Fix (obsolete) — Splinter Review
Check the update status and launch the APK only when the update is pending.
Attachment #491667 - Flags: review?(blassey.bugs)
Attached patch Fix (mobile) (obsolete) — Splinter Review
When update download stops for any reason, hide the notification with a stuck progressbar.
Attachment #491668 - Flags: review?(mark.finkle)
Comment on attachment 491668 [details] [diff] [review]
Fix (mobile)


>   // When the data transfer ends
>   onStopRequest: function(request, context, status) {
>+    let alertsService = Cc["@mozilla.org/alerts-service;1"].getService(Ci.nsIAlertsService);
>+    let progressListener = alertsService.QueryInterface(Ci.nsIAlertsProgressListener);
>+    progressListener.onCancel(UPDATE_NOTIFICATION_NAME);
>+

Since this code is not wrapped in #ifdef ANDROID, let protect it better with a check:

    let alertsService = Cc["@mozilla.org/alerts-service;1"].getService(Ci.nsIAlertsService);
    let progressListener = alertsService.QueryInterface(Ci.nsIAlertsProgressListener);
    if (progressListener)
      progressListener.onCancel(UPDATE_NOTIFICATION_NAME);

also, do the same here:
http://mxr.mozilla.org/mobile-browser/source/components/UpdatePrompt.js#140

Someday more than Android will support progress alerts, so this is a good step
Attachment #491668 - Flags: review?(mark.finkle) → review+
Comment on attachment 491667 [details] [diff] [review]
Fix

># HG changeset patch
># User Alex Pakhotin <alexp@mozilla.com>
># Date 1290118411 28800
># Node ID fc3fdcd5ba86e16a195f9c9d585354d4d363d7f6
># Parent  b0bd253cb40b5cbcf5a1481a1688d0986d17114c
>Switching from 3G to Wifi stops the nightly update download and then restarting Fennec shows you the package installer for the partial package
>
>diff --git a/embedding/android/GeckoApp.java b/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.
Attachment #491667 - Flags: review?(blassey.bugs) → review+
Attached patch Fix (mobile) (obsolete) — Splinter Review
Added the suggested check.
r=mfinkle
Attachment #491668 - Attachment is obsolete: true
Attachment #491672 - Flags: review+
Keywords: checkin-needed
r=blassey a=blocking-fennec
Attachment #491667 - Attachment is obsolete: true
Attachment #492422 - Flags: review+
r=mfinkle a=blocking-fennec
Attachment #491672 - Attachment is obsolete: true
Attachment #492423 - Flags: review+
Blocks: 618316
I was trying to verify this fix today, and noticed the fennec notification icon dissapears once i switch networks.

tested both 3G->Wifi & wifi->3G.   here's my steps:
1) install Fennec android 3/14 build.  Mozilla/5.0 (Android; Linux armv71; rv:2.0b13pre) Gecko/20110314 Firefox/4.0b13pre Fennec/4.0b6pre	
2) stay in wifi mode
3) launch fennec, search for updates.  3/15 update found, begin downloading
4) double check the fennec notification shows normal apk download progress bar
5) quickly, switch to 3G settings
6) Verify once 3G is switched on, the fennec download notification disappears.
7) perform steps 1-6, this time 3G->wifi.  Verify same.

Dave, can you see if this is fixed for you?  if so, please revert status.
Status: RESOLVED → REOPENED
Resolution: FIXED → ---
(In reply to comment #9)
> I was trying to verify this fix today, and noticed the fennec notification icon
> dissapears once i switch networks.

That's exactly what the fix did. The bug was about the notification icon got stuck with a frozen progress bar, and incomplete update being launched. Does it happen now?

The update is not supposed to continue right away after switching connection - it will restart later.
given this patch was over 4 months old, i've filed Bug 642042 to track the possible regression.  

reverting status
Status: REOPENED → RESOLVED
Closed: 9 years ago9 years ago
Resolution: --- → FIXED
I think you can verify this bug based on the description in bug 618316
(In reply to comment #12)
> I think you can verify this bug based on the description in bug 618316

ok, if comment 8 contains the fix for the case in bug 618316, its isn't working correctly. the actual behavior is what i'm seeing on the 3/14 build.
(In reply to comment #13)
> (In reply to comment #12)
> > I think you can verify this bug based on the description in bug 618316
> 
> ok, if comment 8 contains the fix for the case in bug 618316, its isn't working
> correctly. the actual behavior is what i'm seeing on the 3/14 build.

huh? Do you get the android package manager with a partial package? If not, this is fixed and should be verified. 
The description in bug 618316 tells me that you were not seeing the package manager with a partial package in December, so if you're seeing it now we've regressed.
Verified:

Mozilla/5.0 (Android; Linux armv71; rv:2.0b13pre) Gecko/20110316
Firefox/4.0b13pre Fennec/4.0b6pre
Status: RESOLVED → VERIFIED
Target Milestone: --- → Firefox 4.0
You need to log in before you can comment on or make changes to this bug.