七色猫视频 v9.9.9版本的 MD5 值为:6e3740f68cd7a75ec951b5f356e1fd2c
以下内容为反编译后的 ServiceFactory.java 源代码,内容仅作参考
package com.yz.baselib.net.factory;
import com.alibaba.sdk.android.oss.common.utils.HttpHeaders;
import com.blankj.utilcode.util.AppUtils;
import com.blankj.utilcode.util.NetworkUtils;
import com.blankj.utilcode.util.ToastUtils;
import com.blankj.utilcode.util.Utils;
import com.moczul.ok2curl.CurlInterceptor;
import com.moczul.ok2curl.logger.Logger;
import com.yz.baselib.R2;
import com.yz.baselib.base.UserManager;
import com.yz.baselib.net.AppConfig;
import com.yz.baselib.net.utils.HttpsUtils;
import com.yz.baselib.net.utils.SSLSocketFactoryUtils;
import com.yz.baselib.utils.LogUtils;
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.net.Proxy;
import java.util.concurrent.TimeUnit;
import javax.net.ssl.HostnameVerifier;
import javax.net.ssl.SSLSession;
import okhttp3.Cache;
import okhttp3.CacheControl;
import okhttp3.Interceptor;
import okhttp3.OkHttpClient;
import okhttp3.Request;
import okhttp3.Response;
import okhttp3.logging.HttpLoggingInterceptor;
import retrofit2.Retrofit;
import retrofit2.adapter.rxjava2.RxJava2CallAdapterFactory;
import retrofit2.converter.gson.GsonConverterFactory;
import retrofit2.converter.scalars.ScalarsConverterFactory;
public class ServiceFactory {
public static boolean IS_DEBUG = false;
public static final String JAVA_SERVER_URL = "http://120.79.63.193:8085/";
public static final String LOG_SERVER = "https://luodiye-api.tk85.xyz";
public static final String ORIGINAL_URL = "https://nn-mov.oss-cn-hangzhou.aliyuncs.com/other/";
public static final String ZHIBO_URL = "https://luodi-api.gsvaa.fun/conf/";
static boolean apiDebug = false;
public static Cache cache = null;
public static final int cacheSize = 10485760;
public static final File httpCacheDirectory;
public static OkHttpClient httpClient;
public static OkHttpClient originalHttpClient;
private static final OkHttpClient sOtherClient;
static {
HttpLoggingInterceptor level;
File file = new File(Utils.getApp().getCacheDir(), "TcResponse");
httpCacheDirectory = file;
cache = new Cache(file, 10485760L);
IS_DEBUG = false;
apiDebug = false;
OkHttpClient.Builder connectTimeout = new OkHttpClient.Builder().cache(new Cache(new File(AppConfig.DEFAULT_SAVE_OK_HTTP_PATH), 419430400L)).readTimeout(20L, TimeUnit.SECONDS).connectTimeout(20L, TimeUnit.SECONDS);
if (IS_DEBUG) {
level = new HttpLoggingInterceptor(new HttpLoggingInterceptor.Logger() {
@Override
public final void log(String str) {
LogUtils.e("Titan", "收到响应:" + str);
}
}).setLevel(HttpLoggingInterceptor.Level.BODY);
} else {
level = new HttpLoggingInterceptor().setLevel(HttpLoggingInterceptor.Level.NONE);
}
sOtherClient = connectTimeout.addInterceptor(level).cache(cache).build();
}
public static void ApiDebug(boolean z) {
apiDebug = z;
}
public static OkHttpClient getHttpClient() {
return httpClient;
}
public static void setHttpClient(OkHttpClient okHttpClient) {
httpClient = okHttpClient;
}
public static void initHttpClient() {
HttpLoggingInterceptor level;
if (IS_DEBUG) {
OkHttpClient.Builder connectTimeout = new OkHttpClient.Builder().proxy(Proxy.NO_PROXY).readTimeout(20L, TimeUnit.SECONDS).connectTimeout(20L, TimeUnit.SECONDS);
if (IS_DEBUG) {
level = new HttpLoggingInterceptor(new HttpLoggingInterceptor.Logger() {
@Override
public final void log(String str) {
LogUtils.e("Titan", "收到响应:" + str);
}
}).setLevel(HttpLoggingInterceptor.Level.BODY);
} else {
level = new HttpLoggingInterceptor().setLevel(HttpLoggingInterceptor.Level.NONE);
}
httpClient = connectTimeout.addInterceptor(level).addInterceptor(new CurlInterceptor(new Logger() {
@Override
public void log(String str) {
LogUtils.d("NetWork", str);
}
})).addInterceptor(new Interceptor() {
@Override
public final Response intercept(Interceptor.Chain chain) {
return ServiceFactory.lambda$initHttpClient$2(chain);
}
}).cache(cache).build();
return;
}
HttpsUtils.SSLParams sslSocketFactory = HttpsUtils.getSslSocketFactory(new InputStream[0], null, null);
httpClient = new OkHttpClient.Builder().proxy(Proxy.NO_PROXY).sslSocketFactory(SSLSocketFactoryUtils.createSSLSocketFactory(), SSLSocketFactoryUtils.createTrustAllManager()).hostnameVerifier(new HostnameVerifier() {
@Override
public boolean verify(String str, SSLSession sSLSession) {
return true;
}
}).sslSocketFactory(sslSocketFactory.sSLSocketFactory, sslSocketFactory.trustManager).readTimeout(20L, TimeUnit.SECONDS).connectTimeout(20L, TimeUnit.SECONDS).addInterceptor(new Interceptor() {
@Override
public final Response intercept(Interceptor.Chain chain) {
return ServiceFactory.lambda$initHttpClient$3(chain);
}
}).cache(cache).build();
}
public static Response lambda$initHttpClient$2(Interceptor.Chain chain) throws IOException {
Request request = chain.request();
CacheControl.Builder builder = new CacheControl.Builder();
builder.maxAge(0, TimeUnit.SECONDS);
builder.maxStale(R2.attr.drawableRightCompat, TimeUnit.DAYS);
builder.build();
Request.Builder addHeader = request.newBuilder().addHeader("channel", UserManager.getChannel()).addHeader("source", "2").addHeader("version", AppUtils.getAppVersionName());
Request build = addHeader.addHeader("versionCode", AppUtils.getAppVersionCode() + "").addHeader("packageName", AppUtils.getAppPackageName()).addHeader("token", UserManager.getToken()).build();
if (apiDebug) {
ToastUtils.showShort("3x01:" + build.url().toString());
}
Response proceed = chain.proceed(build);
if (apiDebug && !proceed.isSuccessful()) {
ToastUtils.showLong("3x02:" + proceed.body().toString());
}
if (NetworkUtils.isConnected()) {
Response.Builder removeHeader = proceed.newBuilder().removeHeader("Pragma");
return removeHeader.header(HttpHeaders.CACHE_CONTROL, "public ,max-age=0").build();
}
Response.Builder removeHeader2 = proceed.newBuilder().removeHeader("Pragma");
return removeHeader2.header(HttpHeaders.CACHE_CONTROL, "public, only-if-cached, max-stale=2419200").build();
}
public static Response lambda$initHttpClient$3(Interceptor.Chain chain) throws IOException {
Request request = chain.request();
CacheControl.Builder builder = new CacheControl.Builder();
builder.maxAge(0, TimeUnit.SECONDS);
builder.maxStale(R2.attr.drawableRightCompat, TimeUnit.DAYS);
builder.build();
Request.Builder addHeader = request.newBuilder().addHeader("token", UserManager.getToken()).addHeader("source", "2").addHeader("channel", UserManager.getChannel()).addHeader("version", AppUtils.getAppVersionName());
Request build = addHeader.addHeader("versionCode", AppUtils.getAppVersionCode() + "").addHeader("packageName", AppUtils.getAppPackageName()).build();
if (apiDebug) {
ToastUtils.showShort("2x01:" + build.url().toString());
}
Response proceed = chain.proceed(build);
if (apiDebug && !proceed.isSuccessful()) {
ToastUtils.showLong("2x02:" + proceed.body().toString());
}
if (NetworkUtils.isConnected()) {
Response.Builder removeHeader = proceed.newBuilder().removeHeader("Pragma");
return removeHeader.header(HttpHeaders.CACHE_CONTROL, "public ,max-age=0").build();
}
Response.Builder removeHeader2 = proceed.newBuilder().removeHeader("Pragma");
return removeHeader2.header(HttpHeaders.CACHE_CONTROL, "public, only-if-cached, max-stale=2419200").build();
}
public static void initOriginalHttpClient() {
HttpLoggingInterceptor level;
HttpsUtils.SSLParams sslSocketFactory = HttpsUtils.getSslSocketFactory(new InputStream[0], null, null);
OkHttpClient.Builder connectTimeout = new OkHttpClient.Builder().proxy(Proxy.NO_PROXY).sslSocketFactory(sslSocketFactory.sSLSocketFactory, sslSocketFactory.trustManager).readTimeout(20L, TimeUnit.SECONDS).connectTimeout(20L, TimeUnit.SECONDS);
if (IS_DEBUG) {
level = new HttpLoggingInterceptor(new HttpLoggingInterceptor.Logger() {
@Override
public final void log(String str) {
LogUtils.e("Titan", "收到响应:" + str);
}
}).setLevel(HttpLoggingInterceptor.Level.BODY);
} else {
level = new HttpLoggingInterceptor().setLevel(HttpLoggingInterceptor.Level.NONE);
}
originalHttpClient = connectTimeout.addInterceptor(level).addInterceptor(new Interceptor() {
@Override
public final Response intercept(Interceptor.Chain chain) {
return ServiceFactory.lambda$initOriginalHttpClient$5(chain);
}
}).cache(cache).build();
}
public static Response lambda$initOriginalHttpClient$5(Interceptor.Chain chain) throws IOException {
Request request = chain.request();
CacheControl.Builder builder = new CacheControl.Builder();
builder.maxAge(0, TimeUnit.SECONDS);
builder.maxStale(R2.attr.drawableRightCompat, TimeUnit.DAYS);
builder.build();
Request build = request.newBuilder().build();
if (apiDebug) {
ToastUtils.showShort("1x01:" + build.url().toString());
}
Response proceed = chain.proceed(build);
if (apiDebug && !proceed.isSuccessful()) {
ToastUtils.showLong("1x02:" + proceed.body().toString());
}
if (NetworkUtils.isConnected()) {
Response.Builder removeHeader = proceed.newBuilder().removeHeader("Pragma");
return removeHeader.header(HttpHeaders.CACHE_CONTROL, "public ,max-age=0").build();
}
Response.Builder removeHeader2 = proceed.newBuilder().removeHeader("Pragma");
return removeHeader2.header(HttpHeaders.CACHE_CONTROL, "public, only-if-cached, max-stale=2419200").build();
}
public static <T> T createYZService(Class<T> cls) {
UserManager.getRealUrl();
return (T) createOauthService(UserManager.getRealUrl(), cls);
}
public static <T> T createOriginalService(Class<T> cls) {
return (T) createOriginalService("https://nn-mov.oss-cn-hangzhou.aliyuncs.com/other/", cls);
}
public static <T> T createZhiboService(Class<T> cls) {
return (T) createZhiboService(ZHIBO_URL, cls);
}
public static <T> T createLogService(Class<T> cls) {
return (T) createOauthService(LOG_SERVER, cls);
}
public static <T> T createUpdateService(Class<T> cls) {
return (T) createOauthService(UserManager.getRealUrl(), cls);
}
public static <T> T createOauthService(String str, Class<T> cls) {
return (T) new Retrofit.Builder().client(httpClient).baseUrl(str).addConverterFactory(GsonConverterFactory.create()).addCallAdapterFactory(RxJava2CallAdapterFactory.create()).build().create(cls);
}
public static <T> T createOauthOtherService(String str, Class<T> cls) {
return (T) new Retrofit.Builder().client(sOtherClient).baseUrl(str).addConverterFactory(ScalarsConverterFactory.create()).addCallAdapterFactory(RxJava2CallAdapterFactory.create()).build().create(cls);
}
public static <T> T createOriginalService(String str, Class<T> cls) {
return (T) new Retrofit.Builder().client(originalHttpClient).baseUrl(str).addConverterFactory(GsonConverterFactory.create()).addCallAdapterFactory(RxJava2CallAdapterFactory.create()).build().create(cls);
}
public static <T> T createPostService(Class<T> cls) {
return (T) new Retrofit.Builder().client(new OkHttpClient().newBuilder().build()).baseUrl("http://mobile-api.tk85.xyz/req/").addConverterFactory(GsonConverterFactory.create()).addCallAdapterFactory(RxJava2CallAdapterFactory.create()).build().create(cls);
}
public static <T> T createZhiboService(String str, Class<T> cls) {
return (T) new Retrofit.Builder().client(originalHttpClient).baseUrl(str).addConverterFactory(GsonConverterFactory.create()).addCallAdapterFactory(RxJava2CallAdapterFactory.create()).build().create(cls);
}
}