Commit 2d37d0ee authored by T Dev. D's avatar T Dev. D 😎
Browse files

read Dojo version number

parent ca3c8796
......@@ -18,6 +18,7 @@ public class DojoUtil {
private static DojoUtil instance = null;
private static final String TAG = "DojoUtil";
private static Context context = null;
private static String dojoVersion = null;
private DojoUtil() { ; }
......@@ -109,6 +110,39 @@ public class DojoUtil {
}
public String getDojoVersion() {
return dojoVersion;
}
public void setDojoVersion(String version) {
dojoVersion = version;
}
public boolean isLikeType() {
if(dojoParams == null || dojoVersion == null) {
return false;
}
// version 1.11.x
String[] s = dojoVersion.split(".");
try {
if(s.length >= 1 && Integer.parseInt(s[0]) > 1) {
return true;
}
else if(s.length >= 2 && Integer.parseInt(s[0]) == 1 && Integer.parseInt(s[1]) >= 11){
return true;
}
else {
return false;
}
}
catch(NumberFormatException nfe) {
return false;
}
}
public String getVersion(String data) {
if(!isValidPairingPayload(data)) {
......
......@@ -6,6 +6,7 @@ import android.util.Log;
import com.samourai.wallet.BuildConfig;
import com.samourai.wallet.R;
import com.samourai.wallet.SamouraiWallet;
import com.samourai.wallet.network.dojo.DojoUtil;
import com.samourai.wallet.tor.TorManager;
import org.apache.commons.io.IOUtils;
......@@ -22,6 +23,7 @@ import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.concurrent.TimeUnit;
import javax.net.ssl.SSLContext;
......@@ -35,6 +37,7 @@ import ch.boye.httpclientandroidlib.client.methods.HttpDelete;
import ch.boye.httpclientandroidlib.message.BasicNameValuePair;
import info.guardianproject.netcipher.client.StrongHttpsClient;
import okhttp3.FormBody;
import okhttp3.Headers;
import okhttp3.MediaType;
import okhttp3.OkHttpClient;
import okhttp3.Request;
......@@ -42,6 +45,8 @@ import okhttp3.RequestBody;
import okhttp3.Response;
import okhttp3.logging.HttpLoggingInterceptor;
import static com.samourai.wallet.util.LogUtil.info;
//import android.util.Log;
public class WebUtil {
......@@ -376,6 +381,18 @@ public class WebUtil {
if(response.body() == null){
return "";
}
else if(DojoUtil.getInstance(context).getDojoParams() != null) {
Headers _headers = response.headers();
List<String> values = _headers.values("X-Dojo-Version");
if(values != null && values.size() > 0) {
info("WebUtil", "header:" + values.get(0));
DojoUtil.getInstance(context).setDojoVersion(values.get(0));
}
}
else {
;
}
return response.body().string();
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment