Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
AriaLyy committed Feb 17, 2020
1 parent e015c2a commit 2f2d783
Show file tree
Hide file tree
Showing 8 changed files with 45 additions and 25 deletions.
5 changes: 4 additions & 1 deletion DEV_LOG.md
@@ -1,6 +1,9 @@
## 开发日志
+ v_3.8.6
+ v_3.8.6 (2020/2/17)
- fix bug https://github.com/AriaLyy/Aria/issues/608
- fix bug https://github.com/AriaLyy/Aria/issues/579#issuecomment-586665035
- fix bug https://github.com/AriaLyy/Aria/issues/610
- fix bug https://github.com/AriaLyy/Aria/issues/614
- 优化异常提示
+ v_3.8.5 (2020/1/18)
- fix bug https://github.com/AriaLyy/Aria/issues/599
Expand Down
Expand Up @@ -15,27 +15,17 @@
*/
package com.arialyy.aria.http.download;

import com.arialyy.aria.core.TaskRecord;
import com.arialyy.aria.core.common.SubThreadConfig;
import com.arialyy.aria.core.download.DTaskWrapper;
import com.arialyy.aria.core.listener.IEventListener;
import com.arialyy.aria.core.loader.AbsNormalLoader;
import com.arialyy.aria.core.loader.AbsNormalLoaderUtil;
import com.arialyy.aria.core.loader.AbsNormalTTBuilderAdapter;
import com.arialyy.aria.core.loader.IRecordHandler;
import com.arialyy.aria.core.loader.LoaderStructure;
import com.arialyy.aria.core.loader.NormalLoader;
import com.arialyy.aria.core.loader.NormalTTBuilder;
import com.arialyy.aria.core.loader.NormalThreadStateManager;
import com.arialyy.aria.core.task.IThreadTaskAdapter;
import com.arialyy.aria.core.wrapper.AbsTaskWrapper;
import com.arialyy.aria.http.HttpRecordHandler;
import com.arialyy.aria.http.HttpTaskOption;
import com.arialyy.aria.util.ALog;
import com.arialyy.aria.util.BufferedRandomAccessFile;
import com.arialyy.aria.util.FileUtil;
import java.io.File;
import java.io.IOException;

/**
* @Author lyy
Expand All @@ -60,6 +50,4 @@ public LoaderStructure BuildLoaderStructure() {
structure.accept(getLoader());
return structure;
}


}
Expand Up @@ -21,6 +21,7 @@
import android.net.ConnectivityManager;
import android.net.Network;
import android.net.NetworkCapabilities;
import android.net.NetworkInfo;
import android.net.NetworkRequest;
import android.os.Build;
import android.os.Handler;
Expand Down Expand Up @@ -120,6 +121,7 @@ public synchronized Handler getAriaHandler() {
* 注册网络监听,只有配置了检查网络{@link AppConfig#isNetCheck()}才会注册事件
*/
private void regNetCallBack(Context context) {
isConnectedNet = isNetworkAvailable();
if (!getAConfig().isNetCheck()) {
return;
}
Expand Down Expand Up @@ -155,6 +157,31 @@ private void regNetCallBack(Context context) {
}
}

public boolean isNetworkAvailable() {
// 获取手机所有连接管理对象(包括对wi-fi,net等连接的管理)
ConnectivityManager connectivityManager =
(ConnectivityManager) getAPP().getSystemService(Context.CONNECTIVITY_SERVICE);

if (connectivityManager == null) {

return false;
} else {
// 获取NetworkInfo对象
NetworkInfo[] networkInfo = connectivityManager.getAllNetworkInfo();

if (networkInfo != null && networkInfo.length > 0) {
for (NetworkInfo info : networkInfo) {
// 判断当前网络状态是否为连接状态
if (info.getState() == NetworkInfo.State.CONNECTED) {
return true;
}
}
}
}
return false;
}


public boolean isConnectedNet() {
return isConnectedNet;
}
Expand Down
Expand Up @@ -80,21 +80,21 @@ public M3U8Entity getM3U8Entity() {

@Override public int getTaskType() {
int type;
if (TextUtils.isEmpty(getUrl())) {
if (getUrl() == null){
type = ITaskWrapper.ERROR;
} else if (getUrl().startsWith("http")) {
type = ITaskWrapper.D_HTTP;
} else if (getUrl().startsWith("ftp")) {
type = ITaskWrapper.D_FTP;
} else if (getUrl().startsWith("sftp")) {
type = ITaskWrapper.D_SFTP;
} else {
M3U8Entity temp = getM3U8Entity();
if (temp == null) {
type = ITaskWrapper.D_HTTP;
} else {
type = temp.isLive() ? ITaskWrapper.M3U8_LIVE : ITaskWrapper.M3U8_VOD;
}
} else if (getUrl().startsWith("ftp")) {
type = ITaskWrapper.D_FTP;
} else if (getUrl().startsWith("sftp")) {
type = ITaskWrapper.D_SFTP;
} else {
type = ITaskWrapper.ERROR;
}
return type;
}
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/assets/aria_config.xml
Expand Up @@ -9,7 +9,7 @@
<!--设置Aria的日志级别,{@link ALog#LOG_LEVEL_VERBOSE}-->
<logLevel value="2"/>
<!-- 是否检查网络 true: 检查网络,false: 不检查网络-->
<netCheck value="false"/>
<netCheck value="true"/>
<!--除非无法使用注解,否则不建议使用广播来接受任务状态,true:使用广播接收任务状态,false:不适用广播接收状态 -->
<!-- http://aria.laoyuyu.me/aria_doc/api/use_broadcast.html -->
<useBroadcast value="false"/>
Expand Down
Expand Up @@ -59,6 +59,7 @@ LiveData<DownloadEntity> getHttpDownloadInfo(Context context) {
//String url = "https://ss1.baidu.com/-4o3dSag_xI4khGko9WTAnF6hhy/image/h%3D300/sign=a9e671b9a551f3dedcb2bf64a4eff0ec/4610b912c8fcc3cef70d70409845d688d53f20f7.jpg";
//String filePath = AppUtil.getConfigValue(context, HTTP_PATH_KEY, defFilePath);
String url = "https://y.qq.com/download/import/QQMusic-import-1.2.1.zip";
//String url = "http://donuts.aigauss.com/doc_fPhW2DBGj3_1578932414.png";
String filePath = "/mnt/sdcard/update.zip";
//String url = "https://dhfspace.360drm.com/1_12809_1543904946_VID_20180808_212829.vep?e=1578554567&token=gUBmfZgZS5wy4wdQIDZG8UVxlNCyVSjvksIb13K5:WYSZRgmLbH1_9hjgqOAGmqR27JM=";
//String filePath = "/mnt/sdcard/sssss.zip";
Expand All @@ -67,7 +68,7 @@ LiveData<DownloadEntity> getHttpDownloadInfo(Context context) {
if (singDownloadInfo == null) {
singDownloadInfo = new DownloadEntity();
singDownloadInfo.setUrl(url);
File file = new File(defFilePath);
File file = new File(filePath);
singDownloadInfo.setFilePath(filePath);
singDownloadInfo.setFileName(file.getName());
} else {
Expand Down
Expand Up @@ -269,7 +269,7 @@ void taskCancel(DownloadTask task) {

@Download.onTaskFail
void taskFail(DownloadTask task, Exception e) {
if (task.getKey().equals(mUrl)) {
if (task != null && task.getKey().equals(mUrl)) {
Toast.makeText(M3U8VodDLoadActivity.this, getString(R.string.download_fail),
Toast.LENGTH_SHORT)
.show();
Expand Down Expand Up @@ -330,7 +330,7 @@ static class VodTsUrlConverter implements IVodTsUrlConverter {
//String parentUrl = "http://" + uri.getHost() + "/gear1/";
int index = m3u8Url.lastIndexOf("/");
//String parentUrl = m3u8Url.substring(0, index + 1);
String parentUrl = "https://cn7.kankia.com/";
String parentUrl = "https://135zyv5.xw0371.com/2018/10/29/X05c7CG3VB91gi1M/";
//String parentUrl = "http://" + uri.getHost() + "/";
List<String> newUrls = new ArrayList<>();
for (String url : tsUrls) {
Expand Down
Expand Up @@ -35,9 +35,10 @@ public class M3U8VodModule extends BaseViewModule {
//private final String defUrl = "https://www.gaoya123.cn/2019/1557993797897.m3u8";
// 多码率地址:
//private final String defUrl = "http://devimages.apple.com/iphone/samples/bipbop/bipbopall.m3u8";
private final String defUrl = "https://cn7.kankia.com/hls/20200108/e1eaec074274c64fe46a3bdb5d2ba487/1578488360/index.m3u8";
//private final String defUrl = "https://cn7.kankia.com/hls/20200108/e1eaec074274c64fe46a3bdb5d2ba487/1578488360/index.m3u8";
//private final String defUrl = "https://youku.cdn7-okzy.com/20191213/16167_c3592a02/index.m3u8";
//private final String defUrl = "http://qn.shytong.cn/b83137769ff6b555/11b0c9970f9a3fa0.mp4.m3u8";
private final String defUrl = "https://135zyv5.xw0371.com/2018/10/29/X05c7CG3VB91gi1M/playlist.m3u8";
private final String filePath =
Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOWNLOADS).getPath()
//+ "/道士下山.ts";
Expand Down

0 comments on commit 2f2d783

Please sign in to comment.