1.AppManager和SplashView处理图片断电重启无论多少次图片不显示而其原因为文件变回-tmp情况,广告位5s后刷新

2.DownLoadManeger 处理下载apk安装未完成重启无论多少次不安装情况
3.重命名系统概率不成功把重命名和删除文件操作分开间隔5s
This commit is contained in:
2025-11-08 09:03:38 +08:00
parent 578f5739bf
commit 646719c3fb
7 changed files with 43 additions and 11 deletions

View File

@@ -11,8 +11,8 @@ android {
minSdkVersion 21 minSdkVersion 21
targetSdkVersion 34 targetSdkVersion 34
multiDexEnabled true multiDexEnabled true
versionCode 568888804 versionCode 568888806
versionName "SNFLauncher-5.6.4" versionName "SNFLauncher-5.6.6"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
buildConfigField "String", "MANUFACTURER", '"allwinner"' buildConfigField "String", "MANUFACTURER", '"allwinner"'
buildConfigField "boolean", "LOG_ENABLED", "false" buildConfigField "boolean", "LOG_ENABLED", "false"

View File

@@ -48,9 +48,9 @@ public class SystemService extends Service implements AppnetCallback, NetStateCh
private static final int WHAT_PERIODIC_REQUEST = 4; private static final int WHAT_PERIODIC_REQUEST = 4;
// 请求间隔8小时正式环境 // 请求间隔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 static final String KEY_LAST_SUCCESS_TIME = "last_success_time";
private boolean isFirstRequestDone = false; // 首次请求是否完成重启后重置为false private boolean isFirstRequestDone = false; // 首次请求是否完成重启后重置为false

View File

@@ -184,7 +184,7 @@ public class HomeMultiView extends MultiView {
@Override @Override
public void onImageRestartLocal(String path){ public void onImageRestartLocal(String path){
LogUtils.loge("onImageRestartLocal==>"+path); LogUtils.loge("onImageRestartLocal==>"+path);
if(path==null){ if(TextUtils.isEmpty(path)){
return; return;
} }
img_view.setVisibility(VISIBLE); img_view.setVisibility(VISIBLE);

View File

@@ -158,9 +158,16 @@ public class SplashView {
} }
File file = new File(adsInfoBeanInfo.getLocalFilePath()); File file = new File(adsInfoBeanInfo.getLocalFilePath());
if(!file.exists()){ if(!file.exists()){
LogUtils.loge("file is not exits===>"); File tempFile=new File(adsInfoBeanInfo.getLocalFilePath()+"-tmp");
mHandler.sendEmptyMessageDelayed(2,10000); if(tempFile.exists()&&tempFile.length()==adsInfoBeanInfo.getAdSize()){
return ; 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 ;
}
} }

View File

@@ -9,6 +9,7 @@ import com.android.util.GsonUtil;
import com.android.util.LogUtils; import com.android.util.LogUtils;
import java.io.File; import java.io.File;
import java.io.IOException;
import java.util.List; import java.util.List;
public class DownLoadManeger { public class DownLoadManeger {
@@ -132,10 +133,17 @@ public class DownLoadManeger {
for (DownLoadTaskBean downLoadTaskBean:list) { for (DownLoadTaskBean downLoadTaskBean:list) {
if(!TextUtils.isEmpty(downLoadTaskBean.getUrl())&&!TextUtils.isEmpty(downLoadTaskBean.getFileName())&&!TextUtils.isEmpty(downLoadTaskBean.getPath())){ if(!TextUtils.isEmpty(downLoadTaskBean.getUrl())&&!TextUtils.isEmpty(downLoadTaskBean.getFileName())&&!TextUtils.isEmpty(downLoadTaskBean.getPath())){
File file = new File(downLoadTaskBean.getPath()+downLoadTaskBean.getFileName()+"-tmp"); File file = new File(downLoadTaskBean.getPath()+downLoadTaskBean.getFileName()+"-tmp");
if(file.exists()&&downLoadTaskBean.getCurrentProgress()==file.length()&&file.length()<=downLoadTaskBean.getTotal()){ if(file.exists()&&downLoadTaskBean.getCurrentProgress()==file.length()&&file.length()<=downLoadTaskBean.getTotal()){
TaskQueue.getInstance().remove(downLoadTaskBean); TaskQueue.getInstance().remove(downLoadTaskBean);
TaskQueue.getInstance().add(new DownLoadTaskThread(downLoadTaskBean, observer)); 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()){ if(file.exists()&&file.length()>0&&file.length()<=downLoadTaskBean.getTotal()){
downLoadTaskBean.setCurrentProgress(file.length()); downLoadTaskBean.setCurrentProgress(file.length());
DaoManager.getInstance().update(DownLoadTaskBean.class,downLoadTaskBean); 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())){ }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"); File file = new File(downLoadTaskBean.getPath()+downLoadTaskBean.getFileName()+"-tmp");

View File

@@ -49,6 +49,7 @@ public class DownLoadTaskThread implements Runnable {
File dataFile = new File(bean.getPath(), bean.getFileName()); File dataFile = new File(bean.getPath(), bean.getFileName());
if(dataFile.exists()&&dataFile.length()==bean.getTotal()){ //判断该文件已下载无需再下载 if(dataFile.exists()&&dataFile.length()==bean.getTotal()){ //判断该文件已下载无需再下载
LogUtils.loge("dont need download "+bean.getFileName());
observer.onFinish(bean, bean.getTaskId(), dataFile.length()); observer.onFinish(bean, bean.getTaskId(), dataFile.length());
return; return;
} }
@@ -63,8 +64,8 @@ public class DownLoadTaskThread implements Runnable {
if(currentTotal==bean.getTotal()){ if(currentTotal==bean.getTotal()){
File targFile = new File(bean.getPath(), bean.getFileName()); File targFile = new File(bean.getPath(), bean.getFileName());
file.renameTo(targFile);//重命名 file.renameTo(targFile);//重命名
file.delete();//删除临时文件
Thread.sleep(5000); Thread.sleep(5000);
file.delete();//删除临时文件
observer.onFinish(bean, bean.getTaskId(), currentTotal); observer.onFinish(bean, bean.getTaskId(), currentTotal);
return; return;
} }
@@ -114,8 +115,8 @@ public class DownLoadTaskThread implements Runnable {
LogUtils.loge("download Exception===>sleeping before"); LogUtils.loge("download Exception===>sleeping before");
File targFile = new File(bean.getPath(), bean.getFileName()); File targFile = new File(bean.getPath(), bean.getFileName());
file.renameTo(targFile);//重命名 file.renameTo(targFile);//重命名
file.delete();//删除临时文件
Thread.sleep(5000); Thread.sleep(5000);
file.delete();//删除临时文件
LogUtils.loge("download Exception===>sleeping after"); LogUtils.loge("download Exception===>sleeping after");
observer.onFinish(bean, bean.getTaskId(), currentTotal); observer.onFinish(bean, bean.getTaskId(), currentTotal);
}else { }else {

View File

@@ -15,6 +15,8 @@ import com.android.database.lib.NetShortAppBean;
import com.android.database.lib.RecommendAppBean; import com.android.database.lib.RecommendAppBean;
import com.android.database.lib.ShortAppBean; import com.android.database.lib.ShortAppBean;
import com.android.database.lib.VideoAppBean; 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.nebulasdk.bean.FavNaviBean;
import com.android.util.GsonUtil; import com.android.util.GsonUtil;
import com.android.util.LogUtils; import com.android.util.LogUtils;
@@ -587,6 +589,13 @@ public class AppManager {
if (file.exists()) { if (file.exists()) {
favNaviBean = new FavNaviBean(index, adsInfoBean.getLocalFilePath(), adsInfoBean.getInfo(), null); favNaviBean = new FavNaviBean(index, adsInfoBean.getLocalFilePath(), adsInfoBean.getInfo(), null);
}else { }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"); LogUtils.loge(file.getPath()+" is not exit");
} }
} }