Skip to content

Commit

Permalink
Rename Network object to Networking
Browse files Browse the repository at this point in the history
  • Loading branch information
valldrac committed Apr 5, 2024
1 parent 2eb3315 commit 22bb4e7
Show file tree
Hide file tree
Showing 13 changed files with 42 additions and 41 deletions.
4 changes: 2 additions & 2 deletions app/src/foss/java/com/google/android/gms/maps/MapView.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
import org.osmdroid.views.overlay.mylocation.MyLocationNewOverlay;
import org.thoughtcrime.securesms.BuildConfig;
import org.thoughtcrime.securesms.R;
import org.thoughtcrime.securesms.net.Network;
import org.thoughtcrime.securesms.net.Networking;
import org.thoughtcrime.securesms.osm.MapTileProvider;

import java.net.Proxy;
Expand Down Expand Up @@ -65,7 +65,7 @@ public void getMapAsync(OnMapReadyCallback callback) {

private void setDefaultConfiguration(Context context) {
final String userAgent = context.getPackageName();
final Proxy proxy = Network.getProxy();
final Proxy proxy = Networking.getProxy();
final IConfigurationProvider config = Configuration.getInstance();
config.setDebugMode(BuildConfig.DEBUG);
config.setUserAgentValue(userAgent);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
import org.thoughtcrime.securesms.giph.model.ChunkedImageUrl;
import org.thoughtcrime.securesms.net.ContentProxySafetyInterceptor;
import org.thoughtcrime.securesms.net.ContentProxySelector;
import org.thoughtcrime.securesms.net.Network;
import org.thoughtcrime.securesms.net.Networking;
import org.thoughtcrime.securesms.net.StandardUserAgentInterceptor;

import java.io.InputStream;
Expand Down Expand Up @@ -42,9 +42,9 @@ public static class Factory implements ModelLoaderFactory<ChunkedImageUrl, Input

public Factory() {
this.client = new OkHttpClient.Builder()
.socketFactory(Network.getSocketFactory())
.socketFactory(Networking.getSocketFactory())
.proxySelector(new ContentProxySelector())
.dns(Network.getDns())
.dns(Networking.getDns())
.cache(null)
.addInterceptor(new StandardUserAgentInterceptor())
.addNetworkInterceptor(new ContentProxySafetyInterceptor())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
import com.bumptech.glide.load.model.MultiModelLoaderFactory;

import org.thoughtcrime.securesms.net.ContentProxySelector;
import org.thoughtcrime.securesms.net.Network;
import org.thoughtcrime.securesms.net.Networking;
import org.thoughtcrime.securesms.net.StandardUserAgentInterceptor;

import java.io.InputStream;
Expand Down Expand Up @@ -47,8 +47,8 @@ private static OkHttpClient getInternalClient() {
synchronized (Factory.class) {
if (internalClient == null) {
internalClient = new OkHttpClient.Builder()
.socketFactory(Network.getSocketFactory())
.dns(Network.getDns())
.socketFactory(Networking.getSocketFactory())
.dns(Networking.getDns())
.proxySelector(new ContentProxySelector())
.addInterceptor(new StandardUserAgentInterceptor())
.build();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import org.thoughtcrime.securesms.apkupdate.ApkUpdateDownloadManagerReceiver
import org.thoughtcrime.securesms.jobmanager.Job
import org.thoughtcrime.securesms.jobmanager.impl.NetworkConstraint
import org.thoughtcrime.securesms.keyvalue.SignalStore
import org.thoughtcrime.securesms.net.Network
import org.thoughtcrime.securesms.net.Networking
import org.thoughtcrime.securesms.util.FeatureFlags
import org.thoughtcrime.securesms.util.FileUtils
import org.thoughtcrime.securesms.util.JsonUtils
Expand Down Expand Up @@ -72,9 +72,9 @@ class ApkUpdateJob private constructor(parameters: Parameters) : BaseJob(paramet
Log.i(TAG, "Checking for APK update [stable" + (if (includeBeta) ", beta" else "") + "] at $url")

val client = OkHttpClient().newBuilder()
.socketFactory(Network.socketFactory)
.proxySelector(Network.proxySelectorForSocks)
.dns(Network.dns)
.socketFactory(Networking.socketFactory)
.proxySelector(Networking.proxySelectorForSocks)
.dns(Networking.dns)
.build()

val request = Request.Builder().url(url).build()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import org.thoughtcrime.securesms.events.ReminderUpdateEvent;
import org.thoughtcrime.securesms.jobmanager.Job;
import org.thoughtcrime.securesms.jobmanager.impl.NetworkConstraint;
import org.thoughtcrime.securesms.net.Network;
import org.thoughtcrime.securesms.net.Networking;
import org.thoughtcrime.securesms.transport.RetryLaterException;
import org.thoughtcrime.securesms.util.TextSecurePreferences;

Expand Down Expand Up @@ -60,7 +60,7 @@ public void onRun() throws RetryLaterException {
}

try {
InetAddress address = Network.getDns().lookup(BuildConfig.SIGNAL_SERVICE_STATUS_URL).get(0);
InetAddress address = Networking.getDns().lookup(BuildConfig.SIGNAL_SERVICE_STATUS_URL).get(0);
Log.i(TAG, "Received outage check address: " + address.getHostAddress());

if (IP_SUCCESS.equals(address.getHostAddress())) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
import org.thoughtcrime.securesms.mms.PushMediaConstraints;
import org.thoughtcrime.securesms.net.CallRequestController;
import org.thoughtcrime.securesms.net.CompositeRequestController;
import org.thoughtcrime.securesms.net.Network;
import org.thoughtcrime.securesms.net.Networking;
import org.thoughtcrime.securesms.net.RequestController;
import org.thoughtcrime.securesms.net.UserAgentInterceptor;
import org.thoughtcrime.securesms.profiles.AvatarHelper;
Expand Down Expand Up @@ -90,9 +90,9 @@ public class LinkPreviewRepository {

public LinkPreviewRepository() {
this.client = new OkHttpClient.Builder()
.socketFactory(Network.getSocketFactory())
.proxySelector(Network.getProxySelectorForSocks())
.dns(Network.getDns())
.socketFactory(Networking.getSocketFactory())
.proxySelector(Networking.getProxySelectorForSocks())
.dns(Networking.getDns())
.cache(null)
.addInterceptor(new UserAgentInterceptor("WhatsApp/2"))
.build();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
import org.signal.core.util.tracing.Tracer;
import org.thoughtcrime.securesms.database.LogDatabase;
import org.thoughtcrime.securesms.dependencies.ApplicationDependencies;
import org.thoughtcrime.securesms.net.Network;
import org.thoughtcrime.securesms.net.Networking;
import org.thoughtcrime.securesms.net.StandardUserAgentInterceptor;
import org.thoughtcrime.securesms.providers.BlobProvider;
import org.thoughtcrime.securesms.service.KeyCachingService;
Expand Down Expand Up @@ -242,9 +242,9 @@ public void writeTo(@NonNull BufferedSink sink) throws IOException {
@WorkerThread
private @NonNull String uploadContent(@NonNull String contentType, @NonNull RequestBody requestBody) throws IOException {
OkHttpClient client = new OkHttpClient.Builder()
.socketFactory(Network.getSocketFactory())
.proxySelector(Network.getProxySelectorForSocks())
.dns(Network.getDns())
.socketFactory(Networking.getSocketFactory())
.proxySelector(Networking.getProxySelectorForSocks())
.dns(Networking.getDns())
.addInterceptor(new StandardUserAgentInterceptor())
.build();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ import org.thoughtcrime.securesms.components.settings.app.notifications.manual.N
import org.thoughtcrime.securesms.conversationlist.ConversationListFragment
import org.thoughtcrime.securesms.dependencies.ApplicationDependencies
import org.thoughtcrime.securesms.keyvalue.SignalStore
import org.thoughtcrime.securesms.net.Network
import org.thoughtcrime.securesms.net.Networking
import org.thoughtcrime.securesms.notifications.profiles.NotificationProfile
import org.thoughtcrime.securesms.notifications.profiles.NotificationProfiles
import org.thoughtcrime.securesms.recipients.Recipient
Expand Down Expand Up @@ -294,7 +294,7 @@ class MainActivityListHostFragment : Fragment(R.layout.main_activity_list_host_f
WebSocketConnectionState.CONNECTED -> proxyStatus.setImageResource(R.drawable.ic_proxy_connected_24)
WebSocketConnectionState.AUTHENTICATION_FAILED -> proxyStatus.setImageResource(R.drawable.ic_proxy_failed_24)
WebSocketConnectionState.FAILED -> {
val proxyPending = Network.proxy == Network.DUMMY_PROXY
val proxyPending = Networking.proxy == Networking.DUMMY_PROXY
if (proxyPending) proxyStatus.setImageResource(R.drawable.ic_proxy_connecting_24)
else proxyStatus.setImageResource(R.drawable.ic_proxy_failed_24)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,11 +54,11 @@ public static NetworkManager create(@NonNull Context context) {
}

public boolean isNetworkEnabled() {
return Network.isEnabled();
return Networking.isEnabled();
}

public void setNetworkEnabled(boolean enabled) {
Network.setEnabled(enabled);
Networking.setEnabled(enabled);
if (enabled) {
onNetworkEnabled();
}
Expand Down Expand Up @@ -123,7 +123,7 @@ private synchronized boolean configureProxy(SocksProxy newProxy) {
return false;
}

Network.setSocksProxy(newProxy);
Networking.setSocksProxy(newProxy);
existingProxy = newProxy;

SignalExecutors.UNBOUNDED.execute(() -> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import java.net.SocketAddress
import java.net.URI
import javax.net.SocketFactory

object Network {
object Networking {
@JvmStatic
var isEnabled: Boolean = false

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import org.thoughtcrime.securesms.keyvalue.SettingsValues
import org.thoughtcrime.securesms.keyvalue.SignalStore
import org.thoughtcrime.securesms.net.DeprecatedClientPreventionInterceptor
import org.thoughtcrime.securesms.net.DeviceTransferBlockingInterceptor
import org.thoughtcrime.securesms.net.Network
import org.thoughtcrime.securesms.net.Networking
import org.thoughtcrime.securesms.net.RemoteDeprecationDetectorInterceptor
import org.thoughtcrime.securesms.net.StandardUserAgentInterceptor
import org.whispersystems.signalservice.api.push.TrustStore
Expand Down Expand Up @@ -219,9 +219,9 @@ open class SignalServiceNetworkAccess(context: Context) {
signalCdsiUrls = fUrls.map { SignalCdsiUrl(it, F_CDSI_HOST, fTrustStore, APP_CONNECTION_SPEC) }.toTypedArray(),
signalSvr2Urls = fUrls.map { SignalSvr2Url(it, fTrustStore, F_SVR2_HOST, APP_CONNECTION_SPEC) }.toTypedArray(),
networkInterceptors = interceptors,
socketFactory = Network.socketFactory,
proxySelector = Network.proxySelectorForSocks,
dns = Network.dns,
socketFactory = Networking.socketFactory,
proxySelector = Networking.proxySelectorForSocks,
dns = Networking.dns,
zkGroupServerPublicParams = zkGroupServerPublicParams,
genericServerPublicParams = genericServerPublicParams,
backupServerPublicParams = backupServerPublicParams
Expand Down Expand Up @@ -273,9 +273,9 @@ open class SignalServiceNetworkAccess(context: Context) {
signalCdsiUrls = arrayOf(SignalCdsiUrl(BuildConfig.SIGNAL_CDSI_URL, serviceTrustStore)),
signalSvr2Urls = arrayOf(SignalSvr2Url(BuildConfig.SIGNAL_SVR2_URL, serviceTrustStore)),
networkInterceptors = interceptors,
socketFactory = Network.socketFactory,
proxySelector = Network.proxySelectorForSocks,
dns = Network.dns,
socketFactory = Networking.socketFactory,
proxySelector = Networking.proxySelectorForSocks,
dns = Networking.dns,
zkGroupServerPublicParams = zkGroupServerPublicParams,
genericServerPublicParams = genericServerPublicParams,
backupServerPublicParams = backupServerPublicParams
Expand Down Expand Up @@ -344,9 +344,9 @@ open class SignalServiceNetworkAccess(context: Context) {
signalCdsiUrls = cdsiUrls,
signalSvr2Urls = svr2Urls,
networkInterceptors = interceptors,
socketFactory = Network.socketFactory,
proxySelector = Network.proxySelectorForSocks,
dns = Network.dns,
socketFactory = Networking.socketFactory,
proxySelector = Networking.proxySelectorForSocks,
dns = Networking.dns,
zkGroupServerPublicParams = zkGroupServerPublicParams,
genericServerPublicParams = genericServerPublicParams,
backupServerPublicParams = backupServerPublicParams
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
import org.signal.ringrtc.PeekInfo;
import org.thoughtcrime.securesms.dependencies.ApplicationDependencies;
import org.thoughtcrime.securesms.events.WebRtcViewModel;
import org.thoughtcrime.securesms.net.Network;
import org.thoughtcrime.securesms.net.Networking;
import org.thoughtcrime.securesms.service.webrtc.state.WebRtcServiceState;
import org.thoughtcrime.securesms.webrtc.audio.AudioManagerCompat;
import org.thoughtcrime.securesms.webrtc.audio.SignalAudioManager;
Expand Down Expand Up @@ -119,7 +119,7 @@ public static boolean isCallFull(@Nullable PeekInfo peekInfo) {
}

public static PeerConnection.ProxyInfo getProxyInfo() {
Proxy proxy = Network.getProxy();
Proxy proxy = Networking.getProxy();
if (proxy == Proxy.NO_PROXY) {
return null;
} else if (proxy.type() == Proxy.Type.SOCKS) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@

import org.signal.ringrtc.CallManager;
import org.thoughtcrime.securesms.keyvalue.SignalStore;
import org.thoughtcrime.securesms.net.Networking;
import org.webrtc.PeerConnection;

public final class NetworkUtil {
Expand Down Expand Up @@ -124,7 +125,7 @@ private static boolean useLowDataCalling(@NonNull Context context, @NonNull Peer
}

public static NetworkInfo getNetworkInfo(@NonNull Context context) {
if (!org.thoughtcrime.securesms.net.Network.isEnabled()) return null;
if (!Networking.isEnabled()) return null;
return ServiceUtil.getConnectivityManager(context).getActiveNetworkInfo();
}
}

0 comments on commit 22bb4e7

Please sign in to comment.