This commit is contained in:
2
FtpComponent/src/main/resources/META-INF/MANIFEST.MF
Normal file
2
FtpComponent/src/main/resources/META-INF/MANIFEST.MF
Normal file
@@ -0,0 +1,2 @@
|
||||
Manifest-Version: 1.0
|
||||
|
||||
2
HttpComponent/src/main/resources/META-INF/MANIFEST.MF
Normal file
2
HttpComponent/src/main/resources/META-INF/MANIFEST.MF
Normal file
@@ -0,0 +1,2 @@
|
||||
Manifest-Version: 1.0
|
||||
|
||||
2
M3U8Component/src/main/resources/META-INF/MANIFEST.MF
Normal file
2
M3U8Component/src/main/resources/META-INF/MANIFEST.MF
Normal file
@@ -0,0 +1,2 @@
|
||||
Manifest-Version: 1.0
|
||||
|
||||
@@ -32,7 +32,7 @@ import java.util.ServiceLoader;
|
||||
* 参考{@link ServiceLoader}
|
||||
*/
|
||||
public class AriaServiceLoader<S> {
|
||||
|
||||
private static final String TAG = "AriaServiceLoader";
|
||||
private static final String PREFIX = "META-INF/services/";
|
||||
|
||||
// The class or interface representing the service being loaded
|
||||
@@ -177,6 +177,10 @@ public class AriaServiceLoader<S> {
|
||||
}
|
||||
|
||||
private S loadService(String serviceName) {
|
||||
if (pending == null){
|
||||
ALog.e(TAG, "pending为空");
|
||||
return null;
|
||||
}
|
||||
for (String s : pending) {
|
||||
if (s.equals(serviceName)) {
|
||||
Class<?> c = null;
|
||||
|
||||
@@ -24,9 +24,11 @@ import com.arialyy.aria.core.listener.IEventListener;
|
||||
import com.arialyy.aria.core.task.AbsTask;
|
||||
import com.arialyy.aria.core.wrapper.AbsTaskWrapper;
|
||||
import com.arialyy.aria.core.wrapper.ITaskWrapper;
|
||||
import com.arialyy.aria.exception.AriaComponentException;
|
||||
import java.lang.ref.SoftReference;
|
||||
import java.lang.reflect.Constructor;
|
||||
import java.lang.reflect.Field;
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
@@ -43,12 +45,9 @@ public class ComponentUtil {
|
||||
|
||||
private String TAG = CommonUtil.getClassName(getClass());
|
||||
private static volatile ComponentUtil INSTANCE = null;
|
||||
private AriaServiceLoader<IUtil> utilLoader;
|
||||
private AriaServiceLoader<IEventListener> listenerLoader;
|
||||
|
||||
private ComponentUtil() {
|
||||
utilLoader = AriaServiceLoader.load(IUtil.class);
|
||||
listenerLoader = AriaServiceLoader.load(IEventListener.class);
|
||||
|
||||
}
|
||||
|
||||
public static ComponentUtil getInstance() {
|
||||
@@ -105,7 +104,8 @@ public class ComponentUtil {
|
||||
*
|
||||
* @return 返回任务工具
|
||||
*/
|
||||
public synchronized IUtil buildUtil(AbsTaskWrapper wrapper, IEventListener listener) {
|
||||
public synchronized <T extends IUtil> T buildUtil(AbsTaskWrapper wrapper,
|
||||
IEventListener listener) {
|
||||
int requestType = wrapper.getRequestType();
|
||||
String className = null;
|
||||
switch (requestType) {
|
||||
@@ -140,11 +140,30 @@ public class ComponentUtil {
|
||||
className = "com.arialyy.aria.sftp.upload.SFtpULoaderUtil";
|
||||
break;
|
||||
}
|
||||
IUtil util = utilLoader.getService(className);
|
||||
if (util == null) {
|
||||
throw new AriaComponentException("加载工具异常,请求类型:" + wrapper.getRequestType());
|
||||
if (className == null) {
|
||||
ALog.e(TAG, "不识别的类名:" + className);
|
||||
return null;
|
||||
}
|
||||
return util.setParams(wrapper, listener);
|
||||
T util = null;
|
||||
try {
|
||||
Class<T> clazz = (Class<T>) getClass().getClassLoader().loadClass(className);
|
||||
Constructor<T> con = clazz.getConstructor();
|
||||
util = con.newInstance();
|
||||
Method method =
|
||||
CommonUtil.getMethod(clazz, "setParams", AbsTaskWrapper.class, IEventListener.class);
|
||||
method.invoke(util, wrapper, listener);
|
||||
} catch (ClassNotFoundException e) {
|
||||
e.printStackTrace();
|
||||
} catch (NoSuchMethodException e) {
|
||||
e.printStackTrace();
|
||||
} catch (IllegalAccessException e) {
|
||||
e.printStackTrace();
|
||||
} catch (InstantiationException e) {
|
||||
e.printStackTrace();
|
||||
} catch (InvocationTargetException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return util;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -153,7 +172,7 @@ public class ComponentUtil {
|
||||
* @param wrapperType 任务类型{@link ITaskWrapper}
|
||||
* @return 返回事件监听,如果创建失败返回null
|
||||
*/
|
||||
public synchronized IEventListener buildListener(int wrapperType, AbsTask task,
|
||||
public synchronized <T extends IEventListener> T buildListener(int wrapperType, AbsTask task,
|
||||
Handler outHandler) {
|
||||
String className = null, errorStr = "请添加FTP插件";
|
||||
switch (wrapperType) {
|
||||
@@ -180,12 +199,26 @@ public class ComponentUtil {
|
||||
if (className == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
IEventListener listener = listenerLoader.getService(className);
|
||||
if (listener == null) {
|
||||
throw new AriaComponentException(errorStr);
|
||||
T listener = null;
|
||||
try {
|
||||
Class<T> clazz = (Class<T>) getClass().getClassLoader().loadClass(className);
|
||||
Constructor<T> con = clazz.getConstructor();
|
||||
listener = con.newInstance();
|
||||
Method method =
|
||||
CommonUtil.getMethod(clazz, "setParams", AbsTask.class, Handler.class);
|
||||
method.invoke(listener, task, outHandler);
|
||||
} catch (ClassNotFoundException e) {
|
||||
throw new IllegalArgumentException(errorStr);
|
||||
} catch (NoSuchMethodException e) {
|
||||
e.printStackTrace();
|
||||
} catch (IllegalAccessException e) {
|
||||
e.printStackTrace();
|
||||
} catch (InstantiationException e) {
|
||||
e.printStackTrace();
|
||||
} catch (InvocationTargetException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return listener.setParams(task, outHandler);
|
||||
return listener;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
2
PublicComponent/src/main/resources/META-INF/MANIFEST.MF
Normal file
2
PublicComponent/src/main/resources/META-INF/MANIFEST.MF
Normal file
@@ -0,0 +1,2 @@
|
||||
Manifest-Version: 1.0
|
||||
|
||||
2
SFtpComponent/src/main/resources/META-INF/MANIFEST.MF
Normal file
2
SFtpComponent/src/main/resources/META-INF/MANIFEST.MF
Normal file
@@ -0,0 +1,2 @@
|
||||
Manifest-Version: 1.0
|
||||
|
||||
@@ -31,8 +31,9 @@ android {
|
||||
|
||||
buildTypes {
|
||||
release {
|
||||
minifyEnabled false
|
||||
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
|
||||
zipAlignEnabled true
|
||||
minifyEnabled true
|
||||
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
|
||||
signingConfig signingConfigs.release
|
||||
}
|
||||
}
|
||||
@@ -43,6 +44,7 @@ android {
|
||||
|
||||
packagingOptions {
|
||||
exclude 'META-INF/services/javax.annotation.processing.Processor'
|
||||
merge 'META-INF/services/com.arialyy.aria.core.inf.IUtil'
|
||||
}
|
||||
|
||||
lintOptions {
|
||||
@@ -61,6 +63,7 @@ dependencies {
|
||||
androidTestImplementation 'androidx.test:runner:1.2.0'
|
||||
androidTestImplementation 'androidx.test.ext:junit:1.1.1'
|
||||
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
|
||||
implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-android:1.3.0'
|
||||
|
||||
implementation 'androidx.cardview:cardview:1.0.0'
|
||||
implementation 'com.google.android.material:material:1.0.0'
|
||||
@@ -70,16 +73,23 @@ dependencies {
|
||||
implementation 'com.github.bumptech.glide:glide:3.7.0'
|
||||
implementation 'com.pddstudio:highlightjs-android:1.5.0'
|
||||
implementation 'org.greenrobot:eventbus:3.1.1'
|
||||
implementation project(':AppFrame')
|
||||
|
||||
// aria
|
||||
kapt project(':AriaCompiler')
|
||||
implementation project(':Aria')
|
||||
implementation project(':AppFrame')
|
||||
implementation project(':M3U8Component')
|
||||
implementation project(':FtpComponent')
|
||||
implementation project(path: ':AriaAnnotations')
|
||||
implementation project(path: ':SFtpComponent')
|
||||
|
||||
|
||||
// implementation 'com.arialyy.aria:core:3.8.12'
|
||||
// kapt 'com.arialyy.aria:compiler:3.8.12'
|
||||
// implementation 'com.arialyy.aria:ftpComponent:3.8.12' // 如果需要使用ftp,请增加该组件
|
||||
// implementation 'com.arialyy.aria:sftpComponent:3.8.12' // 如果需要使用ftp,请增加该组件
|
||||
// implementation 'com.arialyy.aria:m3u8Component:3.8.12' // 如果需要使用m3u8下载功能,请增加该组件
|
||||
|
||||
debugImplementation 'com.amitshekhar.android:debug-db:1.0.6'
|
||||
}
|
||||
repositories {
|
||||
|
||||
135
app/proguard-rules.pro
vendored
Normal file
135
app/proguard-rules.pro
vendored
Normal file
@@ -0,0 +1,135 @@
|
||||
# Add project specific ProGuard rules here.
|
||||
# You can control the set of applied configuration files using the
|
||||
# proguardFiles setting in build.gradle.
|
||||
#
|
||||
# For more details, see
|
||||
# http://developer.android.com/guide/developing/tools/proguard.html
|
||||
|
||||
# If your project uses WebView with JS, uncomment the following
|
||||
# and specify the fully qualified class name to the JavaScript interface
|
||||
# class:
|
||||
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
|
||||
# public *;
|
||||
#}
|
||||
|
||||
# Uncomment this to preserve the line number information for
|
||||
# debugging stack traces.
|
||||
#-keepattributes SourceFile,LineNumberTable
|
||||
|
||||
# If you keep the line number information, uncomment this to
|
||||
# hide the original source file name.
|
||||
#-renamesourcefileattribute SourceFile
|
||||
|
||||
################################### 混淆配置 start ###########################################
|
||||
#指定代码的压缩级别
|
||||
-optimizationpasses 1
|
||||
#包明不混合大小写
|
||||
-dontusemixedcaseclassnames
|
||||
#不去忽略非公共的库类
|
||||
-dontskipnonpubliclibraryclasses
|
||||
#优化 不优化输入的类文件
|
||||
-dontoptimize
|
||||
#预校验
|
||||
-dontpreverify
|
||||
#混淆时是否记录日志
|
||||
-verbose
|
||||
# 混淆时所采用的算法
|
||||
#-optimizations !code/simplification/arithmetic,!code/simplification/cast,!field/*,!class/merging/*
|
||||
-optimizations !code/simplification/cast,!field/*,!class/merging/*
|
||||
#-optimizations !code/simplification/arithmetic,!field/*,!class/merging/*
|
||||
#忽略警告
|
||||
#-ignorewarning
|
||||
################################### 混淆配置 end ############################################
|
||||
|
||||
|
||||
################## 记录生成的日志数据,gradle build时在本项目根目录输出 #################
|
||||
####### 输出文件夹 build/outputs/mapping
|
||||
#apk 包内所有 class 的内部结构
|
||||
-dump build/outputs/mapping/class_files.txt
|
||||
#未混淆的类和成员
|
||||
-printseeds build/outputs/mapping/kpa_seeds.txt
|
||||
#列出从 apk 中删除的代码
|
||||
-printusage build/outputs/mapping/kpa_unused.txt
|
||||
#混淆前后的映射
|
||||
-printmapping build/outputs/mapping/kpa_mapping.txt
|
||||
################## 记录生成的日志数据,gradle build时 在本项目根目录输出-end #################
|
||||
|
||||
################## 常用属性配置-start ##################
|
||||
# 保护注解
|
||||
-keepattributes *Annotation*
|
||||
# 保护support v4 包
|
||||
-dontwarn android.support.v4.app.**
|
||||
-keep class android.support.v4.app.**{ *; }
|
||||
# 保护andorid x
|
||||
-keep class com.google.android.material.** {*;}
|
||||
-keep class androidx.** {*;}
|
||||
-keep public class * extends androidx.**
|
||||
-keep interface androidx.** {*;}
|
||||
-dontwarn com.google.android.material.**
|
||||
-dontnote com.google.android.material.**
|
||||
-dontwarn androidx.**
|
||||
# 保护一些奇葩的问题
|
||||
-dontwarn org.xmlpull.v1.XmlPullParser
|
||||
-dontwarn org.xmlpull.v1.XmlSerializer
|
||||
-keep class org.xmlpull.v1.* {*;}
|
||||
|
||||
# 保护JS接口
|
||||
-keepclassmembers class * {
|
||||
@android.webkit.JavascriptInterface <methods>;
|
||||
}
|
||||
##保持 native 方法不被混淆
|
||||
-keepclasseswithmembernames class * {
|
||||
native <methods>;
|
||||
}
|
||||
##保持 Parcelable 不被混淆
|
||||
-keep class * implements android.os.Parcelable {
|
||||
public static final android.os.Parcelable$Creator *;
|
||||
}
|
||||
##保持 Serializable 不被混淆
|
||||
-keepnames class * implements java.io.Serializable
|
||||
#
|
||||
#保持 Serializable 不被混淆并且enum 类也不被混淆
|
||||
-keepclassmembers class * implements java.io.Serializable {
|
||||
static final long serialVersionUID;
|
||||
private static final java.io.ObjectStreamField[] serialPersistentFields;
|
||||
private void writeObject(java.io.ObjectOutputStream);
|
||||
private void readObject(java.io.ObjectInputStream);
|
||||
java.lang.Object writeReplace();
|
||||
java.lang.Object readResolve();
|
||||
}
|
||||
#避免混淆泛型 如果混淆报错建议关掉
|
||||
#–keepattributes Signature
|
||||
# webview + js
|
||||
-keepattributes *JavascriptInterface*
|
||||
|
||||
################## 常用属性配置-end ##################
|
||||
|
||||
################## kotlin-start ##################
|
||||
-keep class kotlin.** { *; }
|
||||
-keep class kotlin.Metadata { *; }
|
||||
-dontwarn kotlin.**
|
||||
-keepclassmembers class **$WhenMappings {
|
||||
<fields>;
|
||||
}
|
||||
-keepclassmembers class kotlin.Metadata {
|
||||
public <methods>;
|
||||
}
|
||||
-assumenosideeffects class kotlin.jvm.internal.Intrinsics {
|
||||
static void checkParameterIsNotNull(java.lang.Object, java.lang.String);
|
||||
}
|
||||
################## kotlin-end ##################
|
||||
|
||||
-dontwarn com.arialyy.aria.**
|
||||
-keep class com.arialyy.aria.**{*;}
|
||||
-keep class **$$DownloadListenerProxy{ *; }
|
||||
-keep class **$$UploadListenerProxy{ *; }
|
||||
-keep class **$$DownloadGroupListenerProxy{ *; }
|
||||
-keep class **$$DGSubListenerProxy{ *; }
|
||||
-keepclasseswithmembernames class * {
|
||||
@Download.* <methods>;
|
||||
@Upload.* <methods>;
|
||||
@DownloadGroup.* <methods>;
|
||||
}
|
||||
-keep class com.arialyy.aria.ftp.download.FtpDLoaderUtil{*;}
|
||||
-adaptresourcefilenames **.IUtil
|
||||
-adaptresourcefilecontents **.IUtil
|
||||
@@ -35,12 +35,14 @@ import com.arialyy.aria.core.common.AbsEntity;
|
||||
import com.arialyy.aria.core.common.HttpOption;
|
||||
import com.arialyy.aria.core.download.DownloadEntity;
|
||||
import com.arialyy.aria.core.download.DownloadTaskListener;
|
||||
import com.arialyy.aria.core.download.target.HttpNormalTarget;
|
||||
import com.arialyy.aria.core.listener.ISchedulers;
|
||||
import com.arialyy.aria.core.processor.IHttpFileLenAdapter;
|
||||
import com.arialyy.aria.core.scheduler.NormalTaskListenerInterface;
|
||||
import com.arialyy.aria.core.task.DownloadTask;
|
||||
import com.arialyy.aria.util.ALog;
|
||||
import com.arialyy.aria.util.CommonUtil;
|
||||
import com.arialyy.aria.util.FileUtil;
|
||||
import com.arialyy.frame.util.show.T;
|
||||
import com.arialyy.simple.R;
|
||||
import com.arialyy.simple.base.BaseActivity;
|
||||
@@ -120,6 +122,25 @@ public class SingleTaskActivity extends BaseActivity<ActivitySingleBinding> {
|
||||
|
||||
@Override public void cancel(View v, AbsEntity entity) {
|
||||
Aria.download(this).load(mTaskId).cancel(false);
|
||||
// //1. 删除本地文件目录
|
||||
// File localDirFile = new File(mFilePath);
|
||||
// if (localDirFile.exists()) {
|
||||
// FileUtil.deleteDir(localDirFile.getParentFile());
|
||||
// }
|
||||
//
|
||||
// //2. 删除记录
|
||||
// HttpNormalTarget target = Aria.download(SingleTaskActivity.this).load(mTaskId);
|
||||
// if (target != null) {
|
||||
// // target.cancel();
|
||||
// target.removeRecord();
|
||||
// }
|
||||
//
|
||||
// List<DownloadEntity> notCompleteTask = Aria.download(SingleTaskActivity.this).getAllNotCompleteTask();
|
||||
// if (notCompleteTask == null){
|
||||
// Log.d(TAG, "未完成的任务数:0");
|
||||
// return;
|
||||
// }
|
||||
// Log.d(TAG, "未完成的任务数:" + notCompleteTask.size());
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@@ -314,7 +314,7 @@ public class M3U8VodDLoadActivity extends BaseActivity<ActivityM3u8VodBinding> {
|
||||
option.generateIndexFile();
|
||||
//option.setKeyUrlConverter(new KeyUrlConverter());
|
||||
//option.setVodTsUrlConvert(new VodTsUrlConverter());
|
||||
//option.setBandWidthUrlConverter(new BandWidthUrlConverter());
|
||||
option.setBandWidthUrlConverter(new BandWidthUrlConverter());
|
||||
//option.setUseDefConvert(true);
|
||||
return option;
|
||||
}
|
||||
|
||||
@@ -34,8 +34,8 @@ public class M3U8VodModule extends BaseViewModule {
|
||||
// m3u8测试集合:http://www.voidcn.com/article/p-snaliarm-ct.html
|
||||
//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 = "http://pp3zvsk2n.bkt.clouddn.com/20200806/sd/15967206011811803/38475fadd55e4ecea3.m3u8";
|
||||
private final String defUrl = "http://devimages.apple.com/iphone/samples/bipbop/bipbopall.m3u8";
|
||||
//private final String defUrl = "http://pp3zvsk2n.bkt.clouddn.com/20200806/sd/15967206011811803/38475fadd55e4ecea3.m3u8";
|
||||
//private final String defUrl = "http://youku.cdn7-okzy.com/20200123/16815_fbe419ed/index.m3u8";
|
||||
|
||||
//private final String defUrl = "https://cn7.kankia.com/hls/20200108/e1eaec074274c64fe46a3bdb5d2ba487/1578488360/index.m3u8";
|
||||
|
||||
Reference in New Issue
Block a user