Skip to content

Commit

Permalink
在未发现新版本的位置增加日志,方便排查问题
Browse files Browse the repository at this point in the history
  • Loading branch information
xuexiangjys committed Mar 20, 2024
1 parent 64caecc commit 8f7cca1
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -335,7 +335,7 @@ public void findNewVersion(@NonNull UpdateEntity updateEntity, @NonNull IUpdateP
startDownload(updateEntity, mOnFileDownloadListener);
} else {
//已经下载好的直接安装
_XUpdate.startInstallApk(getContext(), UpdateUtils.getApkFileByUpdateEntity(mUpdateEntity), mUpdateEntity.getDownLoadEntity());
_XUpdate.startInstallApk(getContext(), mUpdateEntity);
}
} else {
if (mUpdateProxy != null) {
Expand Down
14 changes: 13 additions & 1 deletion xupdate-lib/src/main/java/com/xuexiang/xupdate/_XUpdate.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
import androidx.annotation.NonNull;

import com.xuexiang.xupdate.entity.DownloadEntity;
import com.xuexiang.xupdate.entity.UpdateEntity;
import com.xuexiang.xupdate.entity.UpdateError;
import com.xuexiang.xupdate.listener.OnInstallListener;
import com.xuexiang.xupdate.listener.OnUpdateFailureListener;
Expand All @@ -42,6 +43,7 @@
import com.xuexiang.xupdate.proxy.impl.DefaultFileEncryptor;
import com.xuexiang.xupdate.service.DownloadService;
import com.xuexiang.xupdate.utils.ApkInstallUtils;
import com.xuexiang.xupdate.utils.UpdateUtils;

import java.io.File;
import java.util.Map;
Expand Down Expand Up @@ -84,7 +86,7 @@ public final class _XUpdate {
/**
* 获取是否正在进行更新
*
* @param url 请求地址
* @param url 请求地址
*/
public static boolean isAppUpdating(String url) {
return DownloadService.isRunning() || _XUpdate.getCheckUrlStatus(url) || _XUpdate.isPrompterShow(url);
Expand Down Expand Up @@ -266,6 +268,16 @@ public static void startInstallApk(@NonNull Context context, @NonNull File apkFi
startInstallApk(context, apkFile, new DownloadEntity());
}

/**
* 开始安装apk文件
*
* @param context 传activity可以获取安装的返回值,详见{@link ApkInstallUtils#REQUEST_CODE_INSTALL_APP}
* @param updateEntity 版本更新信息实体
*/
public static void startInstallApk(@NonNull Context context, @NonNull UpdateEntity updateEntity) {
startInstallApk(context, UpdateUtils.getApkFileByUpdateEntity(updateEntity), updateEntity.getDownLoadEntity());
}

/**
* 开始安装apk文件
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ public static void processUpdateEntity(UpdateEntity updateEntity, @NonNull Strin
updateProxy.findNewVersion(updateEntity, updateProxy);
}
} else {
UpdateLog.i("未发现新版本, 解析后的版本更新信息如下:" + updateEntity);
updateProxy.noNewVersion(null);
}
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -426,7 +426,7 @@ private void showUpdateButton() {
}

private void onInstallApk() {
_XUpdate.startInstallApk(getContext(), UpdateUtils.getApkFileByUpdateEntity(mUpdateEntity), mUpdateEntity.getDownLoadEntity());
_XUpdate.startInstallApk(getContext(), mUpdateEntity);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -442,7 +442,7 @@ private void showUpdateButton() {
}

private void onInstallApk() {
_XUpdate.startInstallApk(this, UpdateUtils.getApkFileByUpdateEntity(mUpdateEntity), mUpdateEntity.getDownLoadEntity());
_XUpdate.startInstallApk(this, mUpdateEntity);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -491,7 +491,7 @@ private void showUpdateButton() {
}

private void onInstallApk() {
_XUpdate.startInstallApk(getContext(), UpdateUtils.getApkFileByUpdateEntity(mUpdateEntity), mUpdateEntity.getDownLoadEntity());
_XUpdate.startInstallApk(getContext(), mUpdateEntity);
}

/**
Expand Down

0 comments on commit 8f7cca1

Please sign in to comment.