正在查看: Clash Legends v0.0.1 应用的 PayuUploadDeviceAnalytics.java JAVA 源代码文件
本页面展示 JAVA 反编译生成的源代码文件,支持语法高亮显示。 仅供安全研究与技术分析使用,严禁用于任何非法用途。请遵守相关法律法规。
正在查看: Clash Legends v0.0.1 应用的 PayuUploadDeviceAnalytics.java JAVA 源代码文件
本页面展示 JAVA 反编译生成的源代码文件,支持语法高亮显示。 仅供安全研究与技术分析使用,严禁用于任何非法用途。请遵守相关法律法规。
package com.payu.india.Tasks;
import android.content.Context;
import android.content.SharedPreferences;
import android.os.AsyncTask;
import com.payu.custombrowser.util.b;
import com.payu.india.Payu.PayuUtils;
import com.payu.payuanalytics.analytics.utils.PayUAnalyticsConstant;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.lang.Thread;
import java.net.MalformedURLException;
import java.net.ProtocolException;
import java.net.URL;
import java.util.ArrayList;
import java.util.Timer;
import java.util.TimerTask;
import javax.net.ssl.HttpsURLConnection;
import kotlinx.coroutines.internal.LockFreeTaskQueueCore;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
public class PayuUploadDeviceAnalytics {
private static final String PRODUCTION_URL = "https://info.payu.in/merchant/mobileWebService.php";
private static final String TEST_URL = "https://mobiletest.payu.in/merchant/mobileWebService.php";
private static long TIMER_DELAY = 0;
private static boolean isProduction = true;
private String ANALYTICS_URL;
private final Context appContext;
private String fileName;
private ArrayList<String> mBuffer;
private boolean mIsLocked;
private Timer mTimer;
public PayuUploadDeviceAnalytics(Context appContext, String filename) {
this.fileName = "sdk_local_cache_device";
this.ANALYTICS_URL = isProduction ? PRODUCTION_URL : TEST_URL;
this.mIsLocked = false;
this.mBuffer = new ArrayList<>();
this.appContext = appContext;
this.fileName = filename;
final Thread.UncaughtExceptionHandler defaultUEH = Thread.getDefaultUncaughtExceptionHandler();
Thread.UncaughtExceptionHandler _unCaughtExceptionHandler = new Thread.UncaughtExceptionHandler() {
@Override
public void uncaughtException(Thread thread, Throwable ex) {
while (PayuUploadDeviceAnalytics.this.mIsLocked) {
}
PayuUploadDeviceAnalytics.this.setLock();
try {
FileOutputStream fileOutputStream = PayuUploadDeviceAnalytics.this.appContext.openFileOutput(PayuUploadDeviceAnalytics.this.fileName, 0);
int c = PayuUploadDeviceAnalytics.this.mBuffer.size();
for (int i = 0; i < c; i++) {
fileOutputStream.write((((String) PayuUploadDeviceAnalytics.this.mBuffer.get(i)) + "\r\n").getBytes());
}
fileOutputStream.close();
} catch (IOException e) {
e.printStackTrace();
}
PayuUploadDeviceAnalytics.this.releaseLock();
defaultUEH.uncaughtException(thread, ex);
}
};
Thread.setDefaultUncaughtExceptionHandler(_unCaughtExceptionHandler);
}
public void log(String msg) {
JSONArray jsonArray;
if (this.mIsLocked) {
this.mBuffer.add(msg);
} else {
setLock();
try {
JSONObject newobject = new JSONObject(msg);
new JSONArray();
String temp = "";
File file = new File(this.appContext.getFilesDir(), this.fileName);
if (!file.exists()) {
this.appContext.openFileOutput(this.fileName, 0);
}
FileInputStream fileInputStream = this.appContext.openFileInput(this.fileName);
while (fileInputStream != null && fileInputStream.available() > 0) {
int c = fileInputStream.read();
if (c == -1) {
break;
} else {
temp = temp + Character.toString((char) c);
}
}
if (temp.equalsIgnoreCase("")) {
jsonArray = new JSONArray();
} else {
jsonArray = new JSONArray(temp);
}
fileInputStream.close();
FileOutputStream fileOutputStream = this.appContext.openFileOutput(this.fileName, 0);
jsonArray.put(jsonArray.length(), newobject);
fileOutputStream.write((temp + jsonArray.toString() + "\r\n").getBytes());
fileOutputStream.close();
} catch (IOException e) {
e.printStackTrace();
this.mBuffer.add(msg);
} catch (JSONException e2) {
e2.printStackTrace();
}
releaseLock();
}
resetTimer();
}
public void resetTimer() {
Timer timer = this.mTimer;
if (timer != null) {
timer.cancel();
}
Timer timer2 = new Timer();
this.mTimer = timer2;
timer2.schedule(new TimerTask() {
@Override
public void run() {
while (PayuUploadDeviceAnalytics.this.mIsLocked) {
}
long unused = PayuUploadDeviceAnalytics.TIMER_DELAY = PayUAnalyticsConstant.PA_TIMER_DELAY;
PayuUploadDeviceAnalytics.this.setLock();
String temp = "";
try {
try {
File file = new File(PayuUploadDeviceAnalytics.this.appContext.getFilesDir(), PayuUploadDeviceAnalytics.this.fileName);
if (!file.exists()) {
PayuUploadDeviceAnalytics.this.appContext.openFileOutput(PayuUploadDeviceAnalytics.this.fileName, 0);
}
FileInputStream fileInputStream = PayuUploadDeviceAnalytics.this.appContext.openFileInput(PayuUploadDeviceAnalytics.this.fileName);
while (true) {
int c = fileInputStream.read();
if (c == -1) {
break;
} else {
temp = temp + Character.toString((char) c);
}
}
fileInputStream.close();
int c2 = PayuUploadDeviceAnalytics.this.mBuffer.size();
while (c2 > 0) {
c2--;
temp = temp + ((String) PayuUploadDeviceAnalytics.this.mBuffer.get(c2)) + "\r\n";
if (c2 >= 0 && PayuUploadDeviceAnalytics.this.mBuffer.size() > c2) {
PayuUploadDeviceAnalytics.this.mBuffer.remove(c2);
}
}
String temp2 = temp.trim();
if (temp2.length() > 0) {
PayuUploadDeviceAnalytics.this.new UploadData(temp2).execute(temp2);
}
} catch (IOException e) {
e.printStackTrace();
int c3 = PayuUploadDeviceAnalytics.this.mBuffer.size();
while (c3 > 0) {
c3--;
temp = temp + ((String) PayuUploadDeviceAnalytics.this.mBuffer.get(c3)) + "\r\n";
if (c3 >= 0 && PayuUploadDeviceAnalytics.this.mBuffer.size() > c3) {
PayuUploadDeviceAnalytics.this.mBuffer.remove(c3);
}
}
String temp3 = temp.trim();
if (temp3.length() > 0) {
PayuUploadDeviceAnalytics.this.new UploadData(temp3).execute(temp3);
}
}
if (PayuUploadDeviceAnalytics.this.mBuffer.size() > 0) {
PayuUploadDeviceAnalytics.this.resetTimer();
}
PayuUploadDeviceAnalytics.this.releaseLock();
} catch (Throwable th) {
int c4 = PayuUploadDeviceAnalytics.this.mBuffer.size();
while (c4 > 0) {
c4--;
temp = temp + ((String) PayuUploadDeviceAnalytics.this.mBuffer.get(c4)) + "\r\n";
if (c4 >= 0 && PayuUploadDeviceAnalytics.this.mBuffer.size() > c4) {
PayuUploadDeviceAnalytics.this.mBuffer.remove(c4);
}
}
String temp4 = temp.trim();
if (temp4.length() > 0) {
PayuUploadDeviceAnalytics.this.new UploadData(temp4).execute(temp4);
}
throw th;
}
}
}, TIMER_DELAY);
}
synchronized void setLock() {
this.mIsLocked = true;
}
synchronized void releaseLock() {
this.mIsLocked = false;
}
public boolean getbooleanSharedPreference(String key) {
SharedPreferences sharedPreferences = this.appContext.getSharedPreferences("com.payu", 0);
return sharedPreferences.getBoolean(key, false);
}
public void setBooleanSharedPreference(String key, boolean value) {
SharedPreferences.Editor editor = this.appContext.getSharedPreferences("com.payu", 0).edit();
editor.putBoolean(key, value);
editor.apply();
}
public static JSONArray removeJsonObjectAtJsonArrayIndex(JSONArray source, int index) throws JSONException {
if (index < 0 || index > source.length() - 1) {
throw new IndexOutOfBoundsException();
}
JSONArray copy = new JSONArray();
int count = source.length();
for (int i = 0; i < count; i++) {
if (i != index) {
copy.put(source.get(i));
}
}
return copy;
}
public class UploadData extends AsyncTask<String, Void, String> {
private String temp;
UploadData(String temp) {
this.temp = temp;
}
@Override
public void onPostExecute(String aVoid) {
super.onPostExecute((UploadData) aVoid);
}
@Override
public String doInBackground(String... strarr) {
try {
try {
try {
JSONArray jsonArray = new JSONArray(strarr[0]);
JSONArray editorJsonArray = jsonArray;
for (int j = 0; j < editorJsonArray.length(); j++) {
if (PayuUploadDeviceAnalytics.this.getbooleanSharedPreference(((JSONObject) editorJsonArray.get(j)).getString("merchant_key") + "|" + ((JSONObject) editorJsonArray.get(j)).getString("txnid"))) {
jsonArray = PayuUploadDeviceAnalytics.removeJsonObjectAtJsonArrayIndex(editorJsonArray, j);
}
}
int j2 = jsonArray.length();
if (j2 > 0) {
String postData = "mobile_data=" + jsonArray.toString();
postData.getBytes("UTF-8");
URL url = new URL(PayuUploadDeviceAnalytics.this.ANALYTICS_URL);
HttpsURLConnection conn = PayuUtils.getHttpsConn(url.toString(), postData);
if (conn == null) {
PayuUploadDeviceAnalytics.this.appContext.deleteFile(PayuUploadDeviceAnalytics.this.fileName);
return null;
}
int responseCode = conn.getResponseCode();
InputStream responseInputStream = conn.getInputStream();
StringBuffer responseStringBuffer = new StringBuffer();
byte[] byteContainer = new byte[LockFreeTaskQueueCore.MIN_ADD_SPIN_CAPACITY];
while (true) {
int i = responseInputStream.read(byteContainer);
JSONArray editorJsonArray2 = editorJsonArray;
if (i == -1) {
break;
}
String postData2 = postData;
responseStringBuffer.append(new String(byteContainer, 0, i));
postData = postData2;
editorJsonArray = editorJsonArray2;
}
if (responseCode != 200) {
try {
FileOutputStream fileOutputStream = PayuUploadDeviceAnalytics.this.appContext.openFileOutput(PayuUploadDeviceAnalytics.this.fileName, 0);
fileOutputStream.write(this.temp.getBytes());
fileOutputStream.close();
} catch (IOException e1) {
e1.printStackTrace();
}
} else {
try {
JSONObject jsonObject = new JSONObject(responseStringBuffer.toString());
if (!jsonObject.has("status") || jsonObject.getString("status").equalsIgnoreCase("")) {
try {
FileOutputStream fileOutputStream2 = PayuUploadDeviceAnalytics.this.appContext.openFileOutput(PayuUploadDeviceAnalytics.this.fileName, 0);
fileOutputStream2.write(this.temp.getBytes());
fileOutputStream2.close();
} catch (IOException e12) {
e12.printStackTrace();
}
} else {
PayuUploadDeviceAnalytics.this.appContext.deleteFile(PayuUploadDeviceAnalytics.this.fileName);
if (jsonObject.has("status")) {
if (!jsonObject.getString("status").equalsIgnoreCase(b.TRANSACTION_STATUS_SUCCESS) && !jsonObject.getString("status").equalsIgnoreCase("-1")) {
}
int j3 = 0;
while (j3 < jsonArray.length()) {
JSONObject jsonObject2 = jsonObject;
PayuUploadDeviceAnalytics.this.setBooleanSharedPreference(((JSONObject) jsonArray.get(j3)).getString("merchant_key") + "|" + ((JSONObject) jsonArray.get(j3)).getString("txnid"), true);
j3++;
jsonObject = jsonObject2;
}
}
try {
FileOutputStream fileOutputStream3 = PayuUploadDeviceAnalytics.this.appContext.openFileOutput(PayuUploadDeviceAnalytics.this.fileName, 0);
fileOutputStream3.write(this.temp.getBytes());
fileOutputStream3.close();
} catch (IOException e13) {
e13.printStackTrace();
}
}
} catch (Exception e) {
e.printStackTrace();
try {
FileOutputStream fileOutputStream4 = PayuUploadDeviceAnalytics.this.appContext.openFileOutput(PayuUploadDeviceAnalytics.this.fileName, 0);
fileOutputStream4.write(this.temp.getBytes());
fileOutputStream4.close();
} catch (IOException e14) {
e14.printStackTrace();
}
}
}
return null;
}
return null;
} catch (Exception e2) {
e2.printStackTrace();
return null;
}
} catch (IOException e3) {
PayuUploadDeviceAnalytics.this.resetTimer();
e3.printStackTrace();
return null;
}
} catch (MalformedURLException e4) {
e = e4;
e.printStackTrace();
return null;
} catch (ProtocolException e5) {
e = e5;
e.printStackTrace();
return null;
}
}
}
}