CustomUpdateConfigProvider.java 1.7 KB

1234567891011121314151617181920212223242526272829303132333435
  1. package com.emato.ich.update;
  2. import android.content.Context;
  3. import android.util.Log;
  4. import androidx.annotation.NonNull;
  5. import com.xuexiang.xupdate.aria.AriaDownloadServiceProxyImpl;
  6. import com.xuexiang.xupdate.easy.config.IUpdateConfigProvider;
  7. import com.xuexiang.xupdate.easy.config.UpdateConfig;
  8. import com.xuexiang.xupdate.utils.UpdateUtils;
  9. import org.jetbrains.annotations.NotNull;
  10. public class CustomUpdateConfigProvider implements IUpdateConfigProvider {
  11. private static final String TAG = CustomUpdateConfigProvider.class.getName();
  12. @NonNull
  13. @NotNull
  14. @Override
  15. public UpdateConfig getUpdateConfig(@NonNull @NotNull Context context) {
  16. return UpdateConfig.create()
  17. .setIsDebug(true) // 开启debug日志
  18. .setIsWifiOnly(false) // 设置非wifi更新
  19. .setIsGet(false) // 设置post方式获取下载参数
  20. .setIsAutoMode(true) // 设置自动更新
  21. .setParam("versionCode", UpdateUtils.getVersionCode(context)) // 设置默认公共请求参数
  22. .setParam("appKey", context.getPackageName())
  23. .setOnUpdateFailureListener(error -> {
  24. Log.i(TAG, "onCreate: =====================>自动更新失败! " + error.getCode() + ", " + error.getDetailMsg());
  25. })
  26. .setIsSupportSilentInstall(true); // 设置是否支持静默安装,默认是true
  27. }
  28. }