Closed Bug 1070099 Opened 10 years ago Closed 10 years ago

apk file downloaded in Firefox cannot be opened from Android download manager

Categories

(Firefox for Android Graveyard :: Download Manager, defect)

ARM
Android
defect
Not set
normal

Tracking

(firefox35 affected, fennec35+)

VERIFIED FIXED
Firefox 35
Tracking Status
firefox35 --- affected
fennec 35+ ---

People

(Reporter: c.ascheberg, Assigned: wesj)

References

()

Details

Attachments

(2 files)

STR:
- download apk file in Firefox (see provided URL)
- try to open file from Android downloads app

Result:
- app cannot be installed, I see some NFC dialog instead

Note:
- opening the file from Firefox download manager is working
- downloading the same file in Google Chrome also works
I get a file that was saved with content set as application/octet-stream

On attempt to access

W/DownloadManager( 4100): Failed to start Intent { act=android.intent.action.VIEW dat=content: typ=application/octet-stream flg=0x3 }: android.content.ActivityNotFoundException: No Activity found to handle Intent { act=android.intent.action.VIEW dat=content: typ=application/octet-stream flg=0x3 }

I don't see this problem downloading the Nightly APK on http://nightly.mozilla.org for example
tracking-fennec: --- → ?
Assignee: nobody → wjohnston
tracking-fennec: ? → 35+
Argh. Github tells us the mimetype is application/octet-stream. Since that basically means "We don't know", maybe we should try to make a guess when we receive it.
Attached patch PatchSplinter Review
This goes a bit further than bug 1070797. It gives us a list of default/unknown mimetypes. If the requested one matches any of them, its erased and we attempt to deduce the mimetype from the file extension. If that fails, we falls back to using the passed in one or one the first from our unknown list (i.e. "unknown/unknown").
Attachment #8497104 - Flags: review?(margaret.leibovic)
Comment on attachment 8497104 [details] [diff] [review]
Patch

Review of attachment 8497104 [details] [diff] [review]:
-----------------------------------------------------------------

This seems to contain some bits of your patch for bug 1070797. I think it would be fine to just land a folded version in this bug, if you want to dupe that other one here.

::: mobile/android/base/GeckoAppShell.java
@@ -137,5 @@
>      private static GeckoEditableListener editableListener;
>  
>      private static final Queue<GeckoEvent> PENDING_EVENTS = new ConcurrentLinkedQueue<GeckoEvent>();
>      private static final Map<String, String> ALERT_COOKIES = new ConcurrentHashMap<String, String>();
> -    private static final String DEFAULT_MIME_TYPE = "unknown/unknown";

This has changed since your patch for bug 1070797, although you did comment in there that this is a popular default unknown value.

@@ +1825,5 @@
> +        // addCompletedDownload will throw if it received any null parameters. Use aMimeType or a default
> +        // if we still don't have one.
> +        if (TextUtils.isEmpty(mimeType)) {
> +            if (TextUtils.isEmpty(aMimeType)) {
> +                mimeType = UNKNOWN_MIME_TYPES.get(0);

I think you should comment in this list declaration that the first one is used as the default, so that nobody accidentally changes the order around.
Attachment #8497104 - Flags: review?(margaret.leibovic) → review+
https://hg.mozilla.org/mozilla-central/rev/77035cfe3926
Status: NEW → RESOLVED
Closed: 10 years ago
Resolution: --- → FIXED
Target Milestone: --- → Firefox 35
For me, the patch does not fix the problem described in comment 0.
Flags: needinfo?(aaron.train)
(In reply to Christian Ascheberg from comment #7)
> For me, the patch does not fix the problem described in comment 0.

Re-testing this it works for me on Nightly build (10/01). The build was just generated so it, so it is possible you need to update.
Status: RESOLVED → VERIFIED
Flags: needinfo?(aaron.train)
No, I waited for the update, about:buildconfig says rev 14665b1de5ee.
In the Android download app, the icon next to the download is still a blank piece of paper.
I also noticed that when I download the Nightly APK from http://nightly.mozilla.org, I get a dialog "Complete action using". This does not happen on GitHub.
Any suggestion on how I can debug this further?
> I also noticed that when I download the Nightly APK from http://nightly.mozilla.org, I get a dialog "Complete action using". This does not happen on GitHub.

Please file a new bug for this, CC :wesj - downloads in general right now is very problematic.
Actually I see this now. There's a different behaviour between the browser and the system file manager. 

I'm able to open the file from within the browser but not able to open the file from within the Android system download application (My Files) on my Galaxy S5.
Status: VERIFIED → REOPENED
Resolution: FIXED → ---
The system file manager on my Galaxy S5 still considers the downloaded file as octet-stream

D/Instrumentation( 4041): checkStartActivityResult  :Intent { act=android.intent.action.VIEW dat=file:///storage/emulated/0/Download/MozStumbler-v0.30.0.apk typ=application/octet-stream flg=0x1 }
D/Instrumentation( 4041): checkStartActivityResult  inent is instance of inent:
I/ServiceKeeper(  756): In getappinfo pid = 756 pkgName = android appinfo = null
I/ServiceKeeper(  756): In getseinfo pid = 756 uid = 1000 seinfo= system
This might be the problem: dm.addCompletedDownload and GeckoMediaScannerClient.startScan are still using "aMimeType" instead of the new variable "mimeType".
I also noticed that "application/octet-stream" is added to "UNKNOWN_MIME_TYPES" twice.
Attached patch Follow upSplinter Review
Grr. Yeah. Sorry, I revamped this a little right before uploading and missed that. This fixes it to use the new mimetype and then messed up some unbitrotting as well. Tested and works with nightly.mozilla.org. Need to test on Github.
Attachment #8498255 - Flags: review?(margaret.leibovic)
Comment on attachment 8498255 [details] [diff] [review]
Follow up

Review of attachment 8498255 [details] [diff] [review]:
-----------------------------------------------------------------

I'm confused, what patch does this apply on top of? Could you just fold these together to create one patch that applies to the tree now that bug 1070797 landed?
The original patch in this bug already landed. This just fixes a (dumb) mistake in it that caused this bug to be re-opened.
Comment on attachment 8498255 [details] [diff] [review]
Follow up

Review of attachment 8498255 [details] [diff] [review]:
-----------------------------------------------------------------

::: mobile/android/base/GeckoAppShell.java
@@ -140,5 @@
>      private static final Map<String, String> ALERT_COOKIES = new ConcurrentHashMap<String, String>();
>  
>      @SuppressWarnings("serial")
>      private static final List<String> UNKNOWN_MIME_TYPES = new ArrayList<String>(3) {{
> -        add("application/octet-stream"); // This will be used as a default mime type for unknown files

Oh, I didn't notice that this was reopened. I was confused because this line isn't in the patch that was previously attached, I didn't look at the one that had landed. This seems fine.
Attachment #8498255 - Flags: review?(margaret.leibovic) → review+
https://hg.mozilla.org/mozilla-central/rev/4b7e1497fbcb
Status: REOPENED → RESOLVED
Closed: 10 years ago10 years ago
Resolution: --- → FIXED
Status: RESOLVED → VERIFIED
Product: Firefox for Android → Firefox for Android Graveyard
You need to log in before you can comment on or make changes to this bug.