正在查看: Aisle v12.32 应用的 RetrofitManager.java JAVA 源代码文件
本页面展示 JAVA 反编译生成的源代码文件,支持语法高亮显示。 仅供安全研究与技术分析使用,严禁用于任何非法用途。请遵守相关法律法规。
正在查看: Aisle v12.32 应用的 RetrofitManager.java JAVA 源代码文件
本页面展示 JAVA 反编译生成的源代码文件,支持语法高亮显示。 仅供安全研究与技术分析使用,严禁用于任何非法用途。请遵守相关法律法规。
package com.pubnub.internal.managers;
import Fb.y;
import com.pubnub.api.enums.PNLogVerbosity;
import com.pubnub.api.v2.PNConfiguration;
import com.pubnub.internal.PubNubImpl;
import com.pubnub.internal.interceptor.SignatureInterceptor;
import com.pubnub.internal.services.AccessManagerService;
import com.pubnub.internal.services.ChannelGroupService;
import com.pubnub.internal.services.FilesService;
import com.pubnub.internal.services.HistoryService;
import com.pubnub.internal.services.MessageActionService;
import com.pubnub.internal.services.ObjectsService;
import com.pubnub.internal.services.PresenceService;
import com.pubnub.internal.services.PublishService;
import com.pubnub.internal.services.PushService;
import com.pubnub.internal.services.S3Service;
import com.pubnub.internal.services.SignalService;
import com.pubnub.internal.services.SubscribeService;
import com.pubnub.internal.services.TimeService;
import com.pubnub.internal.vendor.AppEngineFactory;
import java.net.Proxy;
import java.net.ProxySelector;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.TimeUnit;
import javax.net.ssl.HostnameVerifier;
import javax.net.ssl.SSLSocketFactory;
import javax.net.ssl.X509ExtendedTrustManager;
import kotlin.Metadata;
import kotlin.collections.r;
import kotlin.jvm.functions.Function1;
import kotlin.jvm.internal.DefaultConstructorMarker;
import kotlin.jvm.internal.Intrinsics;
import kotlin.jvm.internal.SourceDebugExtension;
import okhttp3.Authenticator;
import okhttp3.Call;
import okhttp3.CertificatePinner;
import okhttp3.ConnectionSpec;
import okhttp3.Dispatcher;
import okhttp3.Interceptor;
import okhttp3.OkHttpClient;
import okhttp3.logging.HttpLoggingInterceptor;
import org.jetbrains.annotations.NotNull;
@Metadata
@SourceDebugExtension({"SMAP\nRetrofitManager.kt\nKotlin\n*S Kotlin\n*F\n+ 1 RetrofitManager.kt\ncom/pubnub/internal/managers/RetrofitManager\n+ 2 fake.kt\nkotlin/jvm/internal/FakeKt\n*L\n1#1,191:1\n1#2:192\n*E\n"})
public final class RetrofitManager {
@NotNull
private final AccessManagerService accessManagerService;
@NotNull
private final ChannelGroupService channelGroupService;
@NotNull
private final PNConfiguration configuration;
@NotNull
private final FilesService filesService;
@NotNull
private final HistoryService historyService;
@NotNull
private final MessageActionService messageActionService;
private OkHttpClient noSignatureClientInstance;
@NotNull
private final ObjectsService objectsService;
@NotNull
private final PresenceService presenceService;
@NotNull
private final PublishService publishService;
@NotNull
private final PubNubImpl pubnub;
@NotNull
private final PushService pushService;
@NotNull
private final S3Service s3Service;
@NotNull
private final SignalService signalService;
@NotNull
private SignatureInterceptor signatureInterceptor;
@NotNull
private final SubscribeService subscribeService;
private OkHttpClient subscriptionClientInstance;
@NotNull
private final TimeService timeService;
private OkHttpClient transactionClientInstance;
public RetrofitManager(@NotNull PubNubImpl pubnub, @NotNull PNConfiguration configuration, OkHttpClient transactionClientInstance, OkHttpClient subscriptionClientInstance, OkHttpClient noSignatureClientInstance) {
RetrofitManager retrofitManager;
Intrinsics.checkNotNullParameter(pubnub, "pubnub");
Intrinsics.checkNotNullParameter(configuration, "configuration");
this.pubnub = pubnub;
this.configuration = configuration;
this.transactionClientInstance = transactionClientInstance;
this.subscriptionClientInstance = subscriptionClientInstance;
this.noSignatureClientInstance = noSignatureClientInstance;
this.signatureInterceptor = new SignatureInterceptor(configuration);
if (configuration.getGoogleAppEngineNetworking()) {
retrofitManager = this;
} else {
retrofitManager = this;
retrofitManager.transactionClientInstance = createOkHttpClient$default(retrofitManager, configuration.getNonSubscribeReadTimeout(), false, this.transactionClientInstance, 2, null);
retrofitManager.subscriptionClientInstance = createOkHttpClient$default(retrofitManager, configuration.getSubscribeTimeout(), false, retrofitManager.subscriptionClientInstance, 2, null);
retrofitManager.noSignatureClientInstance = createOkHttpClient(configuration.getNonSubscribeReadTimeout(), false, retrofitManager.noSignatureClientInstance);
}
y createRetrofit = createRetrofit(retrofitManager.transactionClientInstance);
y createRetrofit2 = createRetrofit(retrofitManager.subscriptionClientInstance);
y createRetrofit3 = createRetrofit(retrofitManager.noSignatureClientInstance);
retrofitManager.timeService = (TimeService) createRetrofit.b(TimeService.class);
retrofitManager.publishService = (PublishService) createRetrofit.b(PublishService.class);
retrofitManager.historyService = (HistoryService) createRetrofit.b(HistoryService.class);
retrofitManager.presenceService = (PresenceService) createRetrofit.b(PresenceService.class);
retrofitManager.messageActionService = (MessageActionService) createRetrofit.b(MessageActionService.class);
retrofitManager.signalService = (SignalService) createRetrofit.b(SignalService.class);
retrofitManager.channelGroupService = (ChannelGroupService) createRetrofit.b(ChannelGroupService.class);
retrofitManager.pushService = (PushService) createRetrofit.b(PushService.class);
retrofitManager.accessManagerService = (AccessManagerService) createRetrofit.b(AccessManagerService.class);
retrofitManager.objectsService = (ObjectsService) createRetrofit.b(ObjectsService.class);
retrofitManager.filesService = (FilesService) createRetrofit.b(FilesService.class);
retrofitManager.s3Service = (S3Service) createRetrofit3.b(S3Service.class);
retrofitManager.subscribeService = (SubscribeService) createRetrofit2.b(SubscribeService.class);
}
private final void closeExecutor(OkHttpClient client, boolean force) {
if (client != null) {
client.dispatcher().cancelAll();
ExecutorService executorService = client.dispatcher().executorService();
executorService.shutdown();
if (force) {
try {
if (!executorService.awaitTermination(100L, TimeUnit.MILLISECONDS)) {
executorService.shutdownNow();
}
} catch (InterruptedException unused) {
executorService.shutdownNow();
}
}
client.connectionPool().evictAll();
}
}
private final OkHttpClient createOkHttpClient(int i, boolean z, OkHttpClient okHttpClient) {
OkHttpClient.Builder builder;
if (okHttpClient == null || (builder = okHttpClient.newBuilder()) == null) {
builder = new OkHttpClient.Builder();
}
OkHttpClient.Builder retryOnConnectionFailure = builder.retryOnConnectionFailure(false);
long j = i;
TimeUnit timeUnit = TimeUnit.SECONDS;
retryOnConnectionFailure.readTimeout(j, timeUnit).connectTimeout(this.configuration.getConnectTimeout(), timeUnit);
PNConfiguration pNConfiguration = this.configuration;
if (pNConfiguration.getLogVerbosity() == PNLogVerbosity.BODY) {
HttpLoggingInterceptor httpLoggingInterceptor = new HttpLoggingInterceptor(null, 1, 0 == true ? 1 : 0);
httpLoggingInterceptor.level(HttpLoggingInterceptor.Level.BODY);
builder.addInterceptor(httpLoggingInterceptor);
}
if (pNConfiguration.getHttpLoggingInterceptor() != null) {
HttpLoggingInterceptor httpLoggingInterceptor2 = pNConfiguration.getHttpLoggingInterceptor();
Intrinsics.checkNotNull(httpLoggingInterceptor2);
builder.addInterceptor(httpLoggingInterceptor2);
}
if (pNConfiguration.getSslSocketFactory() != null && pNConfiguration.getX509ExtendedTrustManager() != null) {
SSLSocketFactory sslSocketFactory = this.configuration.getSslSocketFactory();
Intrinsics.checkNotNull(sslSocketFactory);
X509ExtendedTrustManager x509ExtendedTrustManager = this.configuration.getX509ExtendedTrustManager();
Intrinsics.checkNotNull(x509ExtendedTrustManager);
builder.sslSocketFactory(sslSocketFactory, x509ExtendedTrustManager);
}
ConnectionSpec connectionSpec = pNConfiguration.getConnectionSpec();
if (connectionSpec != null) {
builder.connectionSpecs(r.e(connectionSpec));
}
HostnameVerifier hostnameVerifier = pNConfiguration.getHostnameVerifier();
if (hostnameVerifier != null) {
builder.hostnameVerifier(hostnameVerifier);
}
Proxy proxy = pNConfiguration.getProxy();
if (proxy != null) {
builder.proxy(proxy);
}
ProxySelector proxySelector = pNConfiguration.getProxySelector();
if (proxySelector != null) {
builder.proxySelector(proxySelector);
}
Authenticator proxyAuthenticator = pNConfiguration.getProxyAuthenticator();
if (proxyAuthenticator != null) {
builder.proxyAuthenticator(proxyAuthenticator);
}
CertificatePinner certificatePinner = pNConfiguration.getCertificatePinner();
if (certificatePinner != null) {
builder.certificatePinner(certificatePinner);
}
if (z) {
r.G(builder.interceptors(), new Function1() {
@Override
public final Object invoke(Object obj) {
boolean createOkHttpClient$lambda$8;
createOkHttpClient$lambda$8 = RetrofitManager.createOkHttpClient$lambda$8((Interceptor) obj);
return Boolean.valueOf(createOkHttpClient$lambda$8);
}
});
builder.addInterceptor(this.signatureInterceptor);
}
OkHttpClient build = builder.build();
Integer maximumConnections = this.configuration.getMaximumConnections();
if (maximumConnections != null) {
build.dispatcher().setMaxRequestsPerHost(maximumConnections.intValue());
}
return build;
}
static OkHttpClient createOkHttpClient$default(RetrofitManager retrofitManager, int i, boolean z, OkHttpClient okHttpClient, int i2, Object obj) {
if ((i2 & 2) != 0) {
z = true;
}
if ((i2 & 4) != 0) {
okHttpClient = null;
}
return retrofitManager.createOkHttpClient(i, z, okHttpClient);
}
public static final boolean createOkHttpClient$lambda$8(Interceptor it) {
Intrinsics.checkNotNullParameter(it, "it");
return it instanceof SignatureInterceptor;
}
private final y createRetrofit(Call.Factory callFactory) {
y.b a = new y.b().b(this.pubnub.getBaseUrl()).a(this.pubnub.getMapper().getConverterFactory$pubnub_kotlin_impl());
if (this.configuration.getGoogleAppEngineNetworking()) {
a.e(new AppEngineFactory.Factory(this.configuration));
} else {
if (callFactory == null) {
throw new IllegalStateException("Can't instantiate PubNub");
}
a.e(callFactory);
}
y d = a.d();
Intrinsics.checkNotNullExpressionValue(d, "build(...)");
return d;
}
public static void destroy$default(RetrofitManager retrofitManager, boolean z, int i, Object obj) {
if ((i & 1) != 0) {
z = false;
}
retrofitManager.destroy(z);
}
public final void destroy(boolean force) {
closeExecutor(this.transactionClientInstance, force);
closeExecutor(this.subscriptionClientInstance, force);
closeExecutor(this.noSignatureClientInstance, force);
}
@NotNull
public final AccessManagerService getAccessManagerService$pubnub_kotlin_impl() {
return this.accessManagerService;
}
@NotNull
public final ChannelGroupService getChannelGroupService$pubnub_kotlin_impl() {
return this.channelGroupService;
}
@NotNull
public final FilesService getFilesService$pubnub_kotlin_impl() {
return this.filesService;
}
@NotNull
public final HistoryService getHistoryService$pubnub_kotlin_impl() {
return this.historyService;
}
@NotNull
public final MessageActionService getMessageActionService$pubnub_kotlin_impl() {
return this.messageActionService;
}
public final OkHttpClient getNoSignatureClientInstance$pubnub_kotlin_impl() {
return this.noSignatureClientInstance;
}
@NotNull
public final ObjectsService getObjectsService$pubnub_kotlin_impl() {
return this.objectsService;
}
@NotNull
public final PresenceService getPresenceService$pubnub_kotlin_impl() {
return this.presenceService;
}
@NotNull
public final PublishService getPublishService$pubnub_kotlin_impl() {
return this.publishService;
}
@NotNull
public final PubNubImpl getPubnub() {
return this.pubnub;
}
@NotNull
public final PushService getPushService$pubnub_kotlin_impl() {
return this.pushService;
}
@NotNull
public final S3Service getS3Service$pubnub_kotlin_impl() {
return this.s3Service;
}
@NotNull
public final SignalService getSignalService$pubnub_kotlin_impl() {
return this.signalService;
}
@NotNull
public final SubscribeService getSubscribeService$pubnub_kotlin_impl() {
return this.subscribeService;
}
public final OkHttpClient getSubscriptionClientInstance$pubnub_kotlin_impl() {
return this.subscriptionClientInstance;
}
@NotNull
public final TimeService getTimeService$pubnub_kotlin_impl() {
return this.timeService;
}
public final ExecutorService getTransactionClientExecutorService() {
Dispatcher dispatcher;
OkHttpClient okHttpClient = this.transactionClientInstance;
if (okHttpClient == null || (dispatcher = okHttpClient.dispatcher()) == null) {
return null;
}
return dispatcher.executorService();
}
public final OkHttpClient getTransactionClientInstance$pubnub_kotlin_impl() {
return this.transactionClientInstance;
}
public final void setNoSignatureClientInstance$pubnub_kotlin_impl(OkHttpClient okHttpClient) {
this.noSignatureClientInstance = okHttpClient;
}
public final void setSubscriptionClientInstance$pubnub_kotlin_impl(OkHttpClient okHttpClient) {
this.subscriptionClientInstance = okHttpClient;
}
public final void setTransactionClientInstance$pubnub_kotlin_impl(OkHttpClient okHttpClient) {
this.transactionClientInstance = okHttpClient;
}
public RetrofitManager(PubNubImpl pubNubImpl, PNConfiguration pNConfiguration, OkHttpClient okHttpClient, OkHttpClient okHttpClient2, OkHttpClient okHttpClient3, int i, DefaultConstructorMarker defaultConstructorMarker) {
this(pubNubImpl, pNConfiguration, (i & 4) != 0 ? null : okHttpClient, (i & 8) != 0 ? null : okHttpClient2, (i & 16) != 0 ? null : okHttpClient3);
}
public RetrofitManager(@NotNull RetrofitManager retrofitManager, @NotNull PNConfiguration configuration) {
this(retrofitManager.pubnub, configuration, retrofitManager.transactionClientInstance, retrofitManager.subscriptionClientInstance, retrofitManager.noSignatureClientInstance);
Intrinsics.checkNotNullParameter(retrofitManager, "retrofitManager");
Intrinsics.checkNotNullParameter(configuration, "configuration");
}
}