This commit is contained in:
@@ -77,6 +77,9 @@ class ConfigHelper extends DefaultHandler {
|
|||||||
case "buffSize":
|
case "buffSize":
|
||||||
loadBuffSize(value);
|
loadBuffSize(value);
|
||||||
break;
|
break;
|
||||||
|
case "useBroadcast":
|
||||||
|
loadUseBroadcast(value);
|
||||||
|
break;
|
||||||
case "ca":
|
case "ca":
|
||||||
String caName = attributes.getValue("name");
|
String caName = attributes.getValue("name");
|
||||||
String caPath = attributes.getValue("path");
|
String caPath = attributes.getValue("path");
|
||||||
@@ -114,6 +117,20 @@ class ConfigHelper extends DefaultHandler {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void loadUseBroadcast(String value) {
|
||||||
|
boolean b = checkBoolean(value), temp = false;
|
||||||
|
|
||||||
|
if (b) {
|
||||||
|
temp = Boolean.valueOf(value);
|
||||||
|
}
|
||||||
|
if (mType == ConfigType.DOWNLOAD) {
|
||||||
|
mDownloadConfig.useBroadcast = temp;
|
||||||
|
}
|
||||||
|
if (mType == ConfigType.UPLOAD) {
|
||||||
|
mUploadConfig.useBroadcast = temp;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private void loadUseBlock(String value) {
|
private void loadUseBlock(String value) {
|
||||||
if (mType == ConfigType.DOWNLOAD) {
|
if (mType == ConfigType.DOWNLOAD) {
|
||||||
mDownloadConfig.useBlock = checkBoolean(value) ? Boolean.valueOf(value) : false;
|
mDownloadConfig.useBlock = checkBoolean(value) ? Boolean.valueOf(value) : false;
|
||||||
|
|||||||
@@ -45,8 +45,7 @@ import java.util.regex.Pattern;
|
|||||||
import javax.net.ssl.SSLContext;
|
import javax.net.ssl.SSLContext;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by Aria.Lao on 2017/7/25.
|
* Created by Aria.Lao on 2017/7/25. 获取ftp文件夹信息
|
||||||
* 获取ftp文件夹信息
|
|
||||||
*/
|
*/
|
||||||
public abstract class AbsFtpInfoThread<ENTITY extends AbsEntity, TASK_ENTITY extends AbsTaskEntity<ENTITY>>
|
public abstract class AbsFtpInfoThread<ENTITY extends AbsEntity, TASK_ENTITY extends AbsTaskEntity<ENTITY>>
|
||||||
implements Runnable {
|
implements Runnable {
|
||||||
@@ -285,13 +284,7 @@ public abstract class AbsFtpInfoThread<ENTITY extends AbsEntity, TASK_ENTITY ext
|
|||||||
if (sslContext == null) {
|
if (sslContext == null) {
|
||||||
sslContext = SSLContextUtil.getDefaultSLLContext(urlEntity.protocol);
|
sslContext = SSLContextUtil.getDefaultSLLContext(urlEntity.protocol);
|
||||||
}
|
}
|
||||||
//System.setProperty("jdk.tls.useExtendedMasterSecret", "false");
|
temp = new FTPSClient(true, sslContext);
|
||||||
//FTPSClient client = new SSLSessionReuseFTPSClient(true, sslContext);
|
|
||||||
|
|
||||||
FTPSClient client = new FTPSClient(true, sslContext);
|
|
||||||
//Log.d(TAG, "session = " + client.getEnableSessionCreation());
|
|
||||||
|
|
||||||
temp = client;
|
|
||||||
} else {
|
} else {
|
||||||
temp = new FTPClient();
|
temp = new FTPClient();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -81,10 +81,10 @@ abstract class BaseNormalTarget<TARGET extends AbsUploadTarget>
|
|||||||
mTaskEntity.save();
|
mTaskEntity.save();
|
||||||
}
|
}
|
||||||
if (mTaskEntity.getUrlEntity() != null && mTaskEntity.getUrlEntity().isFtps) {
|
if (mTaskEntity.getUrlEntity() != null && mTaskEntity.getUrlEntity().isFtps) {
|
||||||
if (TextUtils.isEmpty(mTaskEntity.getUrlEntity().storePath)) {
|
//if (TextUtils.isEmpty(mTaskEntity.getUrlEntity().storePath)) {
|
||||||
ALog.e(TAG, "证书路径为空");
|
// ALog.e(TAG, "证书路径为空");
|
||||||
return false;
|
// return false;
|
||||||
}
|
//}
|
||||||
if (TextUtils.isEmpty(mTaskEntity.getUrlEntity().keyAlias)) {
|
if (TextUtils.isEmpty(mTaskEntity.getUrlEntity().keyAlias)) {
|
||||||
ALog.e(TAG, "证书别名为空");
|
ALog.e(TAG, "证书别名为空");
|
||||||
return false;
|
return false;
|
||||||
|
|||||||
@@ -25,7 +25,7 @@ import java.lang.annotation.Target;
|
|||||||
* Aria下载事件被注解的方法中,参数仅能有一个,参数类型为{@link com.arialyy.aria.core.download.DownloadTask}
|
* Aria下载事件被注解的方法中,参数仅能有一个,参数类型为{@link com.arialyy.aria.core.download.DownloadTask}
|
||||||
* <pre>
|
* <pre>
|
||||||
* <code>
|
* <code>
|
||||||
* {@literal @}Download.onPre(DownloadUrl)
|
* {@literal @}Download.onPre
|
||||||
* protected void onPre(DownloadTask task) {
|
* protected void onPre(DownloadTask task) {
|
||||||
* mUpdateHandler.obtainMessage(DOWNLOAD_PRE, task.getDownloadEntity().getFileSize()).sendToTarget();
|
* mUpdateHandler.obtainMessage(DOWNLOAD_PRE, task.getDownloadEntity().getFileSize()).sendToTarget();
|
||||||
* }
|
* }
|
||||||
|
|||||||
@@ -36,8 +36,7 @@ import javax.annotation.processing.Filer;
|
|||||||
import javax.lang.model.element.Modifier;
|
import javax.lang.model.element.Modifier;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by lyy on 2017/9/6.
|
* Created by lyy on 2017/9/6. 任务事件代理文件
|
||||||
* 任务事件代理文件
|
|
||||||
*
|
*
|
||||||
* <pre>
|
* <pre>
|
||||||
* <code>
|
* <code>
|
||||||
@@ -127,24 +126,13 @@ final class EventProxyFiler {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
StringBuilder sb = new StringBuilder();
|
StringBuilder sb = new StringBuilder();
|
||||||
sb.append("Set<String> keys = keyMapping.get(\"")
|
sb.append("obj.")
|
||||||
.append(methodInfo.methodName)
|
|
||||||
.append("\");\n");
|
|
||||||
sb.append("if (keys != null) {\n\tif (keys.contains(task.getKey())) {\n")
|
|
||||||
.append("\t\tobj.")
|
|
||||||
.append(methodInfo.methodName)
|
.append(methodInfo.methodName)
|
||||||
.append("((")
|
.append("((")
|
||||||
.append(taskEnum.getClassName())
|
.append(taskEnum.getClassName())
|
||||||
.append(")")
|
.append(")")
|
||||||
.append(callCode)
|
.append(callCode)
|
||||||
.append(");\n\t}\n} else {\n")
|
.append(");\n");
|
||||||
.append("\tobj.")
|
|
||||||
.append(methodInfo.methodName)
|
|
||||||
.append("((")
|
|
||||||
.append(taskEnum.getClassName())
|
|
||||||
.append(")")
|
|
||||||
.append(callCode)
|
|
||||||
.append(");\n}\n");
|
|
||||||
|
|
||||||
MethodSpec.Builder builder = MethodSpec.methodBuilder(annotation.getSimpleName())
|
MethodSpec.Builder builder = MethodSpec.methodBuilder(annotation.getSimpleName())
|
||||||
.addModifiers(Modifier.PUBLIC)
|
.addModifiers(Modifier.PUBLIC)
|
||||||
@@ -186,14 +174,6 @@ final class EventProxyFiler {
|
|||||||
FieldSpec observerField = FieldSpec.builder(obj, "obj").addModifiers(Modifier.PRIVATE).build();
|
FieldSpec observerField = FieldSpec.builder(obj, "obj").addModifiers(Modifier.PRIVATE).build();
|
||||||
builder.addField(observerField);
|
builder.addField(observerField);
|
||||||
|
|
||||||
//添加url映射表
|
|
||||||
FieldSpec mappingField = FieldSpec.builder(
|
|
||||||
ParameterizedTypeName.get(ClassName.get(Map.class), ClassName.get(String.class),
|
|
||||||
ParameterizedTypeName.get(ClassName.get(Set.class), ClassName.get(String.class))),
|
|
||||||
"keyMapping").addModifiers(Modifier.PRIVATE).initializer("new $T()", HashMap.class).build();
|
|
||||||
builder.addField(mappingField);
|
|
||||||
|
|
||||||
//Set<Integer> type = new HashSet<>();
|
|
||||||
//添加注解方法
|
//添加注解方法
|
||||||
for (TaskEnum te : entity.methods.keySet()) {
|
for (TaskEnum te : entity.methods.keySet()) {
|
||||||
Map<Class<? extends Annotation>, MethodInfo> methodInfoMap = entity.methods.get(te);
|
Map<Class<? extends Annotation>, MethodInfo> methodInfoMap = entity.methods.get(te);
|
||||||
@@ -214,23 +194,6 @@ final class EventProxyFiler {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//增加构造函数
|
|
||||||
CodeBlock.Builder cb = CodeBlock.builder();
|
|
||||||
cb.add("Set<String> set = null;\n");
|
|
||||||
for (String methodName : entity.keyMappings.keySet()) {
|
|
||||||
//PrintLog.getInstance().info("methodName ====> " + methodName);
|
|
||||||
Set<String> keys = entity.keyMappings.get(methodName);
|
|
||||||
if (keys == null || keys.size() == 0) continue;
|
|
||||||
StringBuilder sb = new StringBuilder();
|
|
||||||
sb.append("set = new $T();\n");
|
|
||||||
for (String key : keys) {
|
|
||||||
if (key.isEmpty()) continue;
|
|
||||||
sb.append("set.add(\"").append(key).append("\");\n");
|
|
||||||
}
|
|
||||||
|
|
||||||
sb.append("keyMapping.put(\"").append(methodName).append("\", ").append("set);\n");
|
|
||||||
cb.add(sb.toString(), ClassName.get(HashSet.class));
|
|
||||||
}
|
|
||||||
//注册当前类
|
//注册当前类
|
||||||
//for (Integer i : type) {
|
//for (Integer i : type) {
|
||||||
// String str = null;
|
// String str = null;
|
||||||
@@ -249,8 +212,7 @@ final class EventProxyFiler {
|
|||||||
// }
|
// }
|
||||||
//}
|
//}
|
||||||
|
|
||||||
MethodSpec structure =
|
MethodSpec structure = MethodSpec.constructorBuilder().addModifiers(Modifier.PUBLIC).build();
|
||||||
MethodSpec.constructorBuilder().addModifiers(Modifier.PUBLIC).addCode(cb.build()).build();
|
|
||||||
builder.addMethod(structure);
|
builder.addMethod(structure);
|
||||||
|
|
||||||
//添加设置代理的类
|
//添加设置代理的类
|
||||||
|
|||||||
@@ -1,4 +1,7 @@
|
|||||||
## 开发日志
|
## 开发日志
|
||||||
|
+ v_3.5.3
|
||||||
|
- 修复ftps不能加载默认证书的bug https://github.com/AriaLyy/Aria/issues/334
|
||||||
|
- 优化注解性能,移除不必要的判断代码
|
||||||
+ v_3.5.2
|
+ v_3.5.2
|
||||||
- 添加Serializable接口支持 https://github.com/AriaLyy/Aria/issues/320
|
- 添加Serializable接口支持 https://github.com/AriaLyy/Aria/issues/320
|
||||||
- 失败回调增加错误原因 https://github.com/AriaLyy/Aria/issues/310
|
- 失败回调增加错误原因 https://github.com/AriaLyy/Aria/issues/310
|
||||||
|
|||||||
@@ -20,7 +20,7 @@
|
|||||||
<!--android:name=".download.group.DownloadGroupActivity"-->
|
<!--android:name=".download.group.DownloadGroupActivity"-->
|
||||||
<!--android:name=".MainActivity"-->
|
<!--android:name=".MainActivity"-->
|
||||||
<activity
|
<activity
|
||||||
android:name=".download.SingleTaskActivity"
|
android:name=".test.AnyRunActivity"
|
||||||
android:label="@string/app_name">
|
android:label="@string/app_name">
|
||||||
<intent-filter>
|
<intent-filter>
|
||||||
<action android:name="android.intent.action.MAIN"/>
|
<action android:name="android.intent.action.MAIN"/>
|
||||||
|
|||||||
@@ -66,6 +66,8 @@
|
|||||||
|
|
||||||
<!--进度更新更新间隔,默认1000毫秒-->
|
<!--进度更新更新间隔,默认1000毫秒-->
|
||||||
<updateInterval value="1000"/>
|
<updateInterval value="1000"/>
|
||||||
|
<!--除非无法使用注解,否则不建议使用广播来接受任务状态,true:使用广播接收任务状态,false:不适用广播接收状态 -->
|
||||||
|
<useBroadcast value="false"/>
|
||||||
|
|
||||||
</download>
|
</download>
|
||||||
|
|
||||||
@@ -101,6 +103,9 @@
|
|||||||
|
|
||||||
<!--进度更新更新间隔,默认1000毫秒-->
|
<!--进度更新更新间隔,默认1000毫秒-->
|
||||||
<updateInterval value="1000"/>
|
<updateInterval value="1000"/>
|
||||||
|
|
||||||
|
<!--除非无法使用注解,否则不建议使用广播来接受任务状态,true:使用广播接收任务状态,false:不适用广播接收状态 -->
|
||||||
|
<useBroadcast value="false"/>
|
||||||
</upload>
|
</upload>
|
||||||
|
|
||||||
</aria>
|
</aria>
|
||||||
@@ -60,8 +60,6 @@ public class FtpDownloadActivity extends BaseActivity<ActivityFtpDownloadBinding
|
|||||||
switch (view.getId()) {
|
switch (view.getId()) {
|
||||||
case R.id.start:
|
case R.id.start:
|
||||||
Aria.download(this).loadFtp(URL)
|
Aria.download(this).loadFtp(URL)
|
||||||
.login("sxf", "B34VdGsJ")
|
|
||||||
//.login("lao", "123456")
|
|
||||||
.login("lao", "123456")
|
.login("lao", "123456")
|
||||||
.setFilePath("/mnt/sdcard/").start();
|
.setFilePath("/mnt/sdcard/").start();
|
||||||
break;
|
break;
|
||||||
|
|||||||
@@ -206,6 +206,23 @@ final class Configuration {
|
|||||||
*/
|
*/
|
||||||
int maxSpeed = 0;
|
int maxSpeed = 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 是否使用广播
|
||||||
|
* 除非无法使用注解,否则不建议使用广播来接受任务
|
||||||
|
* {@code true} 使用广播,{@code false} 不适用广播
|
||||||
|
*/
|
||||||
|
boolean useBroadcast = false;
|
||||||
|
|
||||||
|
public boolean isUseBroadcast() {
|
||||||
|
return useBroadcast;
|
||||||
|
}
|
||||||
|
|
||||||
|
public BaseTaskConfig setUseBroadcast(boolean useBroadcast) {
|
||||||
|
this.useBroadcast = useBroadcast;
|
||||||
|
save();
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
public int getMaxSpeed() {
|
public int getMaxSpeed() {
|
||||||
return maxSpeed;
|
return maxSpeed;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user