版本更新url获取优化

This commit is contained in:
jjLv 2025-05-08 18:05:18 +08:00
parent 3d338c2628
commit 1671ef3c3f
4 changed files with 22 additions and 8 deletions

View File

@ -156,8 +156,6 @@ public class OperationActivity extends BaseActivity<ActivityCanteenOperationBind
initData(); initData();
initListeners(); initListeners();
showPresentation(); showPresentation();
// 启动服务
startService(new Intent(this, HeartbeatService.class));
//判断是否存在当天订单 //判断是否存在当天订单
ThreadPoolManager.getExecutor().execute(() -> { ThreadPoolManager.getExecutor().execute(() -> {
BusinessDataInfo businessDataInfo = AppDatabase.getDatabase(this).businessDataDao().getBusinessDataInfoByDate(DateTimeHelper.getNowDate()); BusinessDataInfo businessDataInfo = AppDatabase.getDatabase(this).businessDataDao().getBusinessDataInfoByDate(DateTimeHelper.getNowDate());
@ -185,7 +183,8 @@ public class OperationActivity extends BaseActivity<ActivityCanteenOperationBind
// 显示屏幕分辨率在TextView上 // 显示屏幕分辨率在TextView上
String resolutionText = "屏幕分辨率:\n宽度" + widthPixels + " 像素\n高度" + heightPixels + " 像素"; String resolutionText = "屏幕分辨率:\n宽度" + widthPixels + " 像素\n高度" + heightPixels + " 像素";
Log.d(TAG, "resolutionText: " + resolutionText); Log.d(TAG, "resolutionText: " + resolutionText);
// 启动服务
startService(new Intent(this, HeartbeatService.class));
startService(new Intent(this, UpLoadDataService.class)); startService(new Intent(this, UpLoadDataService.class));
} }

View File

@ -19,8 +19,11 @@ package com.bonus.canteen.activity;
import android.view.KeyEvent; import android.view.KeyEvent;
import com.bonus.canteen.db.AppDatabase;
import com.bonus.canteen.db.entity.base.ParamSettingInfo;
import com.bonus.canteen.upgrade.UpdateDown; import com.bonus.canteen.upgrade.UpdateDown;
import com.bonus.canteen.utils.TokenUtils; import com.bonus.canteen.utils.TokenUtils;
import com.bonus.canteen.utils.WorkConfig;
import com.ccb.facedevice.sdk.utils.NetworkUtils; import com.ccb.facedevice.sdk.utils.NetworkUtils;
import com.xuexiang.xui.utils.KeyboardUtils; import com.xuexiang.xui.utils.KeyboardUtils;
import com.xuexiang.xui.widget.activity.BaseSplashActivity; import com.xuexiang.xui.widget.activity.BaseSplashActivity;
@ -64,7 +67,12 @@ public class SplashActivity extends BaseSplashActivity implements CancelAdapt {
private void loginOrGoMainPage() { private void loginOrGoMainPage() {
if (NetworkUtils.isNetworkConnected(this)) { if (NetworkUtils.isNetworkConnected(this)) {
new Thread(() -> { new Thread(() -> {
boolean isLatestVersion = down.checkUpdate(); ParamSettingInfo paramSettingInfo = AppDatabase.getDatabase(this).parameterInfoDao().getOneInfo();
String url = WorkConfig.getBaseUrl();
if (paramSettingInfo != null){
url = paramSettingInfo.getIpAddress() + "/smart-canteen";
}
boolean isLatestVersion = down.checkUpdate(url);
runOnUiThread(() -> { runOnUiThread(() -> {
if (!isLatestVersion) { if (!isLatestVersion) {
navigateToNextPage(); navigateToNextPage();

View File

@ -48,6 +48,7 @@ public class DownLoadDataService extends Service {
private List<String> methodList = new ArrayList<>(); private List<String> methodList = new ArrayList<>();
private WorkConfig workConfig;
@Nullable @Nullable
@Override @Override
@ -147,8 +148,10 @@ public class DownLoadDataService extends Service {
case "人员信息": case "人员信息":
return service.getPersonInfo(null,null,0); return service.getPersonInfo(null,null,0);
case "设备信息": case "设备信息":
workConfig = new WorkConfig();
return service.getDeviceBase(); return service.getDeviceBase();
case "基础参数": case "基础参数":
workConfig = new WorkConfig();
return service.getParamSettingInfo(); return service.getParamSettingInfo();
case "MQ_CONNECT": case "MQ_CONNECT":
return activateFaceEngine(); return activateFaceEngine();

View File

@ -1,5 +1,6 @@
package com.bonus.canteen.upgrade; package com.bonus.canteen.upgrade;
import android.annotation.SuppressLint;
import android.content.Context; import android.content.Context;
import android.os.Handler; import android.os.Handler;
import android.os.Message; import android.os.Message;
@ -36,8 +37,8 @@ public class UpdateDown {
/** /**
* 检测软件更新 * 检测软件更新
*/ */
public boolean checkUpdate() { public boolean checkUpdate(String url) {
VersionBean versionBean = isUpdate(); VersionBean versionBean = isUpdate(url);
if (versionBean != null) { if (versionBean != null) {
AppUpdate appUpdate = new AppUpdate.Builder() AppUpdate appUpdate = new AppUpdate.Builder()
//更新地址必传 //更新地址必传
@ -98,6 +99,7 @@ public class UpdateDown {
new UpdateManager().startUpdate(mContext, appUpdate); new UpdateManager().startUpdate(mContext, appUpdate);
} }
@SuppressLint("HandlerLeak")
private Handler handler = new Handler() { private Handler handler = new Handler() {
@Override @Override
public void handleMessage(Message msg) { public void handleMessage(Message msg) {
@ -113,13 +115,15 @@ public class UpdateDown {
* *
* @return * @return
*/ */
private VersionBean isUpdate() { private VersionBean isUpdate(String url) {
VersionBean versionBean = new VersionBean(); VersionBean versionBean = new VersionBean();
try { try {
// 获取当前软件版本 // 获取当前软件版本
int versionCode = getVersionCode(mContext); int versionCode = getVersionCode(mContext);
// 把version.xml放到网络上然后获取文件信息 // 把version.xml放到网络上然后获取文件信息
String path = WorkConfig.getBaseUrl() + "/api/android/device/getAppVersion";
String path = url + "/api/android/device/getAppVersion";
JSONObject json = new JSONObject(); JSONObject json = new JSONObject();
json.put("id", versionCode + ""); json.put("id", versionCode + "");
json.put("type", "1"); json.put("type", "1");