Private Sub JobDone (Job As HttpJob)
Log("---- AppUpdating.JobDone --")
If sVerbose Then Log(TAB & "JobName = " & Job.JobName & ", Success = " & Job.Success)
If Job.Success = True Then
Select Job.JobName
Case "JobWebVNonly"
If sVerbose Then Log(TAB & "Read while in JobWebVNonly: " & Job.GetString)
webver=ExtractVN(Job.GetString) 'Job.GetString.SubString(4)
webclog=ExtractCL(Job.GetString) 'optional changelog data
If webver = "" Then
sStatusCode = ERR_TXTROW
Else
sStatusCode = OK_WEBVER 'read apk's version number as published on webserver
If sVerbose Then Log(TAB & "Web version number: " & webver)
End If
Finito
Case "JobApkDownload"
Log(TAB & "-- JobApkDownload")
'copy from external to storage card
Dim out As OutputStream
out = File.OpenOutput(File.DirDefaultExternal,"tmp.apk",False)
File.Copy2(Job.GetInputStream, out)
out.Close
sStatusCode = OK_DOWNLOAD
If sVerbose Then Log(TAB & "new apk version downloaded and ready to install")
Finito
Case "JobWebVNcompare"
Log(TAB & "-- JoWebVNcompare")
If sVerbose Then Log(TAB & "Read while in webVNcompare: " & Job.GetString)
webver=ExtractVN(Job.GetString) 'Job.GetString.SubString(4)
webclog=ExtractCL(Job.GetString) 'optional changelog data
If webver = "" Then
sStatusCode = ERR_TXTROW
Finito
Else
sStatusCode = OK_WEBVER 'read apk's version number as published on webserver
If sVerbose Then Log(TAB & "Web version number: " & webver)
End If
If curver < webver Then
sStatusCode = OK_NEWERAPK 'newer apk version available on webserver
If sVerbose Then Log(TAB & "Newer version available. Now I try its downloading")
ApkUpdate 'download and install
Else
sStatusCode = NO_NEWERAPK
If sVerbose Then Log(TAB & "No newer version available on webserver.")
Finito
End If
Case "JobApkUpdate"
Log(TAB & "-- JobApkUpdate")
'copy from external to storage card
Dim out As OutputStream
out = File.OpenOutput(File.DirDefaultExternal,"tmp.apk",False) '<-------------------------------ERROR HERE
File.Copy2(Job.GetInputStream, out)
out.Close
sStatusCode = OK_DOWNLOAD
If sVerbose Then Log(TAB & "new apk version downloaded and ready to install")
'intent to install
Dim i As Intent
i.Initialize(i.ACTION_VIEW, "file://" & File.Combine(File.DirDefaultExternal, "tmp.apk"))
i.SetType("application/vnd.android.package-archive")
StartActivity(i)
sStatusCode = OK_INSTALL
If sVerbose Then Log(TAB & "user asked to install new apk")
Finito
End Select
Else
Log(TAB & "Error: " & Job.ErrorMessage)
sStatusCode = ERR_HTTP
If sVerbose Then Log(TAB & "error in httputils2")
ToastMessageShow("Error: " & Job.ErrorMessage, True)
Finito
End If
Job.Release
End Sub