laoyuyu 6 years ago
parent 97705701e4
commit ed0c98fd7e
  1. 17
      Aria/src/main/java/com/arialyy/aria/core/ConfigHelper.java
  2. 11
      Aria/src/main/java/com/arialyy/aria/core/common/ftp/AbsFtpInfoThread.java
  3. 8
      Aria/src/main/java/com/arialyy/aria/core/upload/BaseNormalTarget.java
  4. 2
      AriaAnnotations/src/main/java/com/arialyy/annotations/Download.java
  5. 46
      AriaCompiler/src/main/java/com/arialyy/compiler/EventProxyFiler.java
  6. 3
      DEV_LOG.md
  7. 2
      app/src/main/AndroidManifest.xml
  8. 5
      app/src/main/assets/aria_config.xml
  9. 2
      app/src/main/java/com/arialyy/simple/download/FtpDownloadActivity.java
  10. 17
      aria/src/main/java/com/arialyy/aria/core/Configuration.java

@ -77,6 +77,9 @@ class ConfigHelper extends DefaultHandler {
case "buffSize":
loadBuffSize(value);
break;
case "useBroadcast":
loadUseBroadcast(value);
break;
case "ca":
String caName = attributes.getValue("name");
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) {
if (mType == ConfigType.DOWNLOAD) {
mDownloadConfig.useBlock = checkBoolean(value) ? Boolean.valueOf(value) : false;

@ -45,8 +45,7 @@ import java.util.regex.Pattern;
import javax.net.ssl.SSLContext;
/**
* Created by Aria.Lao on 2017/7/25.
* 获取ftp文件夹信息
* Created by Aria.Lao on 2017/7/25. 获取ftp文件夹信息
*/
public abstract class AbsFtpInfoThread<ENTITY extends AbsEntity, TASK_ENTITY extends AbsTaskEntity<ENTITY>>
implements Runnable {
@ -285,13 +284,7 @@ public abstract class AbsFtpInfoThread<ENTITY extends AbsEntity, TASK_ENTITY ext
if (sslContext == null) {
sslContext = SSLContextUtil.getDefaultSLLContext(urlEntity.protocol);
}
//System.setProperty("jdk.tls.useExtendedMasterSecret", "false");
//FTPSClient client = new SSLSessionReuseFTPSClient(true, sslContext);
FTPSClient client = new FTPSClient(true, sslContext);
//Log.d(TAG, "session = " + client.getEnableSessionCreation());
temp = client;
temp = new FTPSClient(true, sslContext);
} else {
temp = new FTPClient();
}

@ -81,10 +81,10 @@ abstract class BaseNormalTarget<TARGET extends AbsUploadTarget>
mTaskEntity.save();
}
if (mTaskEntity.getUrlEntity() != null && mTaskEntity.getUrlEntity().isFtps) {
if (TextUtils.isEmpty(mTaskEntity.getUrlEntity().storePath)) {
ALog.e(TAG, "证书路径为空");
return false;
}
//if (TextUtils.isEmpty(mTaskEntity.getUrlEntity().storePath)) {
// ALog.e(TAG, "证书路径为空");
// return false;
//}
if (TextUtils.isEmpty(mTaskEntity.getUrlEntity().keyAlias)) {
ALog.e(TAG, "证书别名为空");
return false;

@ -25,7 +25,7 @@ import java.lang.annotation.Target;
* Aria下载事件被注解的方法中参数仅能有一个参数类型为{@link com.arialyy.aria.core.download.DownloadTask}
* <pre>
* <code>
* {@literal @}Download.onPre(DownloadUrl)
* {@literal @}Download.onPre
* protected void onPre(DownloadTask task) {
* mUpdateHandler.obtainMessage(DOWNLOAD_PRE, task.getDownloadEntity().getFileSize()).sendToTarget();
* }

@ -36,8 +36,7 @@ import javax.annotation.processing.Filer;
import javax.lang.model.element.Modifier;
/**
* Created by lyy on 2017/9/6.
* 任务事件代理文件
* Created by lyy on 2017/9/6. 任务事件代理文件
*
* <pre>
* <code>
@ -127,24 +126,13 @@ final class EventProxyFiler {
}
}
StringBuilder sb = new StringBuilder();
sb.append("Set<String> keys = keyMapping.get(\"")
.append(methodInfo.methodName)
.append("\");\n");
sb.append("if (keys != null) {\n\tif (keys.contains(task.getKey())) {\n")
.append("\t\tobj.")
.append(methodInfo.methodName)
.append("((")
.append(taskEnum.getClassName())
.append(")")
.append(callCode)
.append(");\n\t}\n} else {\n")
.append("\tobj.")
sb.append("obj.")
.append(methodInfo.methodName)
.append("((")
.append(taskEnum.getClassName())
.append(")")
.append(callCode)
.append(");\n}\n");
.append(");\n");
MethodSpec.Builder builder = MethodSpec.methodBuilder(annotation.getSimpleName())
.addModifiers(Modifier.PUBLIC)
@ -186,14 +174,6 @@ final class EventProxyFiler {
FieldSpec observerField = FieldSpec.builder(obj, "obj").addModifiers(Modifier.PRIVATE).build();
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()) {
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) {
// String str = null;
@ -249,8 +212,7 @@ final class EventProxyFiler {
// }
//}
MethodSpec structure =
MethodSpec.constructorBuilder().addModifiers(Modifier.PUBLIC).addCode(cb.build()).build();
MethodSpec structure = MethodSpec.constructorBuilder().addModifiers(Modifier.PUBLIC).build();
builder.addMethod(structure);
//添加设置代理的类

@ -1,4 +1,7 @@
## 开发日志
+ v_3.5.3
- 修复ftps不能加载默认证书的bug https://github.com/AriaLyy/Aria/issues/334
- 优化注解性能,移除不必要的判断代码
+ v_3.5.2
- 添加Serializable接口支持 https://github.com/AriaLyy/Aria/issues/320
- 失败回调增加错误原因 https://github.com/AriaLyy/Aria/issues/310

@ -20,7 +20,7 @@
<!--android:name=".download.group.DownloadGroupActivity"-->
<!--android:name=".MainActivity"-->
<activity
android:name=".download.SingleTaskActivity"
android:name=".test.AnyRunActivity"
android:label="@string/app_name">
<intent-filter>
<action android:name="android.intent.action.MAIN"/>

@ -66,6 +66,8 @@
<!--进度更新更新间隔,默认1000毫秒-->
<updateInterval value="1000"/>
<!--除非无法使用注解,否则不建议使用广播来接受任务状态,true:使用广播接收任务状态,false:不适用广播接收状态 -->
<useBroadcast value="false"/>
</download>
@ -101,6 +103,9 @@
<!--进度更新更新间隔,默认1000毫秒-->
<updateInterval value="1000"/>
<!--除非无法使用注解,否则不建议使用广播来接受任务状态,true:使用广播接收任务状态,false:不适用广播接收状态 -->
<useBroadcast value="false"/>
</upload>
</aria>

@ -60,8 +60,6 @@ public class FtpDownloadActivity extends BaseActivity<ActivityFtpDownloadBinding
switch (view.getId()) {
case R.id.start:
Aria.download(this).loadFtp(URL)
.login("sxf", "B34VdGsJ")
//.login("lao", "123456")
.login("lao", "123456")
.setFilePath("/mnt/sdcard/").start();
break;

@ -206,6 +206,23 @@ final class Configuration {
*/
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() {
return maxSpeed;
}

Loading…
Cancel
Save