android P适配 https://github.com/AriaLyy/Aria/issues/581
This commit is contained in:
@@ -115,7 +115,6 @@ import java.util.concurrent.ConcurrentHashMap;
|
||||
initDb(APP);
|
||||
regAppLifeCallback(APP);
|
||||
initAria();
|
||||
amendTaskState();
|
||||
}
|
||||
|
||||
public Context getAPP() {
|
||||
@@ -137,6 +136,7 @@ import java.util.concurrent.ConcurrentHashMap;
|
||||
}
|
||||
}
|
||||
mDbWrapper = DelegateWrapper.init(context.getApplicationContext());
|
||||
amendTaskState();
|
||||
}
|
||||
|
||||
private void initAria() {
|
||||
|
||||
@@ -30,7 +30,7 @@ public final class BuilderController extends FeatureController implements IStart
|
||||
}
|
||||
|
||||
/**
|
||||
* 添加任务
|
||||
* 添加任务,只添加任务不进行下载
|
||||
*
|
||||
* @return 正常添加,返回任务id,否则返回-1
|
||||
*/
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
## 开发日志
|
||||
+ v_3.8.2
|
||||
+ v_3.8.3
|
||||
- fix bug https://github.com/AriaLyy/Aria/issues/573
|
||||
- android P适配 https://github.com/AriaLyy/Aria/issues/581
|
||||
+ v_3.8.1 (2019/12/22)
|
||||
- 修复一个表创建失败的问题 https://github.com/AriaLyy/Aria/issues/570
|
||||
- 修复一个非分块模式下导致下载失败的问题 https://github.com/AriaLyy/Aria/issues/571
|
||||
|
||||
@@ -38,7 +38,7 @@ class FtpDFileInfoThread extends AbsFtpInfoThread<DownloadEntity, DTaskWrapper>
|
||||
|
||||
@Override protected void handleFile(String remotePath, FTPFile ftpFile) {
|
||||
super.handleFile(remotePath, ftpFile);
|
||||
if (!FileUtil.checkSDMemorySpace(mEntity.getFilePath(), ftpFile.getSize())) {
|
||||
if (!FileUtil.checkMemorySpace(mEntity.getFilePath(), ftpFile.getSize())) {
|
||||
mCallback.onFail(mEntity, new AriaIOException(TAG,
|
||||
String.format("获取ftp文件信息失败,内存空间不足, filePath: %s", mEntity.getFilePath())),
|
||||
false);
|
||||
|
||||
@@ -125,7 +125,7 @@ public class HttpFileInfoThread implements Runnable {
|
||||
}
|
||||
long len = lenAdapter.handleFileLen(conn.getHeaderFields());
|
||||
|
||||
if (!FileUtil.checkSDMemorySpace(mEntity.getFilePath(), len)) {
|
||||
if (!FileUtil.checkMemorySpace(mEntity.getFilePath(), len)) {
|
||||
failDownload(new TaskException(TAG,
|
||||
String.format("下载失败,内存空间不足;filePath: %s, url: %s", mEntity.getDownloadPath(),
|
||||
mEntity.getUrl())), false);
|
||||
|
||||
@@ -375,76 +375,25 @@ public class FileUtil {
|
||||
}
|
||||
|
||||
/**
|
||||
* 检查SD内存空间是否充足
|
||||
* 检查内存空间是否充足
|
||||
*
|
||||
* @param filePath 文件保存路径
|
||||
* @param fileSize 文件大小
|
||||
* @return {@code false} 内存空间不足,{@code true}内存空间足够
|
||||
* @param path 文件路径
|
||||
* @param fileSize 下载的文件的大小
|
||||
* @return true 空间足够
|
||||
*/
|
||||
public static boolean checkSDMemorySpace(String filePath, long fileSize) {
|
||||
List<String> dirs = FileUtil.getSDPathList(AriaConfig.getInstance().getAPP());
|
||||
if (dirs == null || dirs.isEmpty()) {
|
||||
return true;
|
||||
}
|
||||
for (String path : dirs) {
|
||||
if (filePath.contains(path)) {
|
||||
if (fileSize > 0 && fileSize > getAvailableExternalMemorySize(path)) {
|
||||
return false;
|
||||
}
|
||||
public static boolean checkMemorySpace(String path, long fileSize) {
|
||||
File temp = new File(path);
|
||||
if (!temp.exists()){
|
||||
if (!temp.getParentFile().exists()){
|
||||
FileUtil.createDir(temp.getParentFile().getPath());
|
||||
}
|
||||
path = temp.getParentFile().getPath();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* sdcard 可用大小
|
||||
*
|
||||
* @param sdcardPath sdcard 根路径
|
||||
* @return 单位为:byte
|
||||
*/
|
||||
public static long getAvailableExternalMemorySize(String sdcardPath) {
|
||||
StatFs stat = new StatFs(sdcardPath);
|
||||
StatFs stat = new StatFs(path);
|
||||
long blockSize = stat.getBlockSize();
|
||||
long availableBlocks = stat.getAvailableBlocks();
|
||||
return availableBlocks * blockSize;
|
||||
}
|
||||
|
||||
/**
|
||||
* sdcard 总大小
|
||||
*
|
||||
* @param sdcardPath sdcard 根路径
|
||||
* @return 单位为:byte
|
||||
*/
|
||||
public static long getTotalExternalMemorySize(String sdcardPath) {
|
||||
StatFs stat = new StatFs(sdcardPath);
|
||||
long blockSize = stat.getBlockSize();
|
||||
long totalBlocks = stat.getBlockCount();
|
||||
return totalBlocks * blockSize;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取SD卡目录列表
|
||||
*/
|
||||
public static List<String> getSDPathList(Context context) {
|
||||
List<String> paths = null;
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) {
|
||||
try {
|
||||
paths = getVolumeList(context);
|
||||
} catch (ClassNotFoundException e) {
|
||||
e.printStackTrace();
|
||||
} catch (NoSuchMethodException e) {
|
||||
e.printStackTrace();
|
||||
} catch (IllegalAccessException e) {
|
||||
e.printStackTrace();
|
||||
} catch (InvocationTargetException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
} else {
|
||||
List<String> mounts = readMountsFile();
|
||||
List<String> volds = readVoldFile();
|
||||
paths = compareMountsWithVold(mounts, volds);
|
||||
}
|
||||
return paths;
|
||||
return fileSize <= availableBlocks * blockSize;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -495,11 +444,83 @@ public class FileUtil {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 检查SD内存空间是否充足
|
||||
*
|
||||
* @param filePath 文件保存路径
|
||||
* @param fileSize 文件大小
|
||||
* @return {@code false} 内存空间不足,{@code true}内存空间足够
|
||||
*/
|
||||
@Deprecated
|
||||
private static boolean checkSDMemorySpace(String filePath, long fileSize) {
|
||||
List<String> dirs = FileUtil.getSDPathList(AriaConfig.getInstance().getAPP());
|
||||
if (dirs == null || dirs.isEmpty()) {
|
||||
return true;
|
||||
}
|
||||
for (String path : dirs) {
|
||||
if (filePath.contains(path)) {
|
||||
if (fileSize > 0 && fileSize > getAvailableExternalMemorySize(path)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* sdcard 可用大小
|
||||
*
|
||||
* @param sdcardPath sdcard 根路径
|
||||
* @return 单位为:byte
|
||||
*/
|
||||
private static long getAvailableExternalMemorySize(String sdcardPath) {
|
||||
StatFs stat = new StatFs(sdcardPath);
|
||||
long blockSize = stat.getBlockSize();
|
||||
long availableBlocks = stat.getAvailableBlocks();
|
||||
return availableBlocks * blockSize;
|
||||
}
|
||||
|
||||
/**
|
||||
* sdcard 总大小
|
||||
*
|
||||
* @param sdcardPath sdcard 根路径
|
||||
* @return 单位为:byte
|
||||
*/
|
||||
private static long getTotalExternalMemorySize(String sdcardPath) {
|
||||
StatFs stat = new StatFs(sdcardPath);
|
||||
long blockSize = stat.getBlockSize();
|
||||
long totalBlocks = stat.getBlockCount();
|
||||
return totalBlocks * blockSize;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取SD卡目录列表
|
||||
*/
|
||||
private static List<String> getSDPathList(Context context) {
|
||||
List<String> paths = null;
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) {
|
||||
try {
|
||||
paths = getVolumeList(context);
|
||||
} catch (NoSuchMethodException e) {
|
||||
e.printStackTrace();
|
||||
} catch (IllegalAccessException e) {
|
||||
e.printStackTrace();
|
||||
} catch (InvocationTargetException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
} else {
|
||||
List<String> mounts = readMountsFile();
|
||||
List<String> volds = readVoldFile();
|
||||
paths = compareMountsWithVold(mounts, volds);
|
||||
}
|
||||
return paths;
|
||||
}
|
||||
|
||||
/**
|
||||
* getSDPathList
|
||||
*/
|
||||
private static List<String> getVolumeList(final Context context)
|
||||
throws ClassNotFoundException, NoSuchMethodException, InvocationTargetException,
|
||||
throws NoSuchMethodException, InvocationTargetException,
|
||||
IllegalAccessException {
|
||||
List<String> pathList = new ArrayList<>();
|
||||
|
||||
@@ -589,7 +610,7 @@ public class FileUtil {
|
||||
*
|
||||
* @return paths to all available SD-Cards in the system (include emulated)
|
||||
*/
|
||||
public static List<String> getStorageDirectories() {
|
||||
private static List<String> getStorageDirectories() {
|
||||
// Final set of paths
|
||||
final List<String> rv = new ArrayList<>();
|
||||
// Primary physical SD-CARD (not emulated)
|
||||
|
||||
@@ -44,7 +44,7 @@
|
||||
<threadNum value="3"/>
|
||||
|
||||
<!--设置下载队列最大任务数, 默认为2-->
|
||||
<maxTaskNum value="3"/>
|
||||
<maxTaskNum value="1"/>
|
||||
|
||||
<!--设置下载失败,重试次数,默认为10-->
|
||||
<reTryNum value="5"/>
|
||||
|
||||
@@ -29,7 +29,6 @@ import androidx.lifecycle.ViewModelProviders;
|
||||
import androidx.recyclerview.widget.DividerItemDecoration;
|
||||
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
import com.arialyy.aria.core.AriaManager;
|
||||
import com.arialyy.frame.permission.OnPermissionCallback;
|
||||
import com.arialyy.frame.permission.PermissionManager;
|
||||
import com.arialyy.frame.util.show.T;
|
||||
|
||||
@@ -20,6 +20,7 @@ import android.content.BroadcastReceiver;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import android.os.StatFs;
|
||||
import android.util.Log;
|
||||
import android.view.Menu;
|
||||
import android.view.MenuItem;
|
||||
@@ -32,7 +33,6 @@ import androidx.lifecycle.ViewModelProviders;
|
||||
import com.arialyy.annotations.Download;
|
||||
import com.arialyy.aria.core.Aria;
|
||||
import com.arialyy.aria.core.common.HttpOption;
|
||||
import com.arialyy.aria.core.common.RequestEnum;
|
||||
import com.arialyy.aria.core.download.DownloadEntity;
|
||||
import com.arialyy.aria.core.inf.IEntity;
|
||||
import com.arialyy.aria.core.listener.ISchedulers;
|
||||
@@ -40,16 +40,13 @@ import com.arialyy.aria.core.processor.IHttpFileLenAdapter;
|
||||
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;
|
||||
import com.arialyy.simple.common.ModifyPathDialog;
|
||||
import com.arialyy.simple.common.ModifyUrlDialog;
|
||||
import com.arialyy.simple.databinding.ActivitySingleBinding;
|
||||
import com.arialyy.simple.util.AppUtil;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
|
||||
@@ -54,6 +54,13 @@ public class GroupModule extends BaseModule {
|
||||
return names;
|
||||
}
|
||||
|
||||
List<String> getSubName1() {
|
||||
List<String> names = new ArrayList<>();
|
||||
String[] str = getContext().getResources().getStringArray(R.array.group_names);
|
||||
Collections.addAll(names, str);
|
||||
return names;
|
||||
}
|
||||
|
||||
List<String> getSubName2() {
|
||||
List<String> taskSubFile;
|
||||
taskSubFile = new ArrayList<>();
|
||||
|
||||
@@ -44,8 +44,8 @@ task clean(type: Delete) {
|
||||
}
|
||||
|
||||
ext {
|
||||
versionCode = 381
|
||||
versionName = '3.8.1'
|
||||
versionCode = 383
|
||||
versionName = '3.8.3_beta'
|
||||
userOrg = 'arialyy'
|
||||
groupId = 'com.arialyy.aria'
|
||||
publishVersion = versionName
|
||||
|
||||
Reference in New Issue
Block a user