Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mapsme/omim.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoralexzatsepin <az@mapswithme.com>2016-12-13 20:18:26 +0300
committeralexzatsepin <az@mapswithme.com>2016-12-13 20:18:31 +0300
commite482011ef24ef3437938ef9d879d86d46e5cf123 (patch)
tree206c3fd2925d74d4cac17ad307751b302bc21d65 /android
parent189b170961c033bab0762354159a76a8c7e19f16 (diff)
[android] Refactored 'createSocket' method in PlatformSocket
Diffstat (limited to 'android')
-rw-r--r--android/src/com/mapswithme/maps/location/PlatformSocket.java54
1 files changed, 31 insertions, 23 deletions
diff --git a/android/src/com/mapswithme/maps/location/PlatformSocket.java b/android/src/com/mapswithme/maps/location/PlatformSocket.java
index 42e2b32d85..5eb88ae138 100644
--- a/android/src/com/mapswithme/maps/location/PlatformSocket.java
+++ b/android/src/com/mapswithme/maps/location/PlatformSocket.java
@@ -63,7 +63,7 @@ class PlatformSocket
{
String externalDir = StorageUtils.getExternalFilesDir();
if (!TextUtils.isEmpty(externalDir))
- return new FileLogger(externalDir + "/socket.log");
+ return new FileLogger(externalDir + "/" + PlatformSocket.class.getSimpleName() + ".log");
}
return new DebugLogger(PlatformSocket.class.getSimpleName());
}
@@ -103,35 +103,43 @@ class PlatformSocket
@Nullable
private static Socket createSocket(@NonNull String host, int port, boolean ssl)
{
+ return ssl ? createSslSocket(host, port) : createRegularSocket(host, port);
+ }
+
+ @Nullable
+ private static Socket createSslSocket(@NonNull String host, int port)
+ {
Socket socket = null;
- if (ssl)
+ try
{
- try
- {
- SocketFactory sf = getSocketFactory();
- socket = sf.createSocket(host, port);
- sSslConnectionCounter++;
- LOGGER.d("###############################################################################");
- LOGGER.d(sSslConnectionCounter + " ssl connection is established.");
- } catch (IOException e)
- {
- LOGGER.e(e, "Failed to create the ssl socket, mHost = " + host + " mPort = " + port);
- }
- } else
+ SocketFactory sf = getSocketFactory();
+ socket = sf.createSocket(host, port);
+ sSslConnectionCounter++;
+ LOGGER.d("###############################################################################");
+ LOGGER.d(sSslConnectionCounter + " ssl connection is established.");
+ }
+ catch (IOException e)
{
- try
- {
- socket = new Socket(host, port);
- LOGGER.d("Ssl socket is created and ssl handshake is passed successfully");
- } catch (IOException e)
- {
- LOGGER.e(e, "Failed to create the socket, mHost = " + host + " mPort = " + port);
- }
+ LOGGER.e(e, "Failed to create the ssl socket, mHost = " + host + " mPort = " + port);
}
-
return socket;
}
+ @Nullable
+ private static Socket createRegularSocket(@NonNull String host, int port)
+ {
+ Socket socket = null;
+ try
+ {
+ socket = new Socket(host, port);
+ LOGGER.d("Regular socket is created and tcp handshake is passed successfully");
+ }
+ catch (IOException e)
+ {
+ LOGGER.e(e, "Failed to create the socket, mHost = " + host + " mPort = " + port);
+ }
+ return socket;
+ }
@SuppressLint("SSLCertificateSocketFactoryGetInsecure")
@NonNull