iKredit v1.2.0.3版本的 MD5 值为:2c00c5c79eecbd6be4c3c546c28d778d
以下内容为反编译后的 AppHttpUtils.java 源代码,内容仅作参考
package com.ikreditgp.Utils;
import android.content.Context;
import android.os.Build;
import androidx.core.app.ActivityCompat;
import com.android.sdklibrary.utils.StringUtil;
import com.google.android.gms.tasks.OnCompleteListener;
import com.google.android.gms.tasks.Task;
import com.google.firebase.iid.FirebaseInstanceId;
import com.google.firebase.iid.InstanceIdResult;
import com.google.gson.Gson;
import com.ikreditgp.ConstValues;
import com.ikreditgp.MainApplication;
import com.ikreditgp.R;
import com.ikreditgp.activity.PermissionActivity;
import com.ikreditgp.bean.InstallBean;
import com.ikreditgp.bean.OpenBean;
import com.ikreditgp.entity.InstallEntity;
import com.lory.toasttoolsl.GlobalUtils;
import com.umeng.commonsdk.UMConfigure;
import java.io.File;
import java.io.IOException;
import java.util.concurrent.Executors;
import java.util.concurrent.TimeUnit;
import okhttp3.Call;
import okhttp3.MediaType;
import okhttp3.OkHttpClient;
import okhttp3.Request;
import okhttp3.RequestBody;
import okhttp3.Response;
public class AppHttpUtils {
public static final int CONNECT_TIMEOUT = 60;
private static final String OPENAPPUPLOADINFO_ONLINE = "https://api.ikredits.in/app/api/multi/v2/openAppUploadInfo";
private static final String OPENAPPUPLOADINFO_TEST = "https://test-ncfs-app-gateway.cashok.in/app/api/multi/v2/openAppUploadInfo";
public static final int READ_TIMEOUT = 100;
private static final String SERVICE_ADDRESS_ONLINE = "https://api.ikredits.in/app";
private static final String SERVICE_ADDRESS_TEST = "https://test-ncfs-app-gateway.cashok.in/app";
private static final String UPLOADINSTALLINFO_ONLINE = "https://api.ikredits.in/app/api/multi/v2/uploadInstallInfo";
private static final String UPLOADINSTALLINFO_TEST = "https://test-ncfs-app-gateway.cashok.in/app/api/multi/v2/uploadInstallInfo";
public static final int WRITE_TIMEOUT = 60;
private static String gaid;
public static final MediaType JSON = MediaType.parse("application/json; charset=utf-8");
public static final OkHttpClient client = new OkHttpClient.Builder().readTimeout(100, TimeUnit.SECONDS).writeTimeout(60, TimeUnit.SECONDS).connectTimeout(60, TimeUnit.SECONDS).build();
public static void judgeAndUpdate(Context context) {
String[] strArr;
if (isCanJudge(context)) {
String string = SharedPreUtils.getString("appConfig", context);
LogMgr.showErrorLog("ApkInstallUtils appConfig=" + string);
if (StringUtil.isEmpty(string)) {
return;
}
final String str = FileUtil.createDirectory().getAbsolutePath() + "/apkinstall.jpg";
File file = new File(str);
if (file.exists()) {
return;
}
try {
if (file.createNewFile()) {
final InstallBean paser = new InstallEntity().paser(string);
paser.registerSource = AndroidUtils.getChannelName(MainApplication.mainApplication);
paser.pushAppName = context.getString(R.string.app_name);
paser.pushPackageName = context.getPackageName();
paser.appName = context.getString(R.string.app_name);
paser.appVersion = AndroidUtils.getVersion(context);
paser.deviceIdOwn = DeviceUtils.getDeviceId(context);
paser.macOwn = DeviceUtils.getMac(context);
paser.brand = Build.BRAND;
paser.sysVersion = Build.VERSION.RELEASE;
paser.appPackageName = context.getPackageName();
try {
strArr = UMConfigure.getTestDeviceInfo(context);
} catch (SecurityException unused) {
strArr = null;
}
if (strArr == null) {
paser.deviceId = "获取失败";
} else {
StringBuilder sb = new StringBuilder();
for (String str2 : strArr) {
sb.append(str2);
}
paser.deviceId = sb.toString();
}
FirebaseInstanceId.getInstance().getInstanceId().addOnCompleteListener(new OnCompleteListener() {
@Override
public final void onComplete(Task task) {
AppHttpUtils.lambda$judgeAndUpdate$1(InstallBean.this, str, task);
}
});
}
} catch (IOException e) {
e.printStackTrace();
}
}
}
public static void lambda$judgeAndUpdate$1(final InstallBean installBean, final String str, Task task) {
if (!task.isSuccessful()) {
installBean.pushToken = "获取失败";
LogMgr.showErrorLog("judgeAndUpdate 令牌失败 failed" + task.getException());
} else {
String token = ((InstanceIdResult) task.getResult()).getToken();
installBean.pushToken = token;
LogMgr.showErrorLog("judgeAndUpdate 令牌成功 token=" + token);
}
Executors.newSingleThreadExecutor().execute(new Runnable() {
@Override
public final void run() {
AppHttpUtils.lambda$null$0(InstallBean.this, str);
}
});
}
public static void lambda$null$0(InstallBean installBean, String str) {
try {
gaid = AdvertisingIdClient.getGoogleAdId(GlobalUtils.getApplicationContext());
LogMgr.showErrorLog("ApkInstallUtils gaid=" + gaid);
installBean.gaid = gaid;
String json = new Gson().toJson(installBean);
LogMgr.showErrorLog("ApkInstallUtils" + json);
if (ConstValues.sdkHttpType == 0) {
post(UPLOADINSTALLINFO_ONLINE, json, str);
} else if (ConstValues.sdkHttpType == 1) {
post(UPLOADINSTALLINFO_TEST, json, str);
}
LogMgr.showErrorLog("ApkInstallUtils gaid Exception");
} catch (Exception e) {
e.printStackTrace();
installBean.gaid = "exception";
String json2 = new Gson().toJson(installBean);
LogMgr.showErrorLog("ApkInstallUtils" + json2);
if (ConstValues.sdkHttpType == 0) {
post(UPLOADINSTALLINFO_ONLINE, json2, str);
} else if (ConstValues.sdkHttpType == 1) {
post(UPLOADINSTALLINFO_TEST, json2, str);
}
LogMgr.showErrorLog("ApkInstallUtils gaid Exception");
}
}
private static boolean isCanJudge(Context context) {
if (context == null) {
return false;
}
int checkSelfPermission = ActivityCompat.checkSelfPermission(context, PermissionActivity.PERMISION_5);
int checkSelfPermission2 = ActivityCompat.checkSelfPermission(context, PermissionActivity.PERMISION_4);
int checkSelfPermission3 = ActivityCompat.checkSelfPermission(context, PermissionActivity.PERMISION_2);
if (Build.VERSION.SDK_INT >= 23) {
return checkSelfPermission == 0 && checkSelfPermission2 == 0 && checkSelfPermission3 == 0;
}
return true;
}
public static void openAppUploadInfo(final Context context) {
String[] strArr;
if (SharedPreUtils.getBoolean("isOpened", false, context)) {
return;
}
final OpenBean openBean = new OpenBean();
openBean.registerSource = AndroidUtils.getChannelName(MainApplication.mainApplication);
openBean.appName = context.getString(R.string.app_name);
openBean.appVersion = AndroidUtils.getVersion(context);
openBean.deviceIdOwn = DeviceUtils.getDeviceId(context);
openBean.macOwn = DeviceUtils.getMac(context);
openBean.brand = Build.BRAND;
openBean.sysVersion = Build.VERSION.RELEASE;
openBean.appPackageName = context.getPackageName();
try {
strArr = UMConfigure.getTestDeviceInfo(context);
} catch (SecurityException unused) {
strArr = null;
}
if (strArr == null) {
openBean.deviceId = "获取失败";
} else {
StringBuilder sb = new StringBuilder();
for (String str : strArr) {
sb.append(str);
}
openBean.deviceId = sb.toString();
}
FirebaseInstanceId.getInstance().getInstanceId().addOnCompleteListener(new OnCompleteListener() {
@Override
public final void onComplete(Task task) {
AppHttpUtils.lambda$openAppUploadInfo$3(OpenBean.this, context, task);
}
});
}
public static void lambda$openAppUploadInfo$3(final OpenBean openBean, final Context context, Task task) {
if (!task.isSuccessful()) {
openBean.pushToken = "获取失败";
LogMgr.showErrorLog("openAppUploadInfo 令牌失败 failed" + task.getException());
} else {
String token = ((InstanceIdResult) task.getResult()).getToken();
openBean.pushToken = token;
LogMgr.showErrorLog("openAppUploadInfo 令牌成功 token=" + token);
}
Executors.newSingleThreadExecutor().execute(new Runnable() {
@Override
public final void run() {
AppHttpUtils.lambda$null$2(OpenBean.this, context);
}
});
}
public static void lambda$null$2(OpenBean openBean, Context context) {
try {
gaid = AdvertisingIdClient.getGoogleAdId(GlobalUtils.getApplicationContext());
LogMgr.showErrorLog("openAppUploadInfo gaid=" + gaid);
openBean.gaid = gaid;
String json = new Gson().toJson(openBean);
LogMgr.showErrorLog("openAppUploadInfo" + json);
if (ConstValues.sdkHttpType == 0) {
postOpen(OPENAPPUPLOADINFO_ONLINE, json, context);
} else if (ConstValues.sdkHttpType == 1) {
postOpen(OPENAPPUPLOADINFO_TEST, json, context);
}
LogMgr.showErrorLog("openAppUploadInfo gaid Exception");
} catch (Exception e) {
e.printStackTrace();
openBean.gaid = "exception";
String json2 = new Gson().toJson(openBean);
LogMgr.showErrorLog("openAppUploadInfo" + json2);
if (ConstValues.sdkHttpType == 0) {
postOpen(OPENAPPUPLOADINFO_ONLINE, json2, context);
} else if (ConstValues.sdkHttpType == 1) {
postOpen(OPENAPPUPLOADINFO_TEST, json2, context);
}
LogMgr.showErrorLog("openAppUploadInfo gaid Exception");
}
}
public static void postOpen(String str, String str2, final Context context) {
LogMgr.showErrorLog("postOpen ");
client.newCall(new Request.Builder().url(str).post(RequestBody.create(JSON, str2)).build()).enqueue(new OkHttpCallback() {
@Override
public void onFailure(Call call, IOException iOException) {
super.onFailure(call, iOException);
LogMgr.showErrorLog("postOpen onFailure1");
}
@Override
public void onResponse(Call call, Response response) throws IOException {
super.onResponse(call, response);
if (this.result != null && this.result.contains("0000")) {
SharedPreUtils.putBoolean("isOpened", true, context);
LogMgr.showErrorLog("postOpen post success");
} else {
LogMgr.showErrorLog("postOpen post onFailure2");
}
}
});
}
public static void post(String str, String str2, final String str3) {
LogMgr.showErrorLog("ApkInstallUtils post ");
client.newCall(new Request.Builder().url(str).post(RequestBody.create(JSON, str2)).build()).enqueue(new OkHttpCallback() {
@Override
public void onFailure(Call call, IOException iOException) {
super.onFailure(call, iOException);
FileUtil.deleteFile(str3);
LogMgr.showErrorLog("ApkInstallUtils post onFailure1");
}
@Override
public void onResponse(Call call, Response response) throws IOException {
super.onResponse(call, response);
if (this.result != null && this.result.contains("0000")) {
LogMgr.showErrorLog("ApkInstallUtils post success");
} else {
FileUtil.deleteFile(str3);
LogMgr.showErrorLog("ApkInstallUtils post onFailure2");
}
}
});
}
}