移除androidx、support依赖,现在哪个版本的appcompat库都可以导入Aria
修复一个在xml中使用fragment导致的内存泄漏问题
This commit is contained in:
@@ -92,7 +92,6 @@ public class FtpUrlEntity implements Cloneable {
|
||||
* 连接协议
|
||||
* {@link ProtocolType}
|
||||
*/
|
||||
@ProtocolType
|
||||
public String protocol = ProtocolType.Default;
|
||||
|
||||
/**
|
||||
|
||||
@@ -15,20 +15,7 @@
|
||||
*/
|
||||
package com.arialyy.aria.core;
|
||||
|
||||
import androidx.annotation.StringDef;
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
|
||||
@StringDef({
|
||||
ProtocolType.Default,
|
||||
ProtocolType.SSL,
|
||||
ProtocolType.SSLv3,
|
||||
ProtocolType.TLS,
|
||||
ProtocolType.TLSv1,
|
||||
ProtocolType.TLSv1_1,
|
||||
ProtocolType.TLSv1_2
|
||||
})
|
||||
@Retention(RetentionPolicy.SOURCE) public @interface ProtocolType {
|
||||
public interface ProtocolType {
|
||||
String Default = "TLS";
|
||||
String SSL = "SSL";
|
||||
String SSLv3 = "SSLv3";
|
||||
|
||||
@@ -15,17 +15,7 @@
|
||||
*/
|
||||
package com.arialyy.aria.core.config;
|
||||
|
||||
import androidx.annotation.IntDef;
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
|
||||
@IntDef({
|
||||
ConfigType.DOWNLOAD,
|
||||
ConfigType.UPLOAD,
|
||||
ConfigType.APP,
|
||||
ConfigType.D_GROUP
|
||||
})
|
||||
@Retention(RetentionPolicy.SOURCE) @interface ConfigType {
|
||||
public interface ConfigType {
|
||||
int DOWNLOAD = 1;
|
||||
int UPLOAD = 2;
|
||||
int APP = 3;
|
||||
|
||||
@@ -33,7 +33,7 @@ public class XMLReader extends DefaultHandler {
|
||||
private UploadConfig mUploadConfig = Configuration.getInstance().uploadCfg;
|
||||
private AppConfig mAppConfig = Configuration.getInstance().appCfg;
|
||||
private DGroupConfig mDGroupConfig = Configuration.getInstance().dGroupCfg;
|
||||
private @ConfigType int mType;
|
||||
private int mType;
|
||||
|
||||
@Override public void startDocument() throws SAXException {
|
||||
super.startDocument();
|
||||
|
||||
@@ -1,17 +1,6 @@
|
||||
package com.arialyy.aria.core.inf;
|
||||
|
||||
import androidx.annotation.IntDef;
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
|
||||
@IntDef({
|
||||
TaskSchedulerType.TYPE_DEFAULT,
|
||||
TaskSchedulerType.TYPE_STOP_NOT_NEXT,
|
||||
TaskSchedulerType.TYPE_STOP_AND_WAIT,
|
||||
TaskSchedulerType.TYPE_CANCEL_AND_NOT_NOTIFY,
|
||||
TaskSchedulerType.TYPE_START_AND_RESET_STATE
|
||||
})
|
||||
@Retention(RetentionPolicy.SOURCE) public @interface TaskSchedulerType {
|
||||
public interface TaskSchedulerType {
|
||||
int TYPE_DEFAULT = 1;
|
||||
/**
|
||||
* 停止当前任务并且不自动启动下一任务
|
||||
|
||||
@@ -15,7 +15,6 @@
|
||||
*/
|
||||
package com.arialyy.aria.core.processor;
|
||||
|
||||
import androidx.annotation.Nullable;
|
||||
import com.arialyy.aria.core.download.M3U8Entity;
|
||||
import com.arialyy.aria.core.inf.IEventHandler;
|
||||
import java.util.List;
|
||||
@@ -33,5 +32,5 @@ public interface ITsMergeHandler extends IEventHandler {
|
||||
* @param tsPath ts文件列表
|
||||
* @return {@code true} 合并成功
|
||||
*/
|
||||
boolean merge(@Nullable M3U8Entity m3U8Entity, List<String> tsPath);
|
||||
boolean merge(M3U8Entity m3U8Entity, List<String> tsPath);
|
||||
}
|
||||
|
||||
@@ -52,7 +52,6 @@ public abstract class AbsTask<TASK_WRAPPER extends AbsTaskWrapper>
|
||||
/**
|
||||
* 该任务的调度类型
|
||||
*/
|
||||
@TaskSchedulerType
|
||||
private int mSchedulerType = TaskSchedulerType.TYPE_DEFAULT;
|
||||
protected IEventListener mListener;
|
||||
|
||||
@@ -193,7 +192,7 @@ public abstract class AbsTask<TASK_WRAPPER extends AbsTaskWrapper>
|
||||
start(TaskSchedulerType.TYPE_DEFAULT);
|
||||
}
|
||||
|
||||
@Override public void start(@TaskSchedulerType int type) {
|
||||
@Override public void start(int type) {
|
||||
mSchedulerType = type;
|
||||
if (type == TaskSchedulerType.TYPE_START_AND_RESET_STATE) {
|
||||
if (getUtil().isRunning()) {
|
||||
@@ -216,7 +215,7 @@ public abstract class AbsTask<TASK_WRAPPER extends AbsTaskWrapper>
|
||||
stop(TaskSchedulerType.TYPE_DEFAULT);
|
||||
}
|
||||
|
||||
@Override public void stop(@TaskSchedulerType int type) {
|
||||
@Override public void stop(int type) {
|
||||
isStop = true;
|
||||
mSchedulerType = type;
|
||||
getUtil().stop();
|
||||
@@ -226,7 +225,7 @@ public abstract class AbsTask<TASK_WRAPPER extends AbsTaskWrapper>
|
||||
cancel(TaskSchedulerType.TYPE_DEFAULT);
|
||||
}
|
||||
|
||||
@Override public void cancel(@TaskSchedulerType int type) {
|
||||
@Override public void cancel(int type) {
|
||||
isCancel = true;
|
||||
mSchedulerType = type;
|
||||
getUtil().cancel();
|
||||
|
||||
@@ -91,7 +91,7 @@ public interface ITask<TASK_WRAPPER extends AbsTaskWrapper> {
|
||||
*
|
||||
* @param type {@link TaskSchedulerType}
|
||||
*/
|
||||
void start(@TaskSchedulerType int type);
|
||||
void start(int type);
|
||||
|
||||
/**
|
||||
* 停止任务
|
||||
@@ -103,7 +103,7 @@ public interface ITask<TASK_WRAPPER extends AbsTaskWrapper> {
|
||||
*
|
||||
* @param type {@link TaskSchedulerType}
|
||||
*/
|
||||
void stop(@TaskSchedulerType int type);
|
||||
void stop(int type);
|
||||
|
||||
/**
|
||||
* 删除任务
|
||||
@@ -115,7 +115,7 @@ public interface ITask<TASK_WRAPPER extends AbsTaskWrapper> {
|
||||
*
|
||||
* @param type {@link TaskSchedulerType}
|
||||
*/
|
||||
void cancel(@TaskSchedulerType int type);
|
||||
void cancel(int type);
|
||||
|
||||
/**
|
||||
* 读取扩展数据
|
||||
|
||||
@@ -16,7 +16,6 @@
|
||||
package com.arialyy.aria.core.task;
|
||||
|
||||
import android.os.Bundle;
|
||||
import androidx.annotation.Nullable;
|
||||
import com.arialyy.aria.core.inf.IThreadState;
|
||||
import com.arialyy.aria.exception.BaseException;
|
||||
|
||||
@@ -33,7 +32,7 @@ public interface IThreadTaskObserver {
|
||||
*
|
||||
* @param state state {@link IThreadState#STATE_STOP}..
|
||||
*/
|
||||
void updateState(int state, @Nullable Bundle bundle);
|
||||
void updateState(int state, Bundle bundle);
|
||||
|
||||
/**
|
||||
* 更新完成的状态
|
||||
@@ -45,7 +44,7 @@ public interface IThreadTaskObserver {
|
||||
*
|
||||
* @param needRetry 是否需要重试,一般是网络错误才需要重试
|
||||
*/
|
||||
void updateFailState(@Nullable BaseException e, boolean needRetry);
|
||||
void updateFailState(BaseException e, boolean needRetry);
|
||||
|
||||
/**
|
||||
* 更新进度
|
||||
|
||||
@@ -20,7 +20,6 @@ import android.os.Bundle;
|
||||
import android.os.Handler;
|
||||
import android.os.Message;
|
||||
import android.os.Process;
|
||||
import androidx.annotation.Nullable;
|
||||
import com.arialyy.aria.core.AriaConfig;
|
||||
import com.arialyy.aria.core.ThreadRecord;
|
||||
import com.arialyy.aria.core.common.SubThreadConfig;
|
||||
@@ -259,7 +258,7 @@ public class ThreadTask implements IThreadTask, IThreadTaskObserver {
|
||||
* @param bundle 而外数据
|
||||
*/
|
||||
@Override
|
||||
public synchronized void updateState(int state, @Nullable Bundle bundle) {
|
||||
public synchronized void updateState(int state, Bundle bundle) {
|
||||
Message msg = mStateHandler.obtainMessage();
|
||||
msg.what = state;
|
||||
if (state != IThreadState.STATE_UPDATE_PROGRESS) {
|
||||
@@ -297,7 +296,7 @@ public class ThreadTask implements IThreadTask, IThreadTaskObserver {
|
||||
*
|
||||
* @param needRetry 是否需要重试,一般是网络错误才需要重试
|
||||
*/
|
||||
@Override public synchronized void updateFailState(@Nullable BaseException e, boolean needRetry) {
|
||||
@Override public synchronized void updateFailState(BaseException e, boolean needRetry) {
|
||||
fail(mRangeProgress, e, needRetry);
|
||||
}
|
||||
|
||||
@@ -448,7 +447,7 @@ public class ThreadTask implements IThreadTask, IThreadTaskObserver {
|
||||
/**
|
||||
* 发送失败信息
|
||||
*/
|
||||
private void sendFailMsg(@Nullable BaseException e,boolean needRetry) {
|
||||
private void sendFailMsg(BaseException e, boolean needRetry) {
|
||||
Bundle b = new Bundle();
|
||||
b.putBoolean(IThreadState.KEY_RETRY, needRetry);
|
||||
if (e != null) {
|
||||
|
||||
@@ -56,8 +56,7 @@ public class SSLContextUtil {
|
||||
* @param caPath 保存在assets目录下的CA证书完整路径
|
||||
* @param protocol 连接协议
|
||||
*/
|
||||
public static SSLContext getSSLContextFromAssets(String caAlias, String caPath,
|
||||
@ProtocolType String protocol) {
|
||||
public static SSLContext getSSLContextFromAssets(String caAlias, String caPath, String protocol) {
|
||||
if (TextUtils.isEmpty(caAlias) || TextUtils.isEmpty(caPath)) {
|
||||
return null;
|
||||
}
|
||||
@@ -83,8 +82,7 @@ public class SSLContextUtil {
|
||||
* @param caPath CA证书路径
|
||||
* @param protocol 连接协议
|
||||
*/
|
||||
public static SSLContext getSSLContext(String caAlias, String caPath,
|
||||
@ProtocolType String protocol) {
|
||||
public static SSLContext getSSLContext(String caAlias, String caPath, String protocol) {
|
||||
if (TextUtils.isEmpty(caAlias) || TextUtils.isEmpty(caPath)) {
|
||||
return null;
|
||||
}
|
||||
@@ -105,8 +103,8 @@ public class SSLContextUtil {
|
||||
/**
|
||||
* @param cacheKey 别名 + 证书路径,然后取md5
|
||||
*/
|
||||
private static SSLContext createContext(String caAlias, Certificate ca,
|
||||
@ProtocolType String protocol, String cacheKey) {
|
||||
private static SSLContext createContext(String caAlias, Certificate ca, String protocol,
|
||||
String cacheKey) {
|
||||
try {
|
||||
String keyStoreType = KeyStore.getDefaultType();
|
||||
KeyStore keyStore = KeyStore.getInstance(keyStoreType);
|
||||
@@ -154,7 +152,7 @@ public class SSLContextUtil {
|
||||
/**
|
||||
* 服务器证书不是由 CA 签署的,而是自签署时,获取默认的SSL
|
||||
*/
|
||||
public static SSLContext getDefaultSLLContext(@ProtocolType String protocol) {
|
||||
public static SSLContext getDefaultSLLContext(String protocol) {
|
||||
SSLContext sslContext = null;
|
||||
try {
|
||||
sslContext =
|
||||
|
||||
@@ -27,9 +27,6 @@ package com.arialyy.aria.util;
|
||||
import android.os.Handler;
|
||||
import android.os.Looper;
|
||||
import android.os.Message;
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.annotation.VisibleForTesting;
|
||||
import java.lang.ref.WeakReference;
|
||||
import java.util.concurrent.locks.Lock;
|
||||
import java.util.concurrent.locks.ReentrantLock;
|
||||
@@ -51,7 +48,7 @@ import java.util.concurrent.locks.ReentrantLock;
|
||||
// hard reference to Callback. We need to keep callback in memory
|
||||
private final ExecHandler mExec;
|
||||
private Lock mLock = new ReentrantLock();
|
||||
@SuppressWarnings("ConstantConditions") @VisibleForTesting final ChainedRef mRunnables =
|
||||
@SuppressWarnings("ConstantConditions") final ChainedRef mRunnables =
|
||||
new ChainedRef(mLock, null);
|
||||
|
||||
/**
|
||||
@@ -76,7 +73,7 @@ import java.util.concurrent.locks.ReentrantLock;
|
||||
*
|
||||
* @param callback The callback interface in which to handle messages, or null.
|
||||
*/
|
||||
public WeakHandler(@Nullable Handler.Callback callback) {
|
||||
public WeakHandler(Handler.Callback callback) {
|
||||
mCallback = callback; // Hard referencing body
|
||||
mExec = new ExecHandler(new WeakReference<>(callback)); // Weak referencing inside ExecHandler
|
||||
}
|
||||
@@ -86,7 +83,7 @@ import java.util.concurrent.locks.ReentrantLock;
|
||||
*
|
||||
* @param looper The looper, must not be null.
|
||||
*/
|
||||
public WeakHandler(@NonNull Looper looper) {
|
||||
public WeakHandler(Looper looper) {
|
||||
mCallback = null;
|
||||
mExec = new ExecHandler(looper);
|
||||
}
|
||||
@@ -98,7 +95,7 @@ import java.util.concurrent.locks.ReentrantLock;
|
||||
* @param looper The looper, must not be null.
|
||||
* @param callback The callback interface in which to handle messages, or null.
|
||||
*/
|
||||
public WeakHandler(@NonNull Looper looper, @NonNull Handler.Callback callback) {
|
||||
public WeakHandler(Looper looper, Handler.Callback callback) {
|
||||
mCallback = callback;
|
||||
mExec = new ExecHandler(looper, new WeakReference<>(callback));
|
||||
}
|
||||
@@ -113,7 +110,7 @@ import java.util.concurrent.locks.ReentrantLock;
|
||||
* message queue. Returns false on failure, usually because the
|
||||
* looper processing the message queue is exiting.
|
||||
*/
|
||||
public final boolean post(@NonNull Runnable r) {
|
||||
public final boolean post(Runnable r) {
|
||||
return mExec.post(wrapRunnable(r));
|
||||
}
|
||||
|
||||
@@ -133,7 +130,7 @@ import java.util.concurrent.locks.ReentrantLock;
|
||||
* the looper is quit before the delivery time of the message
|
||||
* occurs then the message will be dropped.
|
||||
*/
|
||||
public final boolean postAtTime(@NonNull Runnable r, long uptimeMillis) {
|
||||
public final boolean postAtTime(Runnable r, long uptimeMillis) {
|
||||
return mExec.postAtTime(wrapRunnable(r), uptimeMillis);
|
||||
}
|
||||
|
||||
@@ -367,7 +364,7 @@ import java.util.concurrent.locks.ReentrantLock;
|
||||
return mExec.getLooper();
|
||||
}
|
||||
|
||||
private WeakRunnable wrapRunnable(@NonNull Runnable r) {
|
||||
private WeakRunnable wrapRunnable(Runnable r) {
|
||||
//noinspection ConstantConditions
|
||||
if (r == null) {
|
||||
throw new NullPointerException("Runnable can't be null");
|
||||
@@ -398,7 +395,7 @@ import java.util.concurrent.locks.ReentrantLock;
|
||||
mCallback = callback;
|
||||
}
|
||||
|
||||
@Override public void handleMessage(@NonNull Message msg) {
|
||||
@Override public void handleMessage(Message msg) {
|
||||
if (mCallback == null) {
|
||||
return;
|
||||
}
|
||||
@@ -432,14 +429,14 @@ import java.util.concurrent.locks.ReentrantLock;
|
||||
}
|
||||
|
||||
static class ChainedRef {
|
||||
@Nullable ChainedRef next;
|
||||
@Nullable ChainedRef prev;
|
||||
@NonNull final Runnable runnable;
|
||||
@NonNull final WeakRunnable wrapper;
|
||||
ChainedRef next;
|
||||
ChainedRef prev;
|
||||
final Runnable runnable;
|
||||
final WeakRunnable wrapper;
|
||||
|
||||
@NonNull Lock lock;
|
||||
Lock lock;
|
||||
|
||||
public ChainedRef(@NonNull Lock lock, @NonNull Runnable r) {
|
||||
public ChainedRef(Lock lock, Runnable r) {
|
||||
this.runnable = r;
|
||||
this.lock = lock;
|
||||
this.wrapper = new WeakRunnable(new WeakReference<>(r), new WeakReference<>(this));
|
||||
@@ -462,7 +459,7 @@ import java.util.concurrent.locks.ReentrantLock;
|
||||
return wrapper;
|
||||
}
|
||||
|
||||
public void insertAfter(@NonNull ChainedRef candidate) {
|
||||
public void insertAfter(ChainedRef candidate) {
|
||||
lock.lock();
|
||||
try {
|
||||
if (this.next != null) {
|
||||
@@ -477,7 +474,7 @@ import java.util.concurrent.locks.ReentrantLock;
|
||||
}
|
||||
}
|
||||
|
||||
@Nullable public WeakRunnable remove(Runnable obj) {
|
||||
public WeakRunnable remove(Runnable obj) {
|
||||
lock.lock();
|
||||
try {
|
||||
ChainedRef curr = this.next; // Skipping head
|
||||
|
||||
Reference in New Issue
Block a user