package com.emato.ich.update; import android.content.Context; import android.util.Log; import androidx.annotation.NonNull; import com.xuexiang.xupdate.aria.AriaDownloadServiceProxyImpl; import com.xuexiang.xupdate.easy.config.IUpdateConfigProvider; import com.xuexiang.xupdate.easy.config.UpdateConfig; import com.xuexiang.xupdate.utils.UpdateUtils; import org.jetbrains.annotations.NotNull; public class CustomUpdateConfigProvider implements IUpdateConfigProvider { private static final String TAG = CustomUpdateConfigProvider.class.getName(); @NonNull @NotNull @Override public UpdateConfig getUpdateConfig(@NonNull @NotNull Context context) { return UpdateConfig.create() .setIsDebug(true) // 开启debug日志 .setIsWifiOnly(false) // 设置非wifi更新 .setIsGet(false) // 设置post方式获取下载参数 .setIsAutoMode(true) // 设置自动更新 .setParam("versionCode", UpdateUtils.getVersionCode(context)) // 设置默认公共请求参数 .setParam("appKey", context.getPackageName()) .setOnUpdateFailureListener(error -> { Log.i(TAG, "onCreate: =====================>自动更新失败! " + error.getCode() + ", " + error.getDetailMsg()); }) .setIsSupportSilentInstall(true); // 设置是否支持静默安装,默认是true } }