電視直播.apk(点击下载) / UncaughtExceptionProcessor.java
package com.meishu.sdk.core.exception;
import android.content.Context;
import androidx.annotation.NonNull;
import com.baidu.mobads.sdk.api.IAdInterListener;
import com.mbridge.msdk.playercommon.exoplayer2.C;
import com.meishu.sdk.core.utils.HttpUtil;
import com.meishu.sdk.core.utils.LogUtil;
import com.meishu.sdk.core.utils.RequestUtil;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.PrintStream;
import java.lang.Thread;
import java.nio.charset.Charset;
import java.util.ArrayList;
import java.util.Map;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.TimeUnit;
import okhttp3.Call;
import okhttp3.Callback;
import okhttp3.FormBody;
import okhttp3.Request;
import okhttp3.Response;
public class UncaughtExceptionProcessor {
private static final String REPORT_URL = "https://sdk-report.1rtb.com/reports";
private static final String TAG = "UncaughtExceptionProcessor";
private static final ArrayList<String> excludeList;
private static boolean process = true;
/* access modifiers changed from: package-private */
public static class MeishuUncaughtExceptionHandler implements Thread.UncaughtExceptionHandler {
private Context context;
private boolean isTest;
private Thread.UncaughtExceptionHandler otherHandler;
public MeishuUncaughtExceptionHandler(Context context2, boolean z, Thread.UncaughtExceptionHandler uncaughtExceptionHandler) {
this.context = context2;
this.isTest = z;
this.otherHandler = uncaughtExceptionHandler;
}
public void uncaughtException(@NonNull Thread thread, @NonNull Throwable th) {
try {
UncaughtExceptionProcessor.uploadException(this.context, this.isTest, thread, th);
if (this.otherHandler != null) {
this.otherHandler.uncaughtException(thread, th);
}
} catch (Exception e2) {
e2.printStackTrace();
}
}
}
static {
ArrayList<String> arrayList = new ArrayList<>();
excludeList = arrayList;
arrayList.add("device_adid");
excludeList.add("device_imsi");
excludeList.add("device_imei");
excludeList.add("device_geo_lon");
excludeList.add("device_geo_lat");
excludeList.add("device_battery_level");
excludeList.add("device_mac");
excludeList.add("secure");
excludeList.add("device_apiLevel");
excludeList.add("is_mobile");
excludeList.add("device_type");
excludeList.add("device_oaid");
excludeList.add("device_ssid");
excludeList.add("device_wifi_mac");
}
public static void init(Context context, boolean z) {
if (process) {
Thread.UncaughtExceptionHandler defaultUncaughtExceptionHandler = Thread.getDefaultUncaughtExceptionHandler();
if (!(defaultUncaughtExceptionHandler instanceof MeishuUncaughtExceptionHandler)) {
Thread.setDefaultUncaughtExceptionHandler(new MeishuUncaughtExceptionHandler(context, z, defaultUncaughtExceptionHandler));
}
}
}
public static void setProcess(boolean z) {
process = z;
}
/* access modifiers changed from: private */
public static void uploadException(Context context, boolean z, @NonNull Thread thread, @NonNull Throwable th) {
try {
Map<String, String> params = RequestUtil.getParams(context, null, null, 0, 0);
FormBody.Builder builder = new FormBody.Builder();
for (Map.Entry<String, String> entry : params.entrySet()) {
if (!excludeList.contains(entry.getKey())) {
builder.add(entry.getKey(), entry.getValue());
}
}
builder.add("thread", thread.getName());
ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
th.printStackTrace(new PrintStream(byteArrayOutputStream));
builder.add("message", new String(byteArrayOutputStream.toByteArray(), Charset.forName(C.UTF8_NAME)));
builder.add("env", z ? "test" : IAdInterListener.AdReqParam.PROD);
final CountDownLatch countDownLatch = new CountDownLatch(1);
HttpUtil.doCommonRequest(new Request.Builder().url(REPORT_URL).post(builder.build()).build(), new Callback() {
/* class com.meishu.sdk.core.exception.UncaughtExceptionProcessor.AnonymousClass1 */
@Override // okhttp3.Callback
public void onFailure(Call call, IOException iOException) {
iOException.printStackTrace();
countDownLatch.countDown();
LogUtil.e(UncaughtExceptionProcessor.TAG, "uploadException error ");
}
@Override // okhttp3.Callback
public void onResponse(Call call, Response response) {
countDownLatch.countDown();
LogUtil.d(UncaughtExceptionProcessor.TAG, "uploadException " + response.toString());
}
});
countDownLatch.await(2, TimeUnit.SECONDS);
} catch (Throwable th2) {
th2.printStackTrace();
}
}
}