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"); } }