use of com.eros.framework.manager.impl.VersionManager in project WeexErosFramework by bmfe.
the class VersionChecker method downloadCompleteZip.
/**
* 下载全量包
*/
private void downloadCompleteZip() {
VersionManager versionManager = ManagerFactory.getManagerService(VersionManager.class);
versionManager.checkBundleUpdate(mContext, mUpdateUrl, false, new StringCallback() {
@Override
public void onError(Call call, Exception e, int id) {
L.e(TAG, "检查全量包失败!,更新失败");
mCurrentStatus = Constant.Version.SLEEP;
postFailed("检查全量包失败!,更新失败");
}
@Override
public void onResponse(String response, int id) {
VersionBean version = ManagerFactory.getManagerService(ParseManager.class).parseObject(response, VersionBean.class);
if (version != null && !TextUtils.isEmpty(version.data.path)) {
L.e(TAG, "检查全量包成功!,开始下载");
download(version, true);
}
}
});
}
use of com.eros.framework.manager.impl.VersionManager in project WeexErosFramework by bmfe.
the class VersionChecker method readyUpdate.
private void readyUpdate(String path, boolean diff) {
mUpdateUrl = BMWXEnvironment.mPlatformConfig.getUrl().getBundleUpdate();
if (!TextUtils.isEmpty(path)) {
mUpdateUrl = path;
}
if (TextUtils.isEmpty(mUpdateUrl))
return;
if (Constant.INTERCEPTOR_ACTIVE.equals(SharePreferenceUtil.getInterceptorActive(mContext))) {
mCurrentStatus = Constant.Version.UPDATING;
VersionManager versionManager = ManagerFactory.getManagerService(VersionManager.class);
versionManager.checkBundleUpdate(mContext, mUpdateUrl, diff, new StringCallback() {
@Override
public void onError(Call call, Exception e, int id) {
Log.e(TAG, "获取更新失败");
postFailed("获取更新失败");
mCurrentStatus = Constant.Version.SLEEP;
}
@Override
public void onResponse(String response, int id) {
VersionBean version = ManagerFactory.getManagerService(ParseManager.class).parseObject(response, VersionBean.class);
if (version == null) {
Log.e(TAG, "返回结果异常");
postFailed("返回结果异常");
mCurrentStatus = Constant.Version.SLEEP;
return;
}
switch(version.resCode) {
case // 需要更新
0:
if (!TextUtils.isEmpty(version.data.path)) {
if (version.data.diff) {
// 更新插分包
Log.e(TAG, "检查插分包");
download(version, false);
} else {
// 下载全量包
Log.e(TAG, "检查全量包");
downloadCompleteZip();
}
} else {
// 下载全量包
Log.e(TAG, "检查全量包");
downloadCompleteZip();
}
break;
case 401:
Log.e(TAG, "JS文件查询失败!");
postFailed("JS文件查询失败");
mCurrentStatus = Constant.Version.SLEEP;
break;
case 4000:
Log.e(TAG, "当前版本已是最新!");
postFailed("当前版本已是最新");
mCurrentStatus = Constant.Version.SLEEP;
break;
default:
Log.e(TAG, "resCode:" + version.resCode);
postFailed("resCode:" + version.resCode);
mCurrentStatus = Constant.Version.SLEEP;
break;
}
}
});
}
}
use of com.eros.framework.manager.impl.VersionManager in project WeexErosFramework by bmfe.
the class VersionChecker method download.
/**
* 下载包
*/
public void download(final VersionBean version, final boolean complete) {
try {
if (version == null) {
mCurrentStatus = Constant.Version.SLEEP;
return;
}
VersionManager versionManager = ManagerFactory.getManagerService(VersionManager.class);
versionManager.downloadBundle(version.data.path, new FileCallBack(FileManager.getTempBundleDir(mContext).getAbsolutePath(), version.data.diff ? FileManager.PATCH_NAME : FileManager.TEMP_BUNDLE_NAME) {
@Override
public void onError(Call call, Exception e, int id) {
Log.e(TAG, "下载插分包出错");
if (!complete) {
downloadCompleteZip();
} else {
postFailed("下载全量包失败");
mCurrentStatus = Constant.Version.SLEEP;
}
}
@Override
public void onResponse(File response, int id) {
Log.e("version", "下载成功" + response.getAbsolutePath());
if (version.data.diff) {
bsPatch();
} else {
File download = new File(FileManager.getTempBundleDir(mContext), FileManager.TEMP_BUNDLE_NAME);
if (checkZipValidate(download)) {
RenameDeleteFile();
// 更改本地jsversion
SharePreferenceUtil.setDownLoadVersion(mContext, ManagerFactory.getManagerService(ParseManager.class).toJsonString(newVersion));
newVersion = null;
mCurrentStatus = Constant.Version.SLEEP;
notifyUpdate();
} else {
L.e(TAG, "更新包md5校验失败,更新失败");
FileManager.deleteFile(new File(FileManager.getTempBundleDir(mContext), FileManager.TEMP_BUNDLE_NAME));
newVersion = null;
mCurrentStatus = Constant.Version.SLEEP;
postFailed("更新包md5校验失败,更新失败");
}
}
}
});
} catch (Exception e) {
mCurrentStatus = Constant.Version.SLEEP;
e.printStackTrace();
}
}
use of com.eros.framework.manager.impl.VersionManager in project WeexErosFramework by bmfe.
the class SplashActivityProxy method init.
private void init(final Activity activity) {
final VersionManager versionManager = ManagerFactory.getManagerService(VersionManager.class);
new Thread(new Runnable() {
@Override
public void run() {
long prepareTime = versionManager.prepareJsBundle(activity);
mHandler.postDelayed(new Runnable() {
@Override
public void run() {
toHome(activity);
}
}, 1500 - prepareTime);
}
}).start();
initTabbar(activity);
}
use of com.eros.framework.manager.impl.VersionManager in project WeexErosFramework by bmfe.
the class DefaultWXHttpAdapter method findMd5.
private String findMd5(String path) {
List<Md5MapperModel.Item> lists = ManagerFactory.getManagerService(PersistentManager.class).getFileMapper();
if (lists == null) {
VersionManager versionManager = ManagerFactory.getManagerService(VersionManager.class);
versionManager.initMapper(BMWXEnvironment.mApplicationContext);
lists = ManagerFactory.getManagerService(PersistentManager.class).getFileMapper();
}
for (Md5MapperModel.Item item : lists) {
if (path.endsWith(item.getPage())) {
return item.getMd5();
}
}
return "";
}
Aggregations