From 646719c3fbead2161d5c3314cd2210a3c07d85c3 Mon Sep 17 00:00:00 2001 From: kangshulong Date: Sat, 8 Nov 2025 09:03:38 +0800 Subject: [PATCH] =?UTF-8?q?1.AppManager=E5=92=8CSplashView=E5=A4=84?= =?UTF-8?q?=E7=90=86=E5=9B=BE=E7=89=87=E6=96=AD=E7=94=B5=E9=87=8D=E5=90=AF?= =?UTF-8?q?=E6=97=A0=E8=AE=BA=E5=A4=9A=E5=B0=91=E6=AC=A1=E5=9B=BE=E7=89=87?= =?UTF-8?q?=E4=B8=8D=E6=98=BE=E7=A4=BA=E8=80=8C=E5=85=B6=E5=8E=9F=E5=9B=A0?= =?UTF-8?q?=E4=B8=BA=E6=96=87=E4=BB=B6=E5=8F=98=E5=9B=9E-tmp=E6=83=85?= =?UTF-8?q?=E5=86=B5=EF=BC=8C=E5=B9=BF=E5=91=8A=E4=BD=8D5s=E5=90=8E?= =?UTF-8?q?=E5=88=B7=E6=96=B0=202.DownLoadManeger=20=E5=A4=84=E7=90=86?= =?UTF-8?q?=E4=B8=8B=E8=BD=BDapk=E5=AE=89=E8=A3=85=E6=9C=AA=E5=AE=8C?= =?UTF-8?q?=E6=88=90=E9=87=8D=E5=90=AF=E6=97=A0=E8=AE=BA=E5=A4=9A=E5=B0=91?= =?UTF-8?q?=E6=AC=A1=E4=B8=8D=E5=AE=89=E8=A3=85=E6=83=85=E5=86=B5=203.?= =?UTF-8?q?=E9=87=8D=E5=91=BD=E5=90=8D=E7=B3=BB=E7=BB=9F=E6=A6=82=E7=8E=87?= =?UTF-8?q?=E4=B8=8D=E6=88=90=E5=8A=9F=E6=8A=8A=E9=87=8D=E5=91=BD=E5=90=8D?= =?UTF-8?q?=E5=92=8C=E5=88=A0=E9=99=A4=E6=96=87=E4=BB=B6=E6=93=8D=E4=BD=9C?= =?UTF-8?q?=E5=88=86=E5=BC=80=E9=97=B4=E9=9A=945s?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/build.gradle | 4 ++-- .../java/com/ik/mboxlauncher/SystemService.java | 4 ++-- .../com/ik/mboxlauncher/view/HomeMultiView.java | 2 +- .../com/ik/mboxlauncher/view/SplashView.java | 13 ++++++++++--- .../com/android/download/DownLoadManeger.java | 17 ++++++++++++++++- .../android/download/DownLoadTaskThread.java | 5 +++-- .../java/com/android/nebulasdk/AppManager.java | 9 +++++++++ 7 files changed, 43 insertions(+), 11 deletions(-) diff --git a/app/build.gradle b/app/build.gradle index 4619c4e..5a6be50 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -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" diff --git a/app/src/main/java/com/ik/mboxlauncher/SystemService.java b/app/src/main/java/com/ik/mboxlauncher/SystemService.java index 365a757..ac286a8 100644 --- a/app/src/main/java/com/ik/mboxlauncher/SystemService.java +++ b/app/src/main/java/com/ik/mboxlauncher/SystemService.java @@ -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) diff --git a/app/src/main/java/com/ik/mboxlauncher/view/HomeMultiView.java b/app/src/main/java/com/ik/mboxlauncher/view/HomeMultiView.java index 29087d7..51605f0 100644 --- a/app/src/main/java/com/ik/mboxlauncher/view/HomeMultiView.java +++ b/app/src/main/java/com/ik/mboxlauncher/view/HomeMultiView.java @@ -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); diff --git a/app/src/main/java/com/ik/mboxlauncher/view/SplashView.java b/app/src/main/java/com/ik/mboxlauncher/view/SplashView.java index 78264cf..52320e1 100644 --- a/app/src/main/java/com/ik/mboxlauncher/view/SplashView.java +++ b/app/src/main/java/com/ik/mboxlauncher/view/SplashView.java @@ -158,9 +158,16 @@ public class SplashView { } File file = new File(adsInfoBeanInfo.getLocalFilePath()); if(!file.exists()){ - LogUtils.loge("file is not exits===>"); - mHandler.sendEmptyMessageDelayed(2,10000); - return ; + 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 ; + } } diff --git a/mylibrary/src/main/java/com/android/download/DownLoadManeger.java b/mylibrary/src/main/java/com/android/download/DownLoadManeger.java index 21c2cdb..6736546 100644 --- a/mylibrary/src/main/java/com/android/download/DownLoadManeger.java +++ b/mylibrary/src/main/java/com/android/download/DownLoadManeger.java @@ -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 { @@ -132,10 +133,17 @@ public class DownLoadManeger { for (DownLoadTaskBean downLoadTaskBean:list) { if(!TextUtils.isEmpty(downLoadTaskBean.getUrl())&&!TextUtils.isEmpty(downLoadTaskBean.getFileName())&&!TextUtils.isEmpty(downLoadTaskBean.getPath())){ 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().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()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"); diff --git a/mylibrary/src/main/java/com/android/download/DownLoadTaskThread.java b/mylibrary/src/main/java/com/android/download/DownLoadTaskThread.java index 9a0b368..90510c2 100644 --- a/mylibrary/src/main/java/com/android/download/DownLoadTaskThread.java +++ b/mylibrary/src/main/java/com/android/download/DownLoadTaskThread.java @@ -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 { diff --git a/mylibrary/src/main/java/com/android/nebulasdk/AppManager.java b/mylibrary/src/main/java/com/android/nebulasdk/AppManager.java index 7cfd127..5a69281 100644 --- a/mylibrary/src/main/java/com/android/nebulasdk/AppManager.java +++ b/mylibrary/src/main/java/com/android/nebulasdk/AppManager.java @@ -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"); } }