Skip to content

Commit

Permalink
Blackberry network fix (wifi only)
Browse files Browse the repository at this point in the history
  • Loading branch information
shinovon committed May 28, 2023
1 parent f478a5b commit dbdd220
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 4 deletions.
8 changes: 8 additions & 0 deletions src/mahomaps/MahoMapsApp.java
Original file line number Diff line number Diff line change
Expand Up @@ -295,4 +295,12 @@ public void commandAction(Command c, Displayable d) {
startApp();
}
}

public static String getConnectionParams() {
if (platform.toLowerCase().indexOf("blackberry") == -1) {
return "";
}
// сделать поддержку 3г когда-нибудь
return ";deviceside=true;interface=wifi";
}
}
2 changes: 1 addition & 1 deletion src/mahomaps/UpdateCheckThread.java
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ public void run() {
InputStream is = null;
ByteArrayOutputStream o = new ByteArrayOutputStream();
try {
hc = (HttpConnection) Connector.open(url);
hc = (HttpConnection) Connector.open(url + MahoMapsApp.getConnectionParams());
hc.setRequestMethod("GET");
int r = hc.getResponseCode();
is = hc.openInputStream();
Expand Down
5 changes: 3 additions & 2 deletions src/mahomaps/api/YmapsApiBase.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
import org.json.me.JSONArray;
import org.json.me.JSONObject;

import mahomaps.MahoMapsApp;
import mahomaps.Settings;

public abstract class YmapsApiBase {
Expand All @@ -31,7 +32,7 @@ protected final String GetToken(String key) throws Exception {
url = Settings.proxyServer + YmapsApiBase.EncodeUrl(url);
}
try {
hc = (HttpConnection) Connector.open(url);
hc = (HttpConnection) Connector.open(url + MahoMapsApp.getConnectionParams());
hc.setRequestMethod("GET");
hc.setRequestProperty("User-Agent",
"Mozilla/5.0 (Windows NT 6.3; WOW64; rv:49.0) Gecko/20100101 Firefox/49.0");
Expand Down Expand Up @@ -102,7 +103,7 @@ protected String GetUtf(String url) throws IOException, Http403Exception, Securi
url = Settings.proxyServer + YmapsApiBase.EncodeUrl(url);
}
System.out.println("GET " + url);
HttpConnection hc = (HttpConnection) Connector.open(url);
HttpConnection hc = (HttpConnection) Connector.open(url + MahoMapsApp.getConnectionParams());
InputStream is = null;
ByteArrayOutputStream o = null;
try {
Expand Down
2 changes: 1 addition & 1 deletion src/mahomaps/map/TilesProvider.java
Original file line number Diff line number Diff line change
Expand Up @@ -301,7 +301,7 @@ private Image download(TileId id) throws InterruptedException {
HttpConnection hc = null;
FileConnection fc = null;
try {
hc = (HttpConnection) Connector.open(getUrl(id));
hc = (HttpConnection) Connector.open(getUrl(id) + MahoMapsApp.getConnectionParams());
int len = (int) hc.getLength();
if (len <= 0)
throw new IOException("Empty responce");
Expand Down

0 comments on commit dbdd220

Please sign in to comment.