From dbdd220226fac1834a909ab46ad04ced8f0843a0 Mon Sep 17 00:00:00 2001 From: Shinovon Date: Mon, 29 May 2023 00:06:53 +0500 Subject: [PATCH 1/2] Blackberry network fix (wifi only) --- src/mahomaps/MahoMapsApp.java | 8 ++++++++ src/mahomaps/UpdateCheckThread.java | 2 +- src/mahomaps/api/YmapsApiBase.java | 5 +++-- src/mahomaps/map/TilesProvider.java | 2 +- 4 files changed, 13 insertions(+), 4 deletions(-) diff --git a/src/mahomaps/MahoMapsApp.java b/src/mahomaps/MahoMapsApp.java index e69d35d2..2e2f8afd 100644 --- a/src/mahomaps/MahoMapsApp.java +++ b/src/mahomaps/MahoMapsApp.java @@ -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"; + } } diff --git a/src/mahomaps/UpdateCheckThread.java b/src/mahomaps/UpdateCheckThread.java index 894dcac6..4421edb0 100644 --- a/src/mahomaps/UpdateCheckThread.java +++ b/src/mahomaps/UpdateCheckThread.java @@ -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(); diff --git a/src/mahomaps/api/YmapsApiBase.java b/src/mahomaps/api/YmapsApiBase.java index 25a0903b..8bcf46cb 100644 --- a/src/mahomaps/api/YmapsApiBase.java +++ b/src/mahomaps/api/YmapsApiBase.java @@ -14,6 +14,7 @@ import org.json.me.JSONArray; import org.json.me.JSONObject; +import mahomaps.MahoMapsApp; import mahomaps.Settings; public abstract class YmapsApiBase { @@ -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"); @@ -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 { diff --git a/src/mahomaps/map/TilesProvider.java b/src/mahomaps/map/TilesProvider.java index a45827f0..3990136c 100644 --- a/src/mahomaps/map/TilesProvider.java +++ b/src/mahomaps/map/TilesProvider.java @@ -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"); From 32fb268528fb6abba5d665a91b637812d66dcfba Mon Sep 17 00:00:00 2001 From: Shinovon Date: Mon, 29 May 2023 00:09:09 +0500 Subject: [PATCH 2/2] tab fix --- src/mahomaps/MahoMapsApp.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/mahomaps/MahoMapsApp.java b/src/mahomaps/MahoMapsApp.java index 2e2f8afd..66905006 100644 --- a/src/mahomaps/MahoMapsApp.java +++ b/src/mahomaps/MahoMapsApp.java @@ -297,7 +297,7 @@ public void commandAction(Command c, Displayable d) { } public static String getConnectionParams() { - if (platform.toLowerCase().indexOf("blackberry") == -1) { + if (platform.toLowerCase().indexOf("blackberry") == -1) { return ""; } // сделать поддержку 3г когда-нибудь