正在查看: Clash Legends v0.0.1 应用的 ServiceGenerator.java JAVA 源代码文件
本页面展示 JAVA 反编译生成的源代码文件,支持语法高亮显示。 仅供安全研究与技术分析使用,严禁用于任何非法用途。请遵守相关法律法规。
正在查看: Clash Legends v0.0.1 应用的 ServiceGenerator.java JAVA 源代码文件
本页面展示 JAVA 反编译生成的源代码文件,支持语法高亮显示。 仅供安全研究与技术分析使用,严禁用于任何非法用途。请遵守相关法律法规。
package com.instamojo.android.network;
import android.content.Context;
import android.content.pm.PackageManager;
import android.os.Build;
import com.instamojo.android.Instamojo;
import com.instamojo.android.helpers.Logger;
import java.io.IOException;
import okhttp3.Interceptor;
import okhttp3.OkHttpClient;
import okhttp3.Request;
import okhttp3.Response;
import retrofit2.Retrofit;
import retrofit2.converter.gson.GsonConverterFactory;
public class ServiceGenerator {
private static final String a = ServiceGenerator.class.getSimpleName();
private static final OkHttpClient b;
private static Retrofit.Builder c;
private static Retrofit d;
static {
OkHttpClient build = new OkHttpClient.Builder().addInterceptor(new a((byte) 0)).build();
b = build;
c = new Retrofit.Builder().client(build).addConverterFactory(GsonConverterFactory.create());
initialize(Instamojo.Environment.TEST);
}
public static void initialize(Instamojo.Environment environment) {
String str = environment == Instamojo.Environment.PRODUCTION ? "https://api.instamojo.com/" : "https://test.instamojo.com/";
Logger.d(a, "Using base URL: " + str);
d = c.baseUrl(str).build();
}
public static ImojoService getImojoService() {
return (ImojoService) d.create(ImojoService.class);
}
static class a implements Interceptor {
private String a;
private String b;
private a() {
}
a(byte b) {
this();
}
@Override
public final Response intercept(Interceptor.Chain chain) throws IOException {
Request.Builder newBuilder = chain.request().newBuilder();
String str = this.a;
if (str == null || str.isEmpty()) {
this.a = "instamojo-android-sdk/3.4.0 android/" + Build.VERSION.RELEASE + " " + Build.BRAND + "/" + Build.MODEL;
}
return chain.proceed(newBuilder.header("User-Agent", this.a).header("Referer", a()).build());
}
private String a() {
String str = this.b;
if (str == null || str.isEmpty()) {
Context context = Instamojo.getInstance().getContext();
if (context == null) {
return "";
}
this.b = "android-app://" + context.getPackageName();
try {
this.b += "/" + context.getPackageManager().getPackageInfo(context.getPackageName(), 0).versionName;
} catch (PackageManager.NameNotFoundException e) {
Logger.e(ServiceGenerator.a, "Unable to get version of the current application.");
}
}
return this.b;
}
}
}