Permalink
Browse files

fix bug #334

  • Loading branch information...
AriaLyy committed Dec 3, 2018
1 parent 9770570 commit ed0c98fd7e14cfeb1e1ef2deb72a9f888ac46efc
@@ -77,6 +77,9 @@ public void startElement(String uri, String localName, String qName, Attributes
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 @@ public void startElement(String uri, String localName, String qName, Attributes
}
}

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 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 @@ private FTPClient newInstanceClient(FtpUrlEntity urlEntity) {
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 @@ public boolean isUploading() {
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 @@
* 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.lang.model.element.Modifier;

/**
* Created by lyy on 2017/9/6.
* 任务事件代理文件
* Created by lyy on 2017/9/6. 任务事件代理文件
*
* <pre>
* <code>
@@ -127,24 +126,13 @@ private MethodSpec createProxyMethod(TaskEnum taskEnum, Class<? extends Annotati
}
}
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 @@ private TypeSpec createProxyClass(ProxyClassParam entity) {
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 @@ private TypeSpec createProxyClass(ProxyClassParam entity) {
}
}

//增加构造函数
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 @@ private TypeSpec createProxyClass(ProxyClassParam entity) {
// }
//}

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 void onClick(View view) {
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 @@ void save() {
*/
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;
}

0 comments on commit ed0c98f

Please sign in to comment.