1.优化apk 安装过程中重启apk未安装未删除安装包修改为继续安装
This commit is contained in:
@@ -5,10 +5,12 @@ import android.content.Intent;
|
||||
import android.content.pm.ApplicationInfo;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.content.pm.ResolveInfo;
|
||||
import android.text.TextUtils;
|
||||
|
||||
import com.android.database.DaoManager;
|
||||
import com.android.database.lib.AdsInfoBean;
|
||||
import com.android.database.lib.AppBean;
|
||||
import com.android.database.lib.DownLoadTaskBean;
|
||||
import com.android.database.lib.LocalAppBean;
|
||||
import com.android.database.lib.MusicAppBean;
|
||||
import com.android.database.lib.NetShortAppBean;
|
||||
@@ -18,6 +20,7 @@ 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.FileUtil;
|
||||
import com.android.util.GsonUtil;
|
||||
import com.android.util.LogUtils;
|
||||
import com.android.util.PakageInstallUtil;
|
||||
@@ -588,7 +591,7 @@ public class AppManager {
|
||||
File file = new File(adsInfoBean.getLocalFilePath());
|
||||
if (file.exists()) {
|
||||
favNaviBean = new FavNaviBean(index, adsInfoBean.getLocalFilePath(), adsInfoBean.getInfo(), null);
|
||||
}else {
|
||||
}else {//考虑下载好图片重启后变回 -tmp文件的情况
|
||||
File tempFile=new File(adsInfoBean.getLocalFilePath()+"-tmp");
|
||||
if(tempFile.exists()&&tempFile.length()==adsInfoBean.getAdSize()){
|
||||
tempFile.renameTo(file);
|
||||
@@ -600,7 +603,38 @@ public class AppManager {
|
||||
}
|
||||
}
|
||||
}else {
|
||||
LogUtils.loge(adsInfoBean.getInfo()+" is not exit");
|
||||
LogUtils.loge(adsInfoBean.getInfo()+" is not exit");//考虑下载好APK重启后变回 -tmp文件的情况 补充clearApkFileByPowerDown 下载任务有脏数据情况下
|
||||
String appUrl = adsInfoBean.getAppUrl();
|
||||
boolean taskTableHasIt=false;
|
||||
List<DownLoadTaskBean> list = DaoManager.getInstance().queryList(DownLoadTaskBean.class);
|
||||
for (int i = 0; i <list.size() ; i++) {
|
||||
if(list.get(i).getUrl().equalsIgnoreCase(appUrl)){
|
||||
taskTableHasIt=true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if(!TextUtils.isEmpty(appUrl)&&!taskTableHasIt){
|
||||
int lastIndex = appUrl.lastIndexOf("/");
|
||||
String fileName=lastIndex==-1?appUrl:appUrl.substring(lastIndex+1);
|
||||
String filePath = FileUtil.getBakPath(mContext,1)+"/"+fileName;
|
||||
String tmpFilePath = FileUtil.getBakPath(mContext, 1) + "/" + fileName + "-tmp";
|
||||
File tmpFile=new File(tmpFilePath);
|
||||
File file =new File(filePath);
|
||||
if(tmpFile.exists()&&tmpFile.length()==adsInfoBean.getAppSize()){
|
||||
LogUtils.loge(adsInfoBean.getInfo()+" but apk tmpfile is exit");
|
||||
tmpFile.renameTo(file);
|
||||
//tmpFile.delete();
|
||||
if(list!=null&&list.size()>0){
|
||||
boolean flag = PakageInstallUtil.silentInstall(mContext, file.getAbsolutePath());
|
||||
LogUtils.loge("no task and restart sys apk back to tmp install result="+flag);
|
||||
}
|
||||
}else if(file.exists()&&file.length()==adsInfoBean.getAppSize()){
|
||||
if(list!=null&&list.size()>0){
|
||||
boolean flag = PakageInstallUtil.silentInstall(mContext, file.getAbsolutePath());
|
||||
LogUtils.loge("no task and restart sys apk not install result="+flag);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user