...
 
Commits (12)
......@@ -108,6 +108,6 @@ dependencies {
implementation "net.gotev:uploadservice:$uploadServiceVersion"
implementation "net.gotev:uploadservice-okhttp:$uploadServiceVersion"
implementation "info.guardianproject.netcipher:netcipher:$netCipherVersion"
implementation "info.guardianproject.netcipher:netcipher:2.1.0"
implementation "info.guardianproject.netcipher:netcipher-okhttp3:$netCipherVersion"
}
......@@ -669,8 +669,11 @@ public abstract class BaseMainActivity extends BaseActivity
changeDrawableColor(getApplicationContext(), R.drawable.ic_recently_added,R.color.dark_text);
}
if( social == UpdateAccountInfoAsyncTask.SOCIAL.MASTODON || social == UpdateAccountInfoAsyncTask.SOCIAL.PLEROMA)
startSreaming();
if( social == UpdateAccountInfoAsyncTask.SOCIAL.MASTODON || social == UpdateAccountInfoAsyncTask.SOCIAL.PLEROMA) {
if( Build.VERSION.SDK_INT > Build.VERSION_CODES.KITKAT ) {
startSreaming();
}
}
toolbar_search.setOnQueryTextListener(new SearchView.OnQueryTextListener() {
......
......@@ -16,6 +16,7 @@ package app.fedilab.android.activities;
import android.content.Context;
import android.content.SharedPreferences;
import android.os.Build;
import android.os.StrictMode;
import androidx.multidex.MultiDex;
import androidx.multidex.MultiDexApplication;
......@@ -26,6 +27,11 @@ import com.franmontiel.localechanger.LocaleChanger;
import net.gotev.uploadservice.UploadService;
import java.net.Authenticator;
import java.net.InetSocketAddress;
import java.net.PasswordAuthentication;
import java.net.Proxy;
import java.net.SocketAddress;
import java.util.ArrayList;
import java.util.List;
import java.util.Locale;
......@@ -36,6 +42,8 @@ import app.fedilab.android.jobs.NotificationsSyncJob;
import es.dmoral.toasty.Toasty;
import app.fedilab.android.BuildConfig;
import app.fedilab.android.R;
import info.guardianproject.netcipher.NetCipher;
import info.guardianproject.netcipher.proxy.OrbotHelper;
import static app.fedilab.android.helper.Helper.initNetCipher;
......@@ -59,9 +67,10 @@ public class MainApplication extends MultiDexApplication {
NotificationsSyncJob.schedule(false);
StrictMode.VmPolicy.Builder builder = new StrictMode.VmPolicy.Builder();
StrictMode.setVmPolicy(builder.build());
SharedPreferences sharedpreferences = getSharedPreferences(Helper.APP_PREFS, android.content.Context.MODE_PRIVATE);
try {
List<Locale> SUPPORTED_LOCALES = new ArrayList<>();
SharedPreferences sharedpreferences = getSharedPreferences(Helper.APP_PREFS, android.content.Context.MODE_PRIVATE);
String defaultLocaleString = sharedpreferences.getString(Helper.SET_DEFAULT_LOCALE_NEW, null);
if( defaultLocaleString != null){
Locale defaultLocale;
......@@ -79,7 +88,38 @@ public class MainApplication extends MultiDexApplication {
}catch (Exception ignored){}
//Initialize upload service
UploadService.NAMESPACE = BuildConfig.APPLICATION_ID;
initNetCipher(this);
if (Build.VERSION.SDK_INT >= 24) {
boolean proxyEnabled = sharedpreferences.getBoolean(Helper.SET_PROXY_ENABLED, false);
int type = sharedpreferences.getInt(Helper.SET_PROXY_TYPE, 0);
if( proxyEnabled){
String host = sharedpreferences.getString(Helper.SET_PROXY_HOST, "127.0.0.1");
int port = sharedpreferences.getInt(Helper.SET_PROXY_PORT, 8118);
SocketAddress sa = new InetSocketAddress(host, port);
if( type == 0 ) {
NetCipher.setProxy(new Proxy(Proxy.Type.HTTP, sa));
}else{
NetCipher.setProxy(new Proxy(Proxy.Type.SOCKS, sa));
}
final String login = sharedpreferences.getString(Helper.SET_PROXY_LOGIN, null);
final String pwd = sharedpreferences.getString(Helper.SET_PROXY_PASSWORD, null);
if( login != null) {
Authenticator authenticator = new Authenticator() {
public PasswordAuthentication getPasswordAuthentication() {
assert pwd != null;
return (new PasswordAuthentication(login,
pwd.toCharArray()));
}
};
Authenticator.setDefault(authenticator);
}
NetCipher.useGlobalProxy();
}
}
if( OrbotHelper.isOrbotInstalled(getApplicationContext()) && OrbotHelper.isOrbotRunning(getApplicationContext())){
NetCipher.useTor();
}
Toasty.Config.getInstance()
.setErrorColor(ContextCompat.getColor(getApplicationContext(), R.color.toasty_background))
.setInfoColor(ContextCompat.getColor(getApplicationContext(), R.color.toasty_background))
......
......@@ -448,7 +448,7 @@ public class MediaActivity extends BaseActivity implements OnDownloadInterface {
pbar_inf.setIndeterminate(false);
pbar_inf.setScaleY(3f);
try {
HttpsURLConnection.setDefaultSSLSocketFactory(new TLSSocketFactory(instance));
HttpsURLConnection.setDefaultSSLSocketFactory(new TLSSocketFactory());
} catch (KeyManagementException e) {
e.printStackTrace();
} catch (NoSuchAlgorithmException e) {
......
......@@ -622,7 +622,7 @@ public class PeertubeActivity extends BaseActivity implements OnRetrievePeertube
}
try {
HttpsURLConnection.setDefaultSSLSocketFactory(new TLSSocketFactory(instance));
HttpsURLConnection.setDefaultSSLSocketFactory(new TLSSocketFactory());
} catch (KeyManagementException e) {
e.printStackTrace();
} catch (NoSuchAlgorithmException e) {
......
......@@ -72,6 +72,7 @@ import app.fedilab.android.asynctasks.RetrievePeertubeChannelsAsyncTask;
import app.fedilab.android.interfaces.OnRetrievePeertubeInterface;
import static app.fedilab.android.asynctasks.RetrievePeertubeInformationAsyncTask.peertubeInformation;
import static app.fedilab.android.helper.Helper.initNetCipher;
public class PeertubeUploadActivity extends BaseActivity implements OnRetrievePeertubeInterface, UploadStatusDelegate {
......@@ -131,7 +132,7 @@ public class PeertubeUploadActivity extends BaseActivity implements OnRetrievePe
}
}
setContentView(R.layout.activity_peertube_upload);
initNetCipher(getApplicationContext());
set_upload_file = findViewById(R.id.set_upload_file);
set_upload_file_name = findViewById(R.id.set_upload_file_name);
set_upload_channel = findViewById(R.id.set_upload_channel);
......
......@@ -18,6 +18,7 @@ package app.fedilab.android.activities;
import android.content.Context;
import android.content.SharedPreferences;
import android.os.Build;
import android.os.Bundle;
import androidx.core.content.ContextCompat;
import android.view.MenuItem;
......@@ -31,8 +32,15 @@ import android.widget.CheckBox;
import android.widget.EditText;
import android.widget.Spinner;
import java.net.Authenticator;
import java.net.InetSocketAddress;
import java.net.PasswordAuthentication;
import java.net.Proxy;
import java.net.SocketAddress;
import app.fedilab.android.helper.Helper;
import app.fedilab.android.R;
import info.guardianproject.netcipher.NetCipher;
/**
......@@ -141,6 +149,33 @@ public class ProxyActivity extends BaseActivity {
editor.putString(Helper.SET_PROXY_LOGIN, proxy_loginVal);
editor.putString(Helper.SET_PROXY_PASSWORD, proxy_passwordVal);
editor.apply();
if (Build.VERSION.SDK_INT >= 24) {
if( set_enable_proxy.isChecked() ){
String host = sharedpreferences.getString(Helper.SET_PROXY_HOST, "127.0.0.1");
int port = sharedpreferences.getInt(Helper.SET_PROXY_PORT, 8118);
SocketAddress sa = new InetSocketAddress(host, port);
if( sharedpreferences.getInt(Helper.SET_PROXY_TYPE, 0) == 0 ) {
NetCipher.setProxy(new Proxy(Proxy.Type.HTTP, sa));
}else{
NetCipher.setProxy(new Proxy(Proxy.Type.SOCKS, sa));
}
final String login = sharedpreferences.getString(Helper.SET_PROXY_LOGIN, null);
final String pwd = sharedpreferences.getString(Helper.SET_PROXY_PASSWORD, null);
if( login != null) {
Authenticator authenticator = new Authenticator() {
public PasswordAuthentication getPasswordAuthentication() {
assert pwd != null;
return (new PasswordAuthentication(login,
pwd.toCharArray()));
}
};
Authenticator.setDefault(authenticator);
}
NetCipher.useGlobalProxy();
}else{
NetCipher.clearProxy();
}
}
finish();
}
});
......
......@@ -183,7 +183,6 @@ import es.dmoral.toasty.Toasty;
import static app.fedilab.android.helper.Helper.changeDrawableColor;
import static app.fedilab.android.helper.Helper.countWithEmoji;
import static app.fedilab.android.helper.Helper.initNetCipher;
import static app.fedilab.android.helper.Helper.orbotConnected;
/**
* Created by Thomas on 01/05/2017.
......@@ -288,6 +287,7 @@ public class TootActivity extends BaseActivity implements UploadStatusDelegate,
} else {
max_media_count = 4;
}
initNetCipher(getApplicationContext());
autocomplete = false;
setContentView(R.layout.activity_toot);
ActionBar actionBar = getSupportActionBar();
......
......@@ -114,11 +114,7 @@ public class RetrieveMetaDataAsyncTask extends AsyncTask<Void, Void, Void> {
if( descriptionEncoded != null)
description = Html.fromHtml(descriptionEncoded).toString();
}
} catch (NoSuchAlgorithmException e) {
e.printStackTrace();
} catch (KeyManagementException e) {
e.printStackTrace();
} catch (HttpsConnection.HttpsConnectionException e) {
}catch (HttpsConnection.HttpsConnectionException e) {
e.printStackTrace();
}
}
......
......@@ -20,9 +20,6 @@ import org.json.JSONException;
import org.json.JSONObject;
import java.io.IOException;
import java.security.KeyManagementException;
import java.security.NoSuchAlgorithmException;
import app.fedilab.android.client.Entities.Error;
import app.fedilab.android.client.Entities.Results;
......@@ -60,12 +57,8 @@ public class CustomSharing {
} catch (HttpsConnection.HttpsConnectionException e) {
e.printStackTrace();
setError(e.getStatusCode(), e);
} catch (NoSuchAlgorithmException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
} catch (KeyManagementException e) {
e.printStackTrace();
}
customSharingResponse.setResponse(HTTPResponse);
return customSharingResponse;
......
This source diff could not be displayed because it is too large. You can view the blob instead.
......@@ -31,32 +31,10 @@ public class TLSSocketFactory extends SSLSocketFactory {
private SSLContext sslContext;
private boolean isOnion;
public TLSSocketFactory(String instance) throws KeyManagementException, NoSuchAlgorithmException {
if( instance == null || !instance.endsWith(".onion")) {
sslContext = SSLContext.getInstance("TLS");
isOnion = false;
sslContext.init(null, null, null);
}else{
sslContext = SSLContext.getInstance("SSL");
isOnion = true;
TrustManager[] trustAllCerts = new TrustManager[]{
new X509TrustManager() {
public java.security.cert.X509Certificate[] getAcceptedIssuers() {
return null;
}
public void checkClientTrusted(
java.security.cert.X509Certificate[] certs, String authType) {
}
public void checkServerTrusted(
java.security.cert.X509Certificate[] certs, String authType) {
}
}
};
sslContext.init(null, trustAllCerts, null);
}
public TLSSocketFactory() throws KeyManagementException, NoSuchAlgorithmException {
sslContext = SSLContext.getInstance("TLS");
isOnion = false;
sslContext.init(null, null, null);
sSLSocketFactory = sslContext.getSocketFactory();
}
......@@ -118,11 +96,11 @@ public class TLSSocketFactory extends SSLSocketFactory {
security_provider = sharedpreferences.getBoolean(Helper.SET_SECURITY_PROVIDER, true);
}catch (Exception ignored){}
if( security_provider)
((SSLSocket)socket).setEnabledProtocols(new String[] {"TLSv1.1", "TLSv1.2", "TLSv1.3"});
((SSLSocket)socket).setEnabledProtocols(new String[] {"TLSv1.2", "TLSv1.3"});
else
((SSLSocket)socket).setEnabledProtocols(new String[] {"TLSv1.1", "TLSv1.2"});
((SSLSocket)socket).setEnabledProtocols(new String[] {"TLSv1.2"});
}else{
((SSLSocket)socket).setEnabledProtocols(new String[] {"TLSv1.1", "TLSv1.2",});
((SSLSocket)socket).setEnabledProtocols(new String[] {"TLSv1.2",});
}
}
return socket;
......
package app.fedilab.android.client;
import android.content.SharedPreferences;
import java.io.IOException;
import java.net.InetAddress;
import java.net.Socket;
import java.security.KeyManagementException;
import java.security.NoSuchAlgorithmException;
import javax.net.ssl.SSLContext;
import javax.net.ssl.SSLEngine;
import javax.net.ssl.SSLSocket;
import javax.net.ssl.SSLSocketFactory;
import javax.net.ssl.TrustManager;
import javax.net.ssl.X509TrustManager;
import app.fedilab.android.activities.MainApplication;
import app.fedilab.android.helper.Helper;
/**
* Created by Thomas on 13/06/2019
*
*/
public class TLSSocketFactoryTor extends SSLSocketFactory {
private SSLSocketFactory sSLSocketFactory;
private SSLContext sslContext;
private boolean isOnion;
public TLSSocketFactoryTor() throws KeyManagementException, NoSuchAlgorithmException {
sslContext = SSLContext.getInstance("SSL");
isOnion = true;
TrustManager[] trustAllCerts = new TrustManager[]{
new X509TrustManager() {
public java.security.cert.X509Certificate[] getAcceptedIssuers() {
return null;
}
public void checkClientTrusted(
java.security.cert.X509Certificate[] certs, String authType) {
}
public void checkServerTrusted(
java.security.cert.X509Certificate[] certs, String authType) {
}
}
};
sslContext.init(null, trustAllCerts, null);
sSLSocketFactory = sslContext.getSocketFactory();
}
public SSLContext getSSLContext(){
return this.sslContext;
}
public SSLEngine getSSLEngine(){
return this.sslContext.createSSLEngine();
}
@Override
public String[] getDefaultCipherSuites() {
return sSLSocketFactory.getDefaultCipherSuites();
}
@Override
public String[] getSupportedCipherSuites() {
return sSLSocketFactory.getSupportedCipherSuites();
}
@Override
public Socket createSocket() throws IOException {
return enableTLSOnSocket(sSLSocketFactory.createSocket());
}
@Override
public Socket createSocket(Socket s, String host, int port, boolean autoClose) throws IOException {
return enableTLSOnSocket(sSLSocketFactory.createSocket(s, host, port, autoClose));
}
@Override
public Socket createSocket(String host, int port) throws IOException {
return enableTLSOnSocket(sSLSocketFactory.createSocket(host, port));
}
@Override
public Socket createSocket(String host, int port, InetAddress localHost, int localPort) throws IOException {
return enableTLSOnSocket(sSLSocketFactory.createSocket(host, port, localHost, localPort));
}
@Override
public Socket createSocket(InetAddress host, int port) throws IOException {
return enableTLSOnSocket(sSLSocketFactory.createSocket(host, port));
}
@Override
public Socket createSocket(InetAddress address, int port, InetAddress localAddress, int localPort) throws IOException {
return enableTLSOnSocket(sSLSocketFactory.createSocket(address, port, localAddress, localPort));
}
private Socket enableTLSOnSocket(Socket socket) {
if((socket instanceof SSLSocket)) {
if( !isOnion){
boolean security_provider = false;
try {
SharedPreferences sharedpreferences = MainApplication.getApp().getSharedPreferences(Helper.APP_PREFS, android.content.Context.MODE_PRIVATE);
security_provider = sharedpreferences.getBoolean(Helper.SET_SECURITY_PROVIDER, true);
}catch (Exception ignored){}
if( security_provider)
((SSLSocket)socket).setEnabledProtocols(new String[] {"TLSv1.2", "TLSv1.3"});
else
((SSLSocket)socket).setEnabledProtocols(new String[] {"TLSv1.2"});
}else{
((SSLSocket)socket).setEnabledProtocols(new String[] { "TLSv1.2",});
}
}
return socket;
}
}
\ No newline at end of file
......@@ -22,6 +22,7 @@ import android.content.IntentFilter;
import android.content.SharedPreferences;
import android.database.sqlite.SQLiteDatabase;
import android.os.AsyncTask;
import android.os.Build;
import android.os.Bundle;
import android.os.Handler;
import android.os.Looper;
......@@ -644,10 +645,13 @@ public class DisplayStatusFragment extends Fragment implements OnRetrieveFeedsIn
editor.putBoolean(Helper.SHOULD_CONTINUE_STREAMING_FEDERATED + userId + instance, true);
editor.apply();
if(liveNotifications && batteryProfile == Helper.BATTERY_PROFILE_NORMAL) {
streamingFederatedIntent = new Intent(context, StreamingFederatedTimelineService.class);
try {
context.startService(streamingFederatedIntent);
}catch (Exception ignored){}
if( Build.VERSION.SDK_INT > Build.VERSION_CODES.KITKAT ) {
streamingFederatedIntent = new Intent(context, StreamingFederatedTimelineService.class);
try {
context.startService(streamingFederatedIntent);
}catch (Exception ignored){}
}
}
if( statuses != null && statuses.size() > 0)
retrieveMissingToots(statuses.get(0).getId());
......@@ -659,10 +663,13 @@ public class DisplayStatusFragment extends Fragment implements OnRetrieveFeedsIn
editor.putBoolean(Helper.SHOULD_CONTINUE_STREAMING_LOCAL + userId + instance, true);
editor.apply();
if( liveNotifications && batteryProfile == Helper.BATTERY_PROFILE_NORMAL) {
streamingLocalIntent = new Intent(context, StreamingLocalTimelineService.class);
try {
context.startService(streamingLocalIntent);
}catch (Exception ignored){}
if( Build.VERSION.SDK_INT > Build.VERSION_CODES.KITKAT ) {
streamingLocalIntent = new Intent(context, StreamingLocalTimelineService.class);
try {
context.startService(streamingLocalIntent);
} catch (Exception ignored) {
}
}
}
if( statuses != null && statuses.size() > 0)
retrieveMissingToots(statuses.get(0).getId());
......@@ -745,10 +752,13 @@ public class DisplayStatusFragment extends Fragment implements OnRetrieveFeedsIn
editor.putBoolean(Helper.SHOULD_CONTINUE_STREAMING_FEDERATED + userId + instance, true);
editor.apply();
if(liveNotifications && batteryProfile == Helper.BATTERY_PROFILE_NORMAL) {
streamingFederatedIntent = new Intent(context, StreamingFederatedTimelineService.class);
try {
context.startService(streamingFederatedIntent);
}catch (Exception ignored){}
if( Build.VERSION.SDK_INT > Build.VERSION_CODES.KITKAT ) {
streamingFederatedIntent = new Intent(context, StreamingFederatedTimelineService.class);
try {
context.startService(streamingFederatedIntent);
} catch (Exception ignored) {
}
}
}
if( statuses != null && statuses.size() > 0)
retrieveMissingToots(statuses.get(0).getId());
......@@ -766,10 +776,13 @@ public class DisplayStatusFragment extends Fragment implements OnRetrieveFeedsIn
editor.putBoolean(Helper.SHOULD_CONTINUE_STREAMING_LOCAL + userId + instance, true);
editor.apply();
if( liveNotifications && batteryProfile == Helper.BATTERY_PROFILE_NORMAL) {
streamingLocalIntent = new Intent(context, StreamingLocalTimelineService.class);
try {
context.startService(streamingLocalIntent);
}catch (Exception ignored){}
if( Build.VERSION.SDK_INT > Build.VERSION_CODES.KITKAT ) {
streamingLocalIntent = new Intent(context, StreamingLocalTimelineService.class);
try {
context.startService(streamingLocalIntent);
} catch (Exception ignored) {
}
}
}
if( statuses != null && statuses.size() > 0)
retrieveMissingToots(statuses.get(0).getId());
......
......@@ -149,6 +149,7 @@ import java.lang.ref.WeakReference;
import java.lang.reflect.Type;
import java.net.HttpURLConnection;
import java.net.InetAddress;
import java.security.KeyManagementException;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
import java.security.Security;
......@@ -185,6 +186,7 @@ import app.fedilab.android.client.Entities.Status;
import app.fedilab.android.client.Entities.Tag;
import app.fedilab.android.client.Entities.TagTimeline;
import app.fedilab.android.client.Entities.Version;
import app.fedilab.android.client.TLSSocketFactory;
import app.fedilab.android.client.Tls12SocketFactory;
import es.dmoral.toasty.Toasty;
import app.fedilab.android.BuildConfig;
......
/* Copyright 2017 Thomas Schneider
*
* This file is a part of Fedilab
*
* This program is free software; you can redistribute it and/or modify it under the terms of the
* GNU General Public License as published by the Free Software Foundation; either version 3 of the
* License, or (at your option) any later version.
*
* Fedilab is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even
* the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
* Public License for more details.
*
* You should have received a copy of the GNU General Public License along with Fedilab; if not,
* see <http://www.gnu.org/licenses>. */
package app.fedilab.android.interfaces;
import java.net.HttpURLConnection;
/**
* Created by Thomas on 12/06/2019.
* Interface for http response
*/
public interface OnHttpResponseInterface {
void onResponse(HttpURLConnection httpURLConnection);
}
......@@ -226,16 +226,6 @@ public class LiveNotificationService extends Service implements NetworkStateRece
Objects.requireNonNull(webSocketFutures.get(urlKey)).close();
} catch (Exception ignored) {}
}
if( Build.VERSION.SDK_INT <= Build.VERSION_CODES.KITKAT ) {
try {
AsyncHttpClient.getDefaultInstance().getSSLSocketMiddleware().setSSLContext(new TLSSocketFactory(account.getInstance()).getSSLContext());
AsyncHttpClient.getDefaultInstance().getSSLSocketMiddleware().setConnectAllAddresses(true);
} catch (KeyManagementException e) {
e.printStackTrace();
} catch (NoSuchAlgorithmException e) {
e.printStackTrace();
}
}
AsyncHttpClient.getDefaultInstance().websocket("wss://" + account.getInstance() + "/api/v1/streaming/?stream="+notif_url+"&access_token=" + account.getToken(), "wss", new AsyncHttpClient.WebSocketConnectCallback() {
@Override
public void onCompleted(Exception ex, WebSocket webSocket) {
......
......@@ -108,16 +108,6 @@ public class StreamingFederatedTimelineService extends IntentService {
Uri url = Uri.parse("wss://" + accountStream.getInstance() + "/api/v1/streaming/?stream=public&access_token="+ accountStream.getToken());
AsyncHttpRequest.setDefaultHeaders(headers, url);
Account finalAccountStream = accountStream;
if( Build.VERSION.SDK_INT <= Build.VERSION_CODES.KITKAT ) {
try {
AsyncHttpClient.getDefaultInstance().getSSLSocketMiddleware().setSSLContext(new TLSSocketFactory(accountStream.getInstance()).getSSLContext());
AsyncHttpClient.getDefaultInstance().getSSLSocketMiddleware().setConnectAllAddresses(true);
} catch (KeyManagementException e) {
e.printStackTrace();
} catch (NoSuchAlgorithmException e) {
e.printStackTrace();
}
}
AsyncHttpClient.getDefaultInstance().websocket("wss://" + accountStream.getInstance() + "/api/v1/streaming/?stream=public&access_token="+ accountStream.getToken(),"wss", new AsyncHttpClient.WebSocketConnectCallback() {
@Override
public void onCompleted(Exception ex, WebSocket webSocket) {
......
......@@ -108,16 +108,6 @@ public class StreamingHomeTimelineService extends IntentService {
Uri url = Uri.parse("wss://" + accountStream.getInstance() + "/api/v1/streaming/?stream=user&access_token="+ accountStream.getToken());
AsyncHttpRequest.setDefaultHeaders(headers, url);
Account finalAccountStream = accountStream;
if( Build.VERSION.SDK_INT <= Build.VERSION_CODES.KITKAT ) {
try {
AsyncHttpClient.getDefaultInstance().getSSLSocketMiddleware().setSSLContext(new TLSSocketFactory(accountStream.getInstance()).getSSLContext());
AsyncHttpClient.getDefaultInstance().getSSLSocketMiddleware().setConnectAllAddresses(true);
} catch (KeyManagementException e) {
e.printStackTrace();
} catch (NoSuchAlgorithmException e) {
e.printStackTrace();
}
}
AsyncHttpClient.getDefaultInstance().websocket("wss://" + accountStream.getInstance() + "/api/v1/streaming/?stream=user&access_token="+ accountStream.getToken(),"wss", new AsyncHttpClient.WebSocketConnectCallback() {
@Override
public void onCompleted(Exception ex, WebSocket webSocket) {
......
......@@ -109,16 +109,6 @@ public class StreamingLocalTimelineService extends IntentService {
Uri url = Uri.parse("wss://" + accountStream.getInstance() + "/api/v1/streaming/?stream=public:local&access_token="+ accountStream.getToken());
AsyncHttpRequest.setDefaultHeaders(headers, url);
Account finalAccountStream = accountStream;
if( Build.VERSION.SDK_INT <= Build.VERSION_CODES.KITKAT ) {
try {
AsyncHttpClient.getDefaultInstance().getSSLSocketMiddleware().setSSLContext(new TLSSocketFactory(accountStream.getInstance()).getSSLContext());
AsyncHttpClient.getDefaultInstance().getSSLSocketMiddleware().setConnectAllAddresses(true);
} catch (KeyManagementException e) {
e.printStackTrace();
} catch (NoSuchAlgorithmException e) {
e.printStackTrace();
}
}
AsyncHttpClient.getDefaultInstance().websocket("wss://" + accountStream.getInstance() + "/api/v1/streaming/?stream=public:local&access_token="+ accountStream.getToken(),"wss", new AsyncHttpClient.WebSocketConnectCallback() {
@Override
public void onCompleted(Exception ex, WebSocket webSocket) {
......