修复某些华为手机出现的无法下载的问题

v4
laoyuyu 3 years ago
parent aa292e4389
commit 4bd2ff7e18
  1. 12
      AriaCompiler/build.gradle
  2. 20
      HttpComponent/src/main/java/com/arialyy/aria/http/download/HttpDFileInfoTask.java
  3. 3
      app/src/main/java/com/arialyy/simple/core/download/HttpDownloadModule.java

@ -3,15 +3,15 @@ apply plugin: 'java'
tasks.withType(JavaCompile) { tasks.withType(JavaCompile) {
options.encoding = "UTF-8" options.encoding = "UTF-8"
} }
sourceCompatibility = JavaVersion.VERSION_1_7 sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_7 targetCompatibility = JavaVersion.VERSION_1_8
dependencies { dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs') implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation 'com.google.auto:auto-common:0.10' implementation 'com.google.auto:auto-common:1.2'
implementation 'com.google.auto.service:auto-service:1.0-rc6' implementation 'com.google.auto.service:auto-service:1.0.1'
annotationProcessor 'com.google.auto.service:auto-service:1.0-rc6' annotationProcessor 'com.google.auto.service:auto-service:1.0.1'
implementation 'com.squareup:javapoet:1.9.0' implementation 'com.squareup:javapoet:1.13.0'
implementation project(':AriaAnnotations') implementation project(':AriaAnnotations')
} }

@ -19,7 +19,6 @@ import android.net.TrafficStats;
import android.net.Uri; import android.net.Uri;
import android.os.Process; import android.os.Process;
import android.text.TextUtils; import android.text.TextUtils;
import android.util.Log;
import com.arialyy.aria.core.AriaConfig; import com.arialyy.aria.core.AriaConfig;
import com.arialyy.aria.core.common.CompleteInfo; import com.arialyy.aria.core.common.CompleteInfo;
import com.arialyy.aria.core.common.RequestEnum; import com.arialyy.aria.core.common.RequestEnum;
@ -208,6 +207,17 @@ final class HttpDFileInfoTask implements IInfoTask, Runnable {
} else if (code == HttpURLConnection.HTTP_OK) { } else if (code == HttpURLConnection.HTTP_OK) {
String contentType = conn.getHeaderField("Content-Type"); String contentType = conn.getHeaderField("Content-Type");
if (TextUtils.isEmpty(contentType)) { if (TextUtils.isEmpty(contentType)) {
if (!checkLen(len) && !isChunked) {
if (len < 0) {
failDownload(
new AriaHTTPException(String.format("任务下载失败,文件长度小于0, url: %s", mEntity.getUrl())),
false);
}
return;
}
mEntity.setFileSize(len);
mTaskWrapper.setSupportBP(true);
doNext(code, isChunked);
return; return;
} }
if (contentType.equals("text/html")) { if (contentType.equals("text/html")) {
@ -254,16 +264,20 @@ final class HttpDFileInfoTask implements IInfoTask, Runnable {
String.format("任务下载失败,errorCode:%s, errorMsg: %s, url: %s", code, String.format("任务下载失败,errorCode:%s, errorMsg: %s, url: %s", code,
conn.getResponseMessage(), mEntity.getUrl())), !CheckUtil.httpIsBadRequest(code)); conn.getResponseMessage(), mEntity.getUrl())), !CheckUtil.httpIsBadRequest(code));
} }
if (end) {
doNext(code, isChunked);
}
}
private void doNext(int code, boolean isChunked) {
if (isStop || isCancel) { if (isStop || isCancel) {
return; return;
} }
if (end) {
taskOption.setChunked(isChunked); taskOption.setChunked(isChunked);
CompleteInfo info = new CompleteInfo(code, mTaskWrapper); CompleteInfo info = new CompleteInfo(code, mTaskWrapper);
callback.onSucceed(mEntity.getUrl(), info); callback.onSucceed(mEntity.getUrl(), info);
mEntity.update(); mEntity.update();
} }
}
/** /**
* 处理"Content-Disposition"参数 * 处理"Content-Disposition"参数

@ -51,7 +51,8 @@ public class HttpDownloadModule extends BaseViewModule {
//String url = AppUtil.getConfigValue(context, HTTP_URL_KEY, defUrl); //String url = AppUtil.getConfigValue(context, HTTP_URL_KEY, defUrl);
//String url = "http://fdfs.speedata.cn:9989/group1/M00/00/05/rBGFrl3fdAKAVJwfMtSa9R18wLU139.zip"; //String url = "http://fdfs.speedata.cn:9989/group1/M00/00/05/rBGFrl3fdAKAVJwfMtSa9R18wLU139.zip";
//String url = "http://9.9.9.28:8088/files/update.zip"; //String url = "http://9.9.9.28:8088/files/update.zip";
String url = "https://y.qq.com/download/import/QQMusic-import-1.2.1.zip"; //String url = "https://y.qq.com/download/import/QQMusic-import-1.2.1.zip";
String url = "https://jojopublic.tinman.cn/cc/cc-admin/course/315865800920559616.html?fileName=1463_3337.zip&checksumV2=md5Hex%3D4e42b3aacae4756079f39bbce1295a63";
//String url = "https://gitee.com/huang-junhua/iptv/raw/master/guonei.m3u8"; //String url = "https://gitee.com/huang-junhua/iptv/raw/master/guonei.m3u8";
//String url = "http://v.kjjl100.com/kz/zx/cj/2020cjswxdb/1.mp4"; //String url = "http://v.kjjl100.com/kz/zx/cj/2020cjswxdb/1.mp4";
//String url = "https://static.runoob.com/images/demo/demo2.jpg"; //String url = "https://static.runoob.com/images/demo/demo2.jpg";

Loading…
Cancel
Save