1.AppManager和SplashView处理图片断电重启无论多少次图片不显示而其原因为文件变回-tmp情况,广告位5s后刷新
2.DownLoadManeger 处理下载apk安装未完成重启无论多少次不安装情况 3.重命名系统概率不成功把重命名和删除文件操作分开间隔5s
This commit is contained in:
@@ -11,8 +11,8 @@ android {
|
||||
minSdkVersion 21
|
||||
targetSdkVersion 34
|
||||
multiDexEnabled true
|
||||
versionCode 568888804
|
||||
versionName "SNFLauncher-5.6.4"
|
||||
versionCode 568888806
|
||||
versionName "SNFLauncher-5.6.6"
|
||||
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
||||
buildConfigField "String", "MANUFACTURER", '"allwinner"'
|
||||
buildConfigField "boolean", "LOG_ENABLED", "false"
|
||||
|
||||
@@ -48,9 +48,9 @@ public class SystemService extends Service implements AppnetCallback, NetStateCh
|
||||
private static final int WHAT_PERIODIC_REQUEST = 4;
|
||||
|
||||
// 请求间隔(8小时,正式环境)
|
||||
// private static final long REQUEST_INTERVAL = 8 * 60 * 60 * 1000;
|
||||
private static final long REQUEST_INTERVAL = 8 * 60 * 60 * 1000;
|
||||
// 测试用短间隔
|
||||
private static final long REQUEST_INTERVAL = 5 * 60 * 1000; // 5分钟
|
||||
// private static final long REQUEST_INTERVAL = 5 * 60 * 1000; // 5分钟
|
||||
//持久化存储成功请求时间
|
||||
private static final String KEY_LAST_SUCCESS_TIME = "last_success_time";
|
||||
private boolean isFirstRequestDone = false; // 首次请求是否完成(重启后重置为false)
|
||||
|
||||
@@ -184,7 +184,7 @@ public class HomeMultiView extends MultiView {
|
||||
@Override
|
||||
public void onImageRestartLocal(String path){
|
||||
LogUtils.loge("onImageRestartLocal==>"+path);
|
||||
if(path==null){
|
||||
if(TextUtils.isEmpty(path)){
|
||||
return;
|
||||
}
|
||||
img_view.setVisibility(VISIBLE);
|
||||
|
||||
@@ -158,10 +158,17 @@ public class SplashView {
|
||||
}
|
||||
File file = new File(adsInfoBeanInfo.getLocalFilePath());
|
||||
if(!file.exists()){
|
||||
File tempFile=new File(adsInfoBeanInfo.getLocalFilePath()+"-tmp");
|
||||
if(tempFile.exists()&&tempFile.length()==adsInfoBeanInfo.getAdSize()){
|
||||
tempFile.renameTo(file);
|
||||
tempFile.delete();
|
||||
LogUtils.loge("下载大小完成但重命名失败同时下载任务已清除图片至始至终未显示优化处理 system rename file file bug compose");
|
||||
}else {
|
||||
LogUtils.loge("file is not exits===>");
|
||||
mHandler.sendEmptyMessageDelayed(2,10000);
|
||||
return ;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if(adsInfoBeanInfo.getState()==0){
|
||||
|
||||
@@ -9,6 +9,7 @@ import com.android.util.GsonUtil;
|
||||
import com.android.util.LogUtils;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
|
||||
public class DownLoadManeger {
|
||||
@@ -135,8 +136,15 @@ public class DownLoadManeger {
|
||||
if(file.exists()&&downLoadTaskBean.getCurrentProgress()==file.length()&&file.length()<=downLoadTaskBean.getTotal()){
|
||||
TaskQueue.getInstance().remove(downLoadTaskBean);
|
||||
TaskQueue.getInstance().add(new DownLoadTaskThread(downLoadTaskBean, observer));
|
||||
}else if(downLoadTaskBean.getTaskType()==1){//apk 下载完成未安装断电重新启动下载任务 因为需要安装apk
|
||||
File apkFile = new File(downLoadTaskBean.getPath()+downLoadTaskBean.getFileName());
|
||||
if(apkFile.exists()&&apkFile.length()==downLoadTaskBean.getTotal()&&downLoadTaskBean.getCurrentProgress()<downLoadTaskBean.getTotal()){
|
||||
TaskQueue.getInstance().remove(downLoadTaskBean);
|
||||
TaskQueue.getInstance().add(new DownLoadTaskThread(downLoadTaskBean, observer));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -148,6 +156,13 @@ public class DownLoadManeger {
|
||||
if(file.exists()&&file.length()>0&&file.length()<=downLoadTaskBean.getTotal()){
|
||||
downLoadTaskBean.setCurrentProgress(file.length());
|
||||
DaoManager.getInstance().update(DownLoadTaskBean.class,downLoadTaskBean);
|
||||
}else if(!file.exists()){
|
||||
try {
|
||||
boolean createFileSuccess=file.createNewFile();
|
||||
LogUtils.loge("下载任务但文件丢失创建文件="+createFileSuccess);
|
||||
} catch (IOException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
}else if(downLoadTaskBean.getCurrentProgress()!=0&&!TextUtils.isEmpty(downLoadTaskBean.getUrl())&&!TextUtils.isEmpty(downLoadTaskBean.getFileName())&&!TextUtils.isEmpty(downLoadTaskBean.getPath())){
|
||||
File file = new File(downLoadTaskBean.getPath()+downLoadTaskBean.getFileName()+"-tmp");
|
||||
|
||||
@@ -49,6 +49,7 @@ public class DownLoadTaskThread implements Runnable {
|
||||
|
||||
File dataFile = new File(bean.getPath(), bean.getFileName());
|
||||
if(dataFile.exists()&&dataFile.length()==bean.getTotal()){ //判断该文件已下载无需再下载
|
||||
LogUtils.loge("dont need download "+bean.getFileName());
|
||||
observer.onFinish(bean, bean.getTaskId(), dataFile.length());
|
||||
return;
|
||||
}
|
||||
@@ -63,8 +64,8 @@ public class DownLoadTaskThread implements Runnable {
|
||||
if(currentTotal==bean.getTotal()){
|
||||
File targFile = new File(bean.getPath(), bean.getFileName());
|
||||
file.renameTo(targFile);//重命名
|
||||
file.delete();//删除临时文件
|
||||
Thread.sleep(5000);
|
||||
file.delete();//删除临时文件
|
||||
observer.onFinish(bean, bean.getTaskId(), currentTotal);
|
||||
return;
|
||||
}
|
||||
@@ -114,8 +115,8 @@ public class DownLoadTaskThread implements Runnable {
|
||||
LogUtils.loge("download Exception===>sleeping before");
|
||||
File targFile = new File(bean.getPath(), bean.getFileName());
|
||||
file.renameTo(targFile);//重命名
|
||||
file.delete();//删除临时文件
|
||||
Thread.sleep(5000);
|
||||
file.delete();//删除临时文件
|
||||
LogUtils.loge("download Exception===>sleeping after");
|
||||
observer.onFinish(bean, bean.getTaskId(), currentTotal);
|
||||
}else {
|
||||
|
||||
@@ -15,6 +15,8 @@ import com.android.database.lib.NetShortAppBean;
|
||||
import com.android.database.lib.RecommendAppBean;
|
||||
import com.android.database.lib.ShortAppBean;
|
||||
import com.android.database.lib.VideoAppBean;
|
||||
import com.android.eventbaus.EventBusUtils;
|
||||
import com.android.eventbaus.MessageEvent;
|
||||
import com.android.nebulasdk.bean.FavNaviBean;
|
||||
import com.android.util.GsonUtil;
|
||||
import com.android.util.LogUtils;
|
||||
@@ -587,6 +589,13 @@ public class AppManager {
|
||||
if (file.exists()) {
|
||||
favNaviBean = new FavNaviBean(index, adsInfoBean.getLocalFilePath(), adsInfoBean.getInfo(), null);
|
||||
}else {
|
||||
File tempFile=new File(adsInfoBean.getLocalFilePath()+"-tmp");
|
||||
if(tempFile.exists()&&tempFile.length()==adsInfoBean.getAdSize()){
|
||||
tempFile.renameTo(file);
|
||||
tempFile.delete();
|
||||
EventBusUtils.postMsg(new MessageEvent(MessageEvent.ACTION_UPADATE_DATA_SOURCE));
|
||||
LogUtils.loge("下载大小完成但重命名失败同时下载任务已清除图片至始至终未显示处理 sys rename failed bug solved");
|
||||
}
|
||||
LogUtils.loge(file.getPath()+" is not exit");
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user