You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
976 lines
25 KiB
976 lines
25 KiB
.class public Lcom/viatech/util/DownloadTask; |
|
.super Ljava/lang/Object; |
|
.source "DownloadTask.java" |
|
|
|
# interfaces |
|
.implements Ljava/lang/Runnable; |
|
|
|
|
|
# static fields |
|
.field private static final TAG:Ljava/lang/String; = "Vpai_DownloadTask" |
|
|
|
|
|
# instance fields |
|
.field private mCancel:Z |
|
|
|
.field private mDeleteAfterDownload:Z |
|
|
|
.field private mDownloadSavePath:Ljava/lang/String; |
|
|
|
.field private mDownloadSuccess:Z |
|
|
|
.field private mFileName:Ljava/lang/String; |
|
|
|
.field private mFilePath:Ljava/lang/String; |
|
|
|
.field private mFileUrl:Ljava/lang/String; |
|
|
|
.field private mIs180VrOn:Z |
|
|
|
.field private mListener:Lcom/viatech/util/HttpDownloadManager$OnDownloadListener; |
|
|
|
.field private mProgress:I |
|
|
|
|
|
# direct methods |
|
.method public constructor <init>(Ljava/lang/String;Ljava/lang/String;Lcom/viatech/util/HttpDownloadManager$OnDownloadListener;)V |
|
.locals 2 |
|
|
|
.prologue |
|
const/4 v1, 0x0 |
|
|
|
.line 31 |
|
invoke-direct {p0}, Ljava/lang/Object;-><init>()V |
|
|
|
.line 23 |
|
iput-boolean v1, p0, Lcom/viatech/util/DownloadTask;->mCancel:Z |
|
|
|
.line 24 |
|
iput-boolean v1, p0, Lcom/viatech/util/DownloadTask;->mDownloadSuccess:Z |
|
|
|
.line 25 |
|
iput v1, p0, Lcom/viatech/util/DownloadTask;->mProgress:I |
|
|
|
.line 26 |
|
sget-object v0, Lcom/viatech/Config;->d:Ljava/lang/String; |
|
|
|
iput-object v0, p0, Lcom/viatech/util/DownloadTask;->mDownloadSavePath:Ljava/lang/String; |
|
|
|
.line 29 |
|
iput-boolean v1, p0, Lcom/viatech/util/DownloadTask;->mDeleteAfterDownload:Z |
|
|
|
.line 32 |
|
iput-object p1, p0, Lcom/viatech/util/DownloadTask;->mFileName:Ljava/lang/String; |
|
|
|
.line 33 |
|
new-instance v0, Ljava/lang/StringBuilder; |
|
|
|
invoke-direct {v0}, Ljava/lang/StringBuilder;-><init>()V |
|
|
|
iget-object v1, p0, Lcom/viatech/util/DownloadTask;->mDownloadSavePath:Ljava/lang/String; |
|
|
|
invoke-virtual {v0, v1}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder; |
|
|
|
move-result-object v0 |
|
|
|
const-string v1, "/" |
|
|
|
invoke-virtual {v0, v1}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder; |
|
|
|
move-result-object v0 |
|
|
|
invoke-virtual {v0, p1}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder; |
|
|
|
move-result-object v0 |
|
|
|
invoke-virtual {v0}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String; |
|
|
|
move-result-object v0 |
|
|
|
iput-object v0, p0, Lcom/viatech/util/DownloadTask;->mFilePath:Ljava/lang/String; |
|
|
|
.line 34 |
|
iput-object p2, p0, Lcom/viatech/util/DownloadTask;->mFileUrl:Ljava/lang/String; |
|
|
|
.line 35 |
|
iput-object p3, p0, Lcom/viatech/util/DownloadTask;->mListener:Lcom/viatech/util/HttpDownloadManager$OnDownloadListener; |
|
|
|
.line 37 |
|
return-void |
|
.end method |
|
|
|
.method public constructor <init>(Ljava/lang/String;Ljava/lang/String;Lcom/viatech/util/HttpDownloadManager$OnDownloadListener;Ljava/lang/String;)V |
|
.locals 2 |
|
|
|
.prologue |
|
.line 40 |
|
invoke-direct {p0, p1, p2, p3}, Lcom/viatech/util/DownloadTask;-><init>(Ljava/lang/String;Ljava/lang/String;Lcom/viatech/util/HttpDownloadManager$OnDownloadListener;)V |
|
|
|
.line 41 |
|
iput-object p4, p0, Lcom/viatech/util/DownloadTask;->mDownloadSavePath:Ljava/lang/String; |
|
|
|
.line 42 |
|
new-instance v0, Ljava/lang/StringBuilder; |
|
|
|
invoke-direct {v0}, Ljava/lang/StringBuilder;-><init>()V |
|
|
|
iget-object v1, p0, Lcom/viatech/util/DownloadTask;->mDownloadSavePath:Ljava/lang/String; |
|
|
|
invoke-virtual {v0, v1}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder; |
|
|
|
move-result-object v0 |
|
|
|
const-string v1, "/" |
|
|
|
invoke-virtual {v0, v1}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder; |
|
|
|
move-result-object v0 |
|
|
|
invoke-virtual {v0, p1}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder; |
|
|
|
move-result-object v0 |
|
|
|
invoke-virtual {v0}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String; |
|
|
|
move-result-object v0 |
|
|
|
iput-object v0, p0, Lcom/viatech/util/DownloadTask;->mFilePath:Ljava/lang/String; |
|
|
|
.line 43 |
|
return-void |
|
.end method |
|
|
|
.method public constructor <init>(Ljava/lang/String;Ljava/lang/String;ZLcom/viatech/util/HttpDownloadManager$OnDownloadListener;)V |
|
.locals 2 |
|
|
|
.prologue |
|
const/4 v1, 0x0 |
|
|
|
.line 44 |
|
invoke-direct {p0}, Ljava/lang/Object;-><init>()V |
|
|
|
.line 23 |
|
iput-boolean v1, p0, Lcom/viatech/util/DownloadTask;->mCancel:Z |
|
|
|
.line 24 |
|
iput-boolean v1, p0, Lcom/viatech/util/DownloadTask;->mDownloadSuccess:Z |
|
|
|
.line 25 |
|
iput v1, p0, Lcom/viatech/util/DownloadTask;->mProgress:I |
|
|
|
.line 26 |
|
sget-object v0, Lcom/viatech/Config;->d:Ljava/lang/String; |
|
|
|
iput-object v0, p0, Lcom/viatech/util/DownloadTask;->mDownloadSavePath:Ljava/lang/String; |
|
|
|
.line 29 |
|
iput-boolean v1, p0, Lcom/viatech/util/DownloadTask;->mDeleteAfterDownload:Z |
|
|
|
.line 45 |
|
iput-object p1, p0, Lcom/viatech/util/DownloadTask;->mFileName:Ljava/lang/String; |
|
|
|
.line 46 |
|
new-instance v0, Ljava/lang/StringBuilder; |
|
|
|
invoke-direct {v0}, Ljava/lang/StringBuilder;-><init>()V |
|
|
|
iget-object v1, p0, Lcom/viatech/util/DownloadTask;->mDownloadSavePath:Ljava/lang/String; |
|
|
|
invoke-virtual {v0, v1}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder; |
|
|
|
move-result-object v0 |
|
|
|
const-string v1, "/" |
|
|
|
invoke-virtual {v0, v1}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder; |
|
|
|
move-result-object v0 |
|
|
|
invoke-virtual {v0, p1}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder; |
|
|
|
move-result-object v0 |
|
|
|
invoke-virtual {v0}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String; |
|
|
|
move-result-object v0 |
|
|
|
iput-object v0, p0, Lcom/viatech/util/DownloadTask;->mFilePath:Ljava/lang/String; |
|
|
|
.line 47 |
|
iput-object p2, p0, Lcom/viatech/util/DownloadTask;->mFileUrl:Ljava/lang/String; |
|
|
|
.line 48 |
|
iput-object p4, p0, Lcom/viatech/util/DownloadTask;->mListener:Lcom/viatech/util/HttpDownloadManager$OnDownloadListener; |
|
|
|
.line 49 |
|
iput-boolean p3, p0, Lcom/viatech/util/DownloadTask;->mIs180VrOn:Z |
|
|
|
.line 50 |
|
return-void |
|
.end method |
|
|
|
|
|
# virtual methods |
|
.method public cancelDownload()V |
|
.locals 1 |
|
|
|
.prologue |
|
.line 57 |
|
iget-boolean v0, p0, Lcom/viatech/util/DownloadTask;->mCancel:Z |
|
|
|
if-nez v0, :cond_0 |
|
|
|
.line 58 |
|
const/4 v0, 0x1 |
|
|
|
iput-boolean v0, p0, Lcom/viatech/util/DownloadTask;->mCancel:Z |
|
|
|
.line 60 |
|
:cond_0 |
|
return-void |
|
.end method |
|
|
|
.method public cloneTask()Lcom/viatech/util/DownloadTask; |
|
.locals 5 |
|
|
|
.prologue |
|
.line 53 |
|
new-instance v0, Lcom/viatech/util/DownloadTask; |
|
|
|
iget-object v1, p0, Lcom/viatech/util/DownloadTask;->mFileName:Ljava/lang/String; |
|
|
|
iget-object v2, p0, Lcom/viatech/util/DownloadTask;->mFileUrl:Ljava/lang/String; |
|
|
|
iget-object v3, p0, Lcom/viatech/util/DownloadTask;->mListener:Lcom/viatech/util/HttpDownloadManager$OnDownloadListener; |
|
|
|
iget-object v4, p0, Lcom/viatech/util/DownloadTask;->mDownloadSavePath:Ljava/lang/String; |
|
|
|
invoke-direct {v0, v1, v2, v3, v4}, Lcom/viatech/util/DownloadTask;-><init>(Ljava/lang/String;Ljava/lang/String;Lcom/viatech/util/HttpDownloadManager$OnDownloadListener;Ljava/lang/String;)V |
|
|
|
return-object v0 |
|
.end method |
|
|
|
.method public getFileName()Ljava/lang/String; |
|
.locals 1 |
|
|
|
.prologue |
|
.line 71 |
|
iget-object v0, p0, Lcom/viatech/util/DownloadTask;->mFileName:Ljava/lang/String; |
|
|
|
return-object v0 |
|
.end method |
|
|
|
.method public getFilePath()Ljava/lang/String; |
|
.locals 1 |
|
|
|
.prologue |
|
.line 67 |
|
iget-object v0, p0, Lcom/viatech/util/DownloadTask;->mFilePath:Ljava/lang/String; |
|
|
|
return-object v0 |
|
.end method |
|
|
|
.method public getFileUrl()Ljava/lang/String; |
|
.locals 1 |
|
|
|
.prologue |
|
.line 63 |
|
iget-object v0, p0, Lcom/viatech/util/DownloadTask;->mFileUrl:Ljava/lang/String; |
|
|
|
return-object v0 |
|
.end method |
|
|
|
.method public getProgress()I |
|
.locals 1 |
|
|
|
.prologue |
|
.line 75 |
|
iget v0, p0, Lcom/viatech/util/DownloadTask;->mProgress:I |
|
|
|
return v0 |
|
.end method |
|
|
|
.method public run()V |
|
.locals 13 |
|
|
|
.prologue |
|
const/4 v2, 0x0 |
|
|
|
.line 88 |
|
iget-object v0, p0, Lcom/viatech/util/DownloadTask;->mListener:Lcom/viatech/util/HttpDownloadManager$OnDownloadListener; |
|
|
|
if-eqz v0, :cond_0 |
|
|
|
.line 89 |
|
iget-object v0, p0, Lcom/viatech/util/DownloadTask;->mListener:Lcom/viatech/util/HttpDownloadManager$OnDownloadListener; |
|
|
|
invoke-interface {v0, p0}, Lcom/viatech/util/HttpDownloadManager$OnDownloadListener;->onDownloadStart(Lcom/viatech/util/DownloadTask;)V |
|
|
|
.line 90 |
|
iget-object v0, p0, Lcom/viatech/util/DownloadTask;->mListener:Lcom/viatech/util/HttpDownloadManager$OnDownloadListener; |
|
|
|
invoke-interface {v0, p0, v2}, Lcom/viatech/util/HttpDownloadManager$OnDownloadListener;->onDownloadProgress(Lcom/viatech/util/DownloadTask;I)V |
|
|
|
.line 92 |
|
:cond_0 |
|
const/4 v1, 0x0 |
|
|
|
.line 95 |
|
:try_start_0 |
|
iget-object v0, p0, Lcom/viatech/util/DownloadTask;->mFileUrl:Ljava/lang/String; |
|
|
|
.line 96 |
|
new-instance v3, Ljava/net/URL; |
|
|
|
invoke-direct {v3, v0}, Ljava/net/URL;-><init>(Ljava/lang/String;)V |
|
|
|
.line 97 |
|
invoke-virtual {v3}, Ljava/net/URL;->openConnection()Ljava/net/URLConnection; |
|
|
|
move-result-object v0 |
|
|
|
check-cast v0, Ljava/net/HttpURLConnection; |
|
:try_end_0 |
|
.catch Ljava/net/MalformedURLException; {:try_start_0 .. :try_end_0} :catch_3 |
|
.catch Ljava/io/IOException; {:try_start_0 .. :try_end_0} :catch_2 |
|
.catchall {:try_start_0 .. :try_end_0} :catchall_0 |
|
|
|
.line 99 |
|
:try_start_1 |
|
iget-object v1, p0, Lcom/viatech/util/DownloadTask;->mFilePath:Ljava/lang/String; |
|
|
|
.line 101 |
|
iget-boolean v3, p0, Lcom/viatech/util/DownloadTask;->mIs180VrOn:Z |
|
|
|
if-eqz v3, :cond_1 |
|
|
|
.line 102 |
|
const/4 v3, 0x0 |
|
|
|
invoke-virtual {v1}, Ljava/lang/String;->length()I |
|
|
|
move-result v4 |
|
|
|
add-int/lit8 v4, v4, -0x4 |
|
|
|
invoke-virtual {v1, v3, v4}, Ljava/lang/String;->substring(II)Ljava/lang/String; |
|
|
|
move-result-object v3 |
|
|
|
.line 103 |
|
const-string v4, ".jpg" |
|
|
|
invoke-virtual {v1, v4}, Ljava/lang/String;->endsWith(Ljava/lang/String;)Z |
|
|
|
move-result v1 |
|
|
|
if-eqz v1, :cond_4 |
|
|
|
.line 104 |
|
new-instance v1, Ljava/lang/StringBuilder; |
|
|
|
invoke-direct {v1}, Ljava/lang/StringBuilder;-><init>()V |
|
|
|
invoke-virtual {v1, v3}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder; |
|
|
|
move-result-object v1 |
|
|
|
const-string v3, "_V3D.jpg" |
|
|
|
invoke-virtual {v1, v3}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder; |
|
|
|
move-result-object v1 |
|
|
|
invoke-virtual {v1}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String; |
|
|
|
move-result-object v1 |
|
|
|
.line 110 |
|
:cond_1 |
|
:goto_0 |
|
const-string v3, "Vpai_DownloadTask" |
|
|
|
new-instance v4, Ljava/lang/StringBuilder; |
|
|
|
invoke-direct {v4}, Ljava/lang/StringBuilder;-><init>()V |
|
|
|
const-string v5, "run: ___" |
|
|
|
invoke-virtual {v4, v5}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder; |
|
|
|
move-result-object v4 |
|
|
|
invoke-virtual {v4, v1}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder; |
|
|
|
move-result-object v4 |
|
|
|
invoke-virtual {v4}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String; |
|
|
|
move-result-object v4 |
|
|
|
invoke-static {v3, v4}, Landroid/util/Log;->d(Ljava/lang/String;Ljava/lang/String;)I |
|
|
|
.line 112 |
|
new-instance v3, Ljava/lang/StringBuilder; |
|
|
|
invoke-direct {v3}, Ljava/lang/StringBuilder;-><init>()V |
|
|
|
invoke-virtual {v3, v1}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder; |
|
|
|
move-result-object v3 |
|
|
|
const-string v4, ".tmp" |
|
|
|
invoke-virtual {v3, v4}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder; |
|
|
|
move-result-object v3 |
|
|
|
invoke-virtual {v3}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String; |
|
|
|
move-result-object v3 |
|
|
|
.line 113 |
|
const-string v4, "Vpai_DownloadTask" |
|
|
|
new-instance v5, Ljava/lang/StringBuilder; |
|
|
|
invoke-direct {v5}, Ljava/lang/StringBuilder;-><init>()V |
|
|
|
const-string v6, "pathName = " |
|
|
|
invoke-virtual {v5, v6}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder; |
|
|
|
move-result-object v5 |
|
|
|
invoke-virtual {v5, v1}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder; |
|
|
|
move-result-object v5 |
|
|
|
invoke-virtual {v5}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String; |
|
|
|
move-result-object v5 |
|
|
|
invoke-static {v4, v5}, Landroid/util/Log;->d(Ljava/lang/String;Ljava/lang/String;)I |
|
|
|
.line 115 |
|
invoke-virtual {v0}, Ljava/net/HttpURLConnection;->getContentLength()I |
|
|
|
move-result v4 |
|
|
|
.line 116 |
|
iget-object v5, p0, Lcom/viatech/util/DownloadTask;->mDownloadSavePath:Ljava/lang/String; |
|
|
|
invoke-static {v5}, Lcom/viatech/util/Util;->getAvailableSpace(Ljava/lang/String;)J |
|
|
|
move-result-wide v6 |
|
|
|
.line 117 |
|
int-to-long v8, v4 |
|
|
|
const-wide/32 v10, 0x11e1a300 |
|
|
|
sub-long/2addr v6, v10 |
|
|
|
cmp-long v5, v8, v6 |
|
|
|
if-lez v5, :cond_5 |
|
|
|
.line 118 |
|
iget-object v1, p0, Lcom/viatech/util/DownloadTask;->mListener:Lcom/viatech/util/HttpDownloadManager$OnDownloadListener; |
|
|
|
if-eqz v1, :cond_2 |
|
|
|
.line 119 |
|
iget-object v1, p0, Lcom/viatech/util/DownloadTask;->mListener:Lcom/viatech/util/HttpDownloadManager$OnDownloadListener; |
|
|
|
const/4 v2, 0x0 |
|
|
|
invoke-interface {v1, p0, v2}, Lcom/viatech/util/HttpDownloadManager$OnDownloadListener;->onDownloadEnd(Lcom/viatech/util/DownloadTask;Z)V |
|
:try_end_1 |
|
.catch Ljava/net/MalformedURLException; {:try_start_1 .. :try_end_1} :catch_0 |
|
.catch Ljava/io/IOException; {:try_start_1 .. :try_end_1} :catch_1 |
|
.catchall {:try_start_1 .. :try_end_1} :catchall_1 |
|
|
|
.line 192 |
|
:cond_2 |
|
:goto_1 |
|
if-eqz v0, :cond_3 |
|
|
|
.line 193 |
|
invoke-virtual {v0}, Ljava/net/HttpURLConnection;->disconnect()V |
|
|
|
.line 194 |
|
:cond_3 |
|
invoke-static {}, Lcom/viatech/util/HttpDownloadManager;->instance()Lcom/viatech/util/HttpDownloadManager; |
|
|
|
move-result-object v0 |
|
|
|
invoke-virtual {v0, p0}, Lcom/viatech/util/HttpDownloadManager;->cancelDownload(Lcom/viatech/util/DownloadTask;)V |
|
|
|
.line 196 |
|
:goto_2 |
|
return-void |
|
|
|
.line 106 |
|
:cond_4 |
|
:try_start_2 |
|
new-instance v1, Ljava/lang/StringBuilder; |
|
|
|
invoke-direct {v1}, Ljava/lang/StringBuilder;-><init>()V |
|
|
|
invoke-virtual {v1, v3}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder; |
|
|
|
move-result-object v1 |
|
|
|
const-string v3, "_V3D.mp4" |
|
|
|
invoke-virtual {v1, v3}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder; |
|
|
|
move-result-object v1 |
|
|
|
invoke-virtual {v1}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String; |
|
|
|
move-result-object v1 |
|
|
|
goto :goto_0 |
|
|
|
.line 122 |
|
:cond_5 |
|
new-instance v5, Ljava/io/File; |
|
|
|
invoke-direct {v5, v1}, Ljava/io/File;-><init>(Ljava/lang/String;)V |
|
|
|
.line 123 |
|
new-instance v6, Ljava/io/File; |
|
|
|
invoke-direct {v6, v3}, Ljava/io/File;-><init>(Ljava/lang/String;)V |
|
|
|
.line 124 |
|
invoke-virtual {v0}, Ljava/net/HttpURLConnection;->getInputStream()Ljava/io/InputStream; |
|
|
|
move-result-object v7 |
|
|
|
.line 125 |
|
invoke-virtual {v5}, Ljava/io/File;->exists()Z |
|
|
|
move-result v1 |
|
|
|
if-eqz v1, :cond_6 |
|
|
|
.line 126 |
|
const-string v1, "Vpai_DownloadTask" |
|
|
|
const-string v3, "file exists,delete it" |
|
|
|
invoke-static {v1, v3}, Landroid/util/Log;->i(Ljava/lang/String;Ljava/lang/String;)I |
|
|
|
.line 127 |
|
invoke-virtual {v5}, Ljava/io/File;->delete()Z |
|
|
|
.line 130 |
|
:cond_6 |
|
invoke-virtual {v6}, Ljava/io/File;->exists()Z |
|
|
|
move-result v1 |
|
|
|
if-eqz v1, :cond_7 |
|
|
|
.line 131 |
|
invoke-virtual {v6}, Ljava/io/File;->delete()Z |
|
|
|
.line 134 |
|
:cond_7 |
|
invoke-virtual {v5}, Ljava/io/File;->getParentFile()Ljava/io/File; |
|
|
|
move-result-object v1 |
|
|
|
invoke-virtual {v1}, Ljava/io/File;->getAbsolutePath()Ljava/lang/String; |
|
|
|
move-result-object v1 |
|
|
|
.line 135 |
|
const-string v3, "Vpai_DownloadTask" |
|
|
|
new-instance v8, Ljava/lang/StringBuilder; |
|
|
|
invoke-direct {v8}, Ljava/lang/StringBuilder;-><init>()V |
|
|
|
const-string v9, "dir = " |
|
|
|
invoke-virtual {v8, v9}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder; |
|
|
|
move-result-object v8 |
|
|
|
invoke-virtual {v8, v1}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder; |
|
|
|
move-result-object v8 |
|
|
|
invoke-virtual {v8}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String; |
|
|
|
move-result-object v8 |
|
|
|
invoke-static {v3, v8}, Landroid/util/Log;->i(Ljava/lang/String;Ljava/lang/String;)I |
|
|
|
.line 136 |
|
new-instance v3, Ljava/io/File; |
|
|
|
invoke-direct {v3, v1}, Ljava/io/File;-><init>(Ljava/lang/String;)V |
|
|
|
.line 137 |
|
invoke-virtual {v3}, Ljava/io/File;->exists()Z |
|
|
|
move-result v1 |
|
|
|
if-nez v1, :cond_8 |
|
|
|
.line 138 |
|
invoke-virtual {v3}, Ljava/io/File;->mkdirs()Z |
|
|
|
.line 140 |
|
:cond_8 |
|
invoke-virtual {v6}, Ljava/io/File;->createNewFile()Z |
|
|
|
.line 141 |
|
new-instance v8, Ljava/io/FileOutputStream; |
|
|
|
invoke-direct {v8, v6}, Ljava/io/FileOutputStream;-><init>(Ljava/io/File;)V |
|
|
|
.line 143 |
|
const/16 v1, 0x400 |
|
|
|
new-array v9, v1, [B |
|
|
|
.line 147 |
|
invoke-virtual {v7, v9}, Ljava/io/InputStream;->read([B)I |
|
|
|
move-result v1 |
|
|
|
move v3, v2 |
|
|
|
.line 148 |
|
:goto_3 |
|
const/4 v10, -0x1 |
|
|
|
if-eq v1, v10, :cond_a |
|
|
|
iget-boolean v10, p0, Lcom/viatech/util/DownloadTask;->mCancel:Z |
|
|
|
if-nez v10, :cond_a |
|
|
|
.line 149 |
|
const/4 v10, 0x0 |
|
|
|
invoke-virtual {v8, v9, v10, v1}, Ljava/io/OutputStream;->write([BII)V |
|
|
|
.line 150 |
|
add-int/2addr v3, v1 |
|
|
|
.line 151 |
|
int-to-float v1, v3 |
|
|
|
const/high16 v10, 0x3f800000 # 1.0f |
|
|
|
mul-float/2addr v1, v10 |
|
|
|
int-to-float v10, v4 |
|
|
|
div-float/2addr v1, v10 |
|
|
|
const/high16 v10, 0x42c80000 # 100.0f |
|
|
|
mul-float/2addr v1, v10 |
|
|
|
float-to-int v1, v1 |
|
|
|
.line 152 |
|
if-le v1, v2, :cond_12 |
|
|
|
.line 154 |
|
iput v1, p0, Lcom/viatech/util/DownloadTask;->mProgress:I |
|
|
|
.line 155 |
|
iget-object v2, p0, Lcom/viatech/util/DownloadTask;->mListener:Lcom/viatech/util/HttpDownloadManager$OnDownloadListener; |
|
|
|
if-eqz v2, :cond_9 |
|
|
|
.line 156 |
|
iget-object v2, p0, Lcom/viatech/util/DownloadTask;->mListener:Lcom/viatech/util/HttpDownloadManager$OnDownloadListener; |
|
|
|
invoke-interface {v2, p0, v1}, Lcom/viatech/util/HttpDownloadManager$OnDownloadListener;->onDownloadProgress(Lcom/viatech/util/DownloadTask;I)V |
|
|
|
.line 158 |
|
:cond_9 |
|
:goto_4 |
|
invoke-virtual {v7, v9}, Ljava/io/InputStream;->read([B)I |
|
|
|
move-result v2 |
|
|
|
move v12, v2 |
|
|
|
move v2, v1 |
|
|
|
move v1, v12 |
|
|
|
goto :goto_3 |
|
|
|
.line 160 |
|
:cond_a |
|
invoke-virtual {v8}, Ljava/io/OutputStream;->flush()V |
|
|
|
.line 161 |
|
invoke-virtual {v8}, Ljava/io/OutputStream;->close()V |
|
|
|
.line 162 |
|
invoke-virtual {v7}, Ljava/io/InputStream;->close()V |
|
|
|
.line 163 |
|
iget-boolean v1, p0, Lcom/viatech/util/DownloadTask;->mCancel:Z |
|
|
|
if-eqz v1, :cond_e |
|
|
|
.line 164 |
|
iget-object v1, p0, Lcom/viatech/util/DownloadTask;->mListener:Lcom/viatech/util/HttpDownloadManager$OnDownloadListener; |
|
|
|
if-eqz v1, :cond_b |
|
|
|
.line 165 |
|
iget-object v1, p0, Lcom/viatech/util/DownloadTask;->mListener:Lcom/viatech/util/HttpDownloadManager$OnDownloadListener; |
|
|
|
const/4 v2, 0x0 |
|
|
|
invoke-interface {v1, p0, v2}, Lcom/viatech/util/HttpDownloadManager$OnDownloadListener;->onDownloadEnd(Lcom/viatech/util/DownloadTask;Z)V |
|
|
|
.line 178 |
|
:cond_b |
|
:goto_5 |
|
invoke-virtual {v6}, Ljava/io/File;->exists()Z |
|
|
|
move-result v1 |
|
|
|
if-eqz v1, :cond_2 |
|
|
|
.line 179 |
|
invoke-virtual {v6}, Ljava/io/File;->delete()Z |
|
:try_end_2 |
|
.catch Ljava/net/MalformedURLException; {:try_start_2 .. :try_end_2} :catch_0 |
|
.catch Ljava/io/IOException; {:try_start_2 .. :try_end_2} :catch_1 |
|
.catchall {:try_start_2 .. :try_end_2} :catchall_1 |
|
|
|
goto/16 :goto_1 |
|
|
|
.line 183 |
|
:catch_0 |
|
move-exception v1 |
|
|
|
move-object v12, v1 |
|
|
|
move-object v1, v0 |
|
|
|
move-object v0, v12 |
|
|
|
.line 184 |
|
:goto_6 |
|
:try_start_3 |
|
const-string v2, "Vpai_DownloadTask" |
|
|
|
invoke-virtual {v0}, Ljava/net/MalformedURLException;->getMessage()Ljava/lang/String; |
|
|
|
move-result-object v0 |
|
|
|
invoke-static {v2, v0}, Landroid/util/Log;->e(Ljava/lang/String;Ljava/lang/String;)I |
|
|
|
.line 185 |
|
iget-object v0, p0, Lcom/viatech/util/DownloadTask;->mListener:Lcom/viatech/util/HttpDownloadManager$OnDownloadListener; |
|
|
|
if-eqz v0, :cond_c |
|
|
|
.line 186 |
|
iget-object v0, p0, Lcom/viatech/util/DownloadTask;->mListener:Lcom/viatech/util/HttpDownloadManager$OnDownloadListener; |
|
|
|
const/4 v2, 0x0 |
|
|
|
invoke-interface {v0, p0, v2}, Lcom/viatech/util/HttpDownloadManager$OnDownloadListener;->onDownloadEnd(Lcom/viatech/util/DownloadTask;Z)V |
|
:try_end_3 |
|
.catchall {:try_start_3 .. :try_end_3} :catchall_0 |
|
|
|
.line 192 |
|
:cond_c |
|
if-eqz v1, :cond_d |
|
|
|
.line 193 |
|
invoke-virtual {v1}, Ljava/net/HttpURLConnection;->disconnect()V |
|
|
|
.line 194 |
|
:cond_d |
|
invoke-static {}, Lcom/viatech/util/HttpDownloadManager;->instance()Lcom/viatech/util/HttpDownloadManager; |
|
|
|
move-result-object v0 |
|
|
|
invoke-virtual {v0, p0}, Lcom/viatech/util/HttpDownloadManager;->cancelDownload(Lcom/viatech/util/DownloadTask;)V |
|
|
|
goto/16 :goto_2 |
|
|
|
.line 167 |
|
:cond_e |
|
:try_start_4 |
|
invoke-virtual {v6, v5}, Ljava/io/File;->renameTo(Ljava/io/File;)Z |
|
|
|
.line 168 |
|
const/16 v1, 0x64 |
|
|
|
iput v1, p0, Lcom/viatech/util/DownloadTask;->mProgress:I |
|
|
|
.line 169 |
|
const/4 v1, 0x1 |
|
|
|
iput-boolean v1, p0, Lcom/viatech/util/DownloadTask;->mDownloadSuccess:Z |
|
|
|
.line 170 |
|
iget-object v1, p0, Lcom/viatech/util/DownloadTask;->mListener:Lcom/viatech/util/HttpDownloadManager$OnDownloadListener; |
|
|
|
if-eqz v1, :cond_b |
|
|
|
.line 171 |
|
iget-object v1, p0, Lcom/viatech/util/DownloadTask;->mListener:Lcom/viatech/util/HttpDownloadManager$OnDownloadListener; |
|
|
|
const/16 v2, 0x64 |
|
|
|
invoke-interface {v1, p0, v2}, Lcom/viatech/util/HttpDownloadManager$OnDownloadListener;->onDownloadProgress(Lcom/viatech/util/DownloadTask;I)V |
|
|
|
.line 172 |
|
iget-object v1, p0, Lcom/viatech/util/DownloadTask;->mListener:Lcom/viatech/util/HttpDownloadManager$OnDownloadListener; |
|
|
|
const/4 v2, 0x1 |
|
|
|
invoke-interface {v1, p0, v2}, Lcom/viatech/util/HttpDownloadManager$OnDownloadListener;->onDownloadEnd(Lcom/viatech/util/DownloadTask;Z)V |
|
:try_end_4 |
|
.catch Ljava/net/MalformedURLException; {:try_start_4 .. :try_end_4} :catch_0 |
|
.catch Ljava/io/IOException; {:try_start_4 .. :try_end_4} :catch_1 |
|
.catchall {:try_start_4 .. :try_end_4} :catchall_1 |
|
|
|
goto :goto_5 |
|
|
|
.line 187 |
|
:catch_1 |
|
move-exception v1 |
|
|
|
move-object v12, v1 |
|
|
|
move-object v1, v0 |
|
|
|
move-object v0, v12 |
|
|
|
.line 188 |
|
:goto_7 |
|
:try_start_5 |
|
const-string v2, "Vpai_DownloadTask" |
|
|
|
invoke-virtual {v0}, Ljava/io/IOException;->getMessage()Ljava/lang/String; |
|
|
|
move-result-object v0 |
|
|
|
invoke-static {v2, v0}, Landroid/util/Log;->e(Ljava/lang/String;Ljava/lang/String;)I |
|
|
|
.line 189 |
|
iget-object v0, p0, Lcom/viatech/util/DownloadTask;->mListener:Lcom/viatech/util/HttpDownloadManager$OnDownloadListener; |
|
|
|
if-eqz v0, :cond_f |
|
|
|
.line 190 |
|
iget-object v0, p0, Lcom/viatech/util/DownloadTask;->mListener:Lcom/viatech/util/HttpDownloadManager$OnDownloadListener; |
|
|
|
const/4 v2, 0x0 |
|
|
|
invoke-interface {v0, p0, v2}, Lcom/viatech/util/HttpDownloadManager$OnDownloadListener;->onDownloadEnd(Lcom/viatech/util/DownloadTask;Z)V |
|
:try_end_5 |
|
.catchall {:try_start_5 .. :try_end_5} :catchall_0 |
|
|
|
.line 192 |
|
:cond_f |
|
if-eqz v1, :cond_10 |
|
|
|
.line 193 |
|
invoke-virtual {v1}, Ljava/net/HttpURLConnection;->disconnect()V |
|
|
|
.line 194 |
|
:cond_10 |
|
invoke-static {}, Lcom/viatech/util/HttpDownloadManager;->instance()Lcom/viatech/util/HttpDownloadManager; |
|
|
|
move-result-object v0 |
|
|
|
invoke-virtual {v0, p0}, Lcom/viatech/util/HttpDownloadManager;->cancelDownload(Lcom/viatech/util/DownloadTask;)V |
|
|
|
goto/16 :goto_2 |
|
|
|
.line 192 |
|
:catchall_0 |
|
move-exception v0 |
|
|
|
:goto_8 |
|
if-eqz v1, :cond_11 |
|
|
|
.line 193 |
|
invoke-virtual {v1}, Ljava/net/HttpURLConnection;->disconnect()V |
|
|
|
.line 194 |
|
:cond_11 |
|
invoke-static {}, Lcom/viatech/util/HttpDownloadManager;->instance()Lcom/viatech/util/HttpDownloadManager; |
|
|
|
move-result-object v1 |
|
|
|
invoke-virtual {v1, p0}, Lcom/viatech/util/HttpDownloadManager;->cancelDownload(Lcom/viatech/util/DownloadTask;)V |
|
|
|
.line 195 |
|
throw v0 |
|
|
|
.line 192 |
|
:catchall_1 |
|
move-exception v1 |
|
|
|
move-object v12, v1 |
|
|
|
move-object v1, v0 |
|
|
|
move-object v0, v12 |
|
|
|
goto :goto_8 |
|
|
|
.line 187 |
|
:catch_2 |
|
move-exception v0 |
|
|
|
goto :goto_7 |
|
|
|
.line 183 |
|
:catch_3 |
|
move-exception v0 |
|
|
|
goto :goto_6 |
|
|
|
:cond_12 |
|
move v1, v2 |
|
|
|
goto/16 :goto_4 |
|
.end method |
|
|
|
.method public setDeleteAfterDownload(Z)V |
|
.locals 0 |
|
|
|
.prologue |
|
.line 83 |
|
iput-boolean p1, p0, Lcom/viatech/util/DownloadTask;->mDeleteAfterDownload:Z |
|
|
|
.line 84 |
|
return-void |
|
.end method |
|
|
|
.method public setListener(Lcom/viatech/util/HttpDownloadManager$OnDownloadListener;)V |
|
.locals 0 |
|
|
|
.prologue |
|
.line 79 |
|
iput-object p1, p0, Lcom/viatech/util/DownloadTask;->mListener:Lcom/viatech/util/HttpDownloadManager$OnDownloadListener; |
|
|
|
.line 80 |
|
return-void |
|
.end method
|
|
|