Android Question Android Security when downloading APK

Noelkman

Member
Licensed User
Longtime User
Hi there,
I'm wondering if there is any security when downloading APK files from a private webserver.

Situation:
I have a P9 with 6.0 Android on it. I am using the B4A 6.5 LargeFileDownload example from Erel and that works great with all other files but when I'm downloading an apk file the app crashes without any info or just does nothing. In the download folder then there is a file created with 0 bytes.

I have all security functions on the phone disabled and there is no antivirus that could cause this.

I'm lost - maybe someone else has an idea.
 

Noelkman

Member
Licensed User
Longtime User
This is just curious!
If I download the following file "5MB.zip" everything is fine. If I change the filename on the server to "5MB.apk" or take any other legal apk file I get the error log below.





Not Found
Error occurred on line: 131 (HttpJob)
java.io.FileNotFoundException: /data/user/0/and.xsvc/cache/2: open failed: ENOENT (No such file or directory)
at libcore.io.IoBridge.open(IoBridge.java:459)
at java.io.FileInputStream.<init>(FileInputStream.java:76)
at anywheresoftware.b4a.objects.streams.File.OpenInput(File.java:209)
at and.xsvc.httpjob._getinputstream(httpjob.java:63)
at java.lang.reflect.Method.invoke(Native Method)
at anywheresoftware.b4a.shell.Shell.runMethod(Shell.java:708)
at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:337)
at anywheresoftware.b4a.shell.Shell.raiseEvent(Shell.java:247)
at java.lang.reflect.Method.invoke(Native Method)
at anywheresoftware.b4a.ShellBA.raiseEvent2(ShellBA.java:134)
at anywheresoftware.b4a.BA$2.run(BA.java:328)
at android.os.Handler.handleCallback(Handler.java:743)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:150)
at android.app.ActivityThread.main(ActivityThread.java:5665)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:799)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:689)
Caused by: android.system.ErrnoException: open failed: ENOENT (No such file or directory)
at libcore.io.Posix.open(Native Method)
at libcore.io.BlockGuardOs.open(BlockGuardOs.java:186)
at libcore.io.IoBridge.open(IoBridge.java:445)
... 17 more
** Activity (main) Pause, UserClosed = true **
 
Upvote 0

Noelkman

Member
Licensed User
Longtime User
Raddaraddayaddiyaah...!!!

Found the issue! Oh my goodness after days.

It was the web server IIS 7.0

I needed to allow the extension ".apk" with mime type "application/octet-stream"
maybe someone else finds this info useful.
 
Upvote 0

Noelkman

Member
Licensed User
Longtime User
Erel,
you are right. I was not checking success but anyhow why in the world this works with every other file (and I mean with EVERY other file all kind and size) and since I have permitted and added the .apk extension on IIS it works without checking success ?
It worked right away so is there some checking with mime or something like that?

Just for my logic because I don't get it.
 
Upvote 0

udg

Expert
Licensed User
Longtime User
Hi @Noelkman ,
the problem you discovered with IIS is a known one. You can find traces along the posts in the thread about my lib AppUpdating which is used to download an update of an apk from a proprietary server and install it.

As for the use of checking or not Succes on JobDone, I'm sure Erel will reply in a more precise and correct way. To me it appears that not checking is like assuming a risk. If everything goes smooth it doesn't matter, but if something goes wrong you execute code tha shouldn't be executed since it assumes a successful download.

udg
 
Upvote 0

Erel

B4X founder
Staff member
Licensed User
Longtime User
You should always make sure that Job.Success is true before you try to access the downloaded data. Network errors can and will happen.

permitted and added the .apk extension on IIS it works without checking success ?
It will work as long as the download was successful. However if the download was not successful then you should handle it gracefully.
 
Upvote 0
Top