QQ浏览器 v12.2.3.7053版本的 MD5 值为:8285ab3059e5c8b521a264dfbc5c3685
以下内容为反编译后的 m.java 源代码,内容仅作参考
package com.tencent.odk.player.client.a;
import android.content.ContentValues;
import android.content.Context;
import android.database.Cursor;
import android.database.DatabaseUtils;
import android.database.SQLException;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteFullException;
import android.os.Build;
import android.text.TextUtils;
import android.util.Base64;
import com.facebook.common.util.UriUtil;
import com.tencent.common.http.NetUtils;
import com.tencent.midas.api.APMidasPayAPI;
import com.tencent.odk.player.StatConfig;
import com.xiaomi.mipush.sdk.Constants;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.DataInputStream;
import java.io.File;
import java.io.InputStream;
import java.net.MalformedURLException;
import java.net.SocketTimeoutException;
import java.net.URI;
import java.net.URL;
import java.net.UnknownHostException;
import java.nio.ByteBuffer;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.zip.GZIPInputStream;
import java.util.zip.GZIPOutputStream;
import org.apache.http.Header;
import org.apache.http.HttpEntity;
import org.apache.http.HttpResponse;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.entity.ByteArrayEntity;
import org.apache.http.impl.client.DefaultHttpClient;
import org.apache.http.params.BasicHttpParams;
import org.apache.http.params.HttpConnectionParams;
import org.apache.http.util.EntityUtils;
import org.json.JSONObject;
public class m {
private static String f76413b = "omg_tencent_analysis.db";
private static Context j = null;
private static volatile String k = "pingma.qq.com:80/";
private static volatile String l = "http://pingma.qq.com:80/mstat/report";
private static volatile m n;
private static String o;
private static StringBuilder p = new StringBuilder(1000);
DefaultHttpClient f76414a;
private t f76415c;
private t f76416d;
private long e;
private com.tencent.odk.player.client.d.j f;
private String g;
private String h;
private volatile AtomicInteger i = new AtomicInteger(0);
private boolean m;
private m(Context context) {
this.f76415c = null;
this.f76416d = null;
this.f76414a = null;
this.e = 0L;
this.f = null;
this.g = "";
this.h = "";
this.m = true;
try {
this.e = System.currentTimeMillis() / 1000;
j = context.getApplicationContext();
this.g = b(context);
this.h = "pri_" + b(context);
File databasePath = j.getDatabasePath(this.g);
File databasePath2 = j.getDatabasePath(this.g);
if (!databasePath.exists() && !databasePath2.exists()) {
this.m = false;
return;
}
this.f76415c = new t(j, this.g);
this.f76416d = new t(j, this.h);
c();
if (this.i.get() == 0) {
com.tencent.odk.player.client.d.i.d("there has no record in mta, delete dababase file");
databasePath.delete();
databasePath2.delete();
this.m = false;
return;
}
b();
b(true);
b(false);
c();
com.tencent.odk.player.client.d.i.d("there has " + this.i.get() + " count in mta");
if (this.i.get() == 0) {
return;
}
this.f = new com.tencent.odk.player.client.d.j("mta_store_handler", false);
BasicHttpParams basicHttpParams = new BasicHttpParams();
HttpConnectionParams.setStaleCheckingEnabled(basicHttpParams, false);
HttpConnectionParams.setConnectionTimeout(basicHttpParams, 10000);
HttpConnectionParams.setSoTimeout(basicHttpParams, 10000);
this.f76414a = new DefaultHttpClient(basicHttpParams);
this.f76414a.setKeepAliveStrategy(new n(this));
} catch (Throwable th) {
com.tencent.odk.player.client.d.i.a("StatStore", th);
}
}
public static m a(Context context) {
if (n == null) {
synchronized (m.class) {
if (n == null) {
n = new m(context);
}
}
}
return n;
}
public static String a() {
return l;
}
public static String a(Context context, String str) {
if (o == null) {
o = com.tencent.odk.player.client.repository.a.y(context);
}
if (o == null) {
return str;
}
return str + "_" + o;
}
private static String a(String str, String str2) {
StringBuilder sb = new StringBuilder(str.length() + str2.length() + 10);
if (!str.startsWith(UriUtil.HTTP_SCHEME)) {
sb.append(NetUtils.SCHEME_HTTP);
}
sb.append(str);
if (!str.endsWith("/") && !str2.startsWith("/")) {
sb.append("/");
}
sb.append(str2);
return sb.toString();
}
private String a(List list) {
StringBuilder sb = new StringBuilder(list.size() * 3);
sb.append("event_id in (");
int size = list.size();
Iterator it = list.iterator();
int i = 0;
while (it.hasNext()) {
sb.append(((u) it.next()).f76433a);
if (i != size - 1) {
sb.append(Constants.ACCEPT_TIME_SEPARATOR_SP);
}
i++;
}
sb.append(")");
return sb.toString();
}
private synchronized void a(int i, boolean z) {
try {
} finally {
}
if (this.i.get() > 0 && i > 0) {
if (StatConfig.isDebugEnable()) {
com.tencent.odk.player.client.d.i.a("Load " + this.i + " unsent events");
}
ArrayList arrayList = new ArrayList(i);
b(arrayList, i, z);
if (arrayList.size() > 0) {
if (StatConfig.isDebugEnable()) {
com.tencent.odk.player.client.d.i.a("Peek " + arrayList.size() + " unsent events.");
}
a(arrayList, 2, z);
com.tencent.odk.player.client.d.k.a(new q(this, arrayList, z));
}
}
}
public static void a(String str) {
if (str == null || str.length() == 0) {
com.tencent.odk.player.client.d.i.b("statReportUrl cannot be null or empty.");
return;
}
l = str;
try {
k = new URI(str).getHost();
} catch (Exception e) {
com.tencent.odk.player.client.d.i.b("", e);
}
com.tencent.odk.player.client.d.i.d("url:" + str + ", domain:" + k);
}
public synchronized void a(List list, int i, boolean z) {
String str;
StringBuilder sb;
if (list.size() == 0) {
return;
}
SQLiteDatabase sQLiteDatabase = null;
try {
sQLiteDatabase = c(z);
if (i == 2) {
sb = new StringBuilder();
sb.append("update events set status=");
sb.append(i);
sb.append(", send_count=send_count+1 where ");
sb.append(a(list));
} else {
sb = new StringBuilder();
sb.append("update events set status=");
sb.append(i);
sb.append(" where ");
sb.append(a(list));
}
String sb2 = sb.toString();
if (StatConfig.isDebugEnable()) {
com.tencent.odk.player.client.d.i.a("update sql:" + sb2);
}
sQLiteDatabase.beginTransaction();
sQLiteDatabase.execSQL(sb2);
sQLiteDatabase.setTransactionSuccessful();
if (sQLiteDatabase != null) {
try {
sQLiteDatabase.endTransaction();
sQLiteDatabase.close();
} catch (Throwable th) {
th = th;
str = "";
com.tencent.odk.player.client.d.i.a(str, th);
}
}
} catch (Throwable th2) {
try {
com.tencent.odk.player.client.d.i.a("", th2);
if (sQLiteDatabase != null) {
try {
sQLiteDatabase.endTransaction();
sQLiteDatabase.close();
} catch (Throwable th3) {
th = th3;
str = "";
com.tencent.odk.player.client.d.i.a(str, th);
}
}
} finally {
}
}
}
public synchronized void a(List list, boolean z) {
SQLiteDatabase sQLiteDatabase;
Throwable th;
String str;
if (list.size() == 0) {
return;
}
if (StatConfig.isDebugEnable()) {
com.tencent.odk.player.client.d.i.a("Delete " + list.size() + " events, important:" + z);
}
StringBuilder sb = new StringBuilder(list.size() * 3);
sb.append("event_id in (");
int i = 0;
int size = list.size();
Iterator it = list.iterator();
while (it.hasNext()) {
sb.append(((u) it.next()).f76433a);
if (i != size - 1) {
sb.append(Constants.ACCEPT_TIME_SEPARATOR_SP);
}
i++;
}
sb.append(")");
try {
sQLiteDatabase = c(z);
try {
sQLiteDatabase.beginTransaction();
int delete = sQLiteDatabase.delete("events", sb.toString(), null);
if (StatConfig.isDebugEnable()) {
com.tencent.odk.player.client.d.i.a("delete " + size + " event " + sb.toString() + ", success delete:" + delete);
}
this.i.addAndGet(-delete);
sQLiteDatabase.setTransactionSuccessful();
c();
if (sQLiteDatabase != null) {
try {
sQLiteDatabase.endTransaction();
sQLiteDatabase.close();
} catch (Throwable th2) {
th = th2;
str = "";
com.tencent.odk.player.client.d.i.a(str, th);
}
}
} catch (Throwable th3) {
th = th3;
try {
com.tencent.odk.player.client.d.i.a("", th);
if (sQLiteDatabase != null) {
try {
sQLiteDatabase.endTransaction();
sQLiteDatabase.close();
} catch (Throwable th4) {
th = th4;
str = "";
com.tencent.odk.player.client.d.i.a(str, th);
}
}
} finally {
}
}
} catch (Throwable th5) {
sQLiteDatabase = null;
th = th5;
}
}
private boolean a(boolean z) {
SQLiteDatabase sQLiteDatabase;
int delete;
Cursor query;
int count;
Cursor cursor = null;
boolean z2 = true;
try {
} catch (Throwable th) {
th = th;
}
try {
try {
sQLiteDatabase = c(z);
} catch (Throwable th2) {
th2.printStackTrace();
}
try {
sQLiteDatabase.beginTransaction();
ContentValues contentValues = new ContentValues();
contentValues.put("content", APMidasPayAPI.ENV_TEST);
contentValues.put("send_count", "100");
contentValues.put("status", Integer.toString(1));
contentValues.put("timestamp", Long.valueOf(System.currentTimeMillis()));
sQLiteDatabase.insert("events", null, contentValues);
sQLiteDatabase.setTransactionSuccessful();
sQLiteDatabase.endTransaction();
delete = sQLiteDatabase.delete("events", "content = ?", new String[]{APMidasPayAPI.ENV_TEST});
query = sQLiteDatabase.query("events", null, "content=?", new String[]{APMidasPayAPI.ENV_TEST}, null, null, null, "1");
count = query.getCount();
query.close();
} catch (SQLiteFullException unused) {
if (0 != 0) {
cursor.close();
}
if (sQLiteDatabase != null) {
sQLiteDatabase.close();
}
return z2;
} catch (Exception e) {
e = e;
com.tencent.odk.player.client.d.i.a("", e);
z2 = false;
if (0 != 0) {
cursor.close();
}
if (sQLiteDatabase != null) {
sQLiteDatabase.close();
}
return z2;
}
} catch (SQLiteFullException unused2) {
sQLiteDatabase = null;
} catch (Exception e2) {
e = e2;
sQLiteDatabase = null;
} catch (Throwable th3) {
th = th3;
z = 0;
if (0 != 0) {
try {
cursor.close();
} catch (Throwable th4) {
th4.printStackTrace();
throw th;
}
}
if (z != 0) {
z.close();
}
throw th;
}
if (delete == 0 || count > 0) {
throw new SQLException("test delete error.");
}
if (StatConfig.isDebugEnable()) {
String[] split = sQLiteDatabase.getPath().split("/");
com.tencent.odk.player.client.d.i.a("test db passed, db name:" + split[split.length - 1]);
}
if (query != null) {
query.close();
}
if (sQLiteDatabase != null) {
sQLiteDatabase.close();
}
return z2;
}
public static byte[] a(byte[] bArr) {
ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(bArr);
GZIPInputStream gZIPInputStream = new GZIPInputStream(byteArrayInputStream);
byte[] bArr2 = new byte[4096];
ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream(bArr.length * 2);
while (true) {
int read = gZIPInputStream.read(bArr2);
if (read == -1) {
byte[] byteArray = byteArrayOutputStream.toByteArray();
byteArrayInputStream.close();
gZIPInputStream.close();
byteArrayOutputStream.close();
return byteArray;
}
byteArrayOutputStream.write(bArr2, 0, read);
}
}
public static String b(Context context) {
return a(context, f76413b);
}
private void b() {
if (!a(false)) {
com.tencent.odk.player.client.d.i.c("delete " + t.a(this.f76415c) + ", and create new one");
this.f76415c.a();
this.f76415c = new t(j, this.g);
}
if (a(true)) {
return;
}
com.tencent.odk.player.client.d.i.c("delete " + t.a(this.f76416d) + ", and create new one");
this.f76416d.a();
this.f76416d = new t(j, this.h);
}
public void b(int i, boolean z) {
if (i == -1) {
i = !z ? d() : e();
}
if (i > 0) {
int c2 = com.tencent.odk.player.client.repository.b.c();
if (i > c2 && c2 > 0) {
i = c2;
}
int i2 = i / 30;
int i3 = i % 30;
if (StatConfig.isDebugEnable()) {
com.tencent.odk.player.client.d.i.a("sentStoreEventsByDb sendNumbers=" + i + ",important=" + z + ",maxSendNumPerFor1Period=" + c2 + ",maxCount=" + i2 + ",restNumbers=" + i3);
}
for (int i4 = 0; i4 < i2; i4++) {
a(30, z);
}
if (i3 > 0) {
a(i3, z);
}
}
}
public static void b(String str) {
if (TextUtils.isEmpty(str)) {
com.tencent.odk.player.client.d.i.b("setStatReportHost host cannot be null or empty.");
return;
}
String a2 = a(str, "mstat/report");
try {
new URL(a2);
l = a2;
com.tencent.odk.player.client.d.i.d("setStatReportHost url:" + l + ", host:" + str);
} catch (MalformedURLException e) {
com.tencent.odk.player.client.d.i.b("setStatReportHost " + str + " " + e.toString());
}
}
private void b(List list, int i, boolean z) {
SQLiteDatabase sQLiteDatabase;
Cursor cursor = null;
try {
try {
sQLiteDatabase = d(z);
try {
cursor = sQLiteDatabase.query("events", null, "status=?", new String[]{Integer.toString(1)}, null, null, null, Integer.toString(i));
while (cursor.moveToNext()) {
long j2 = cursor.getLong(0);
String c2 = c(cursor.getString(1));
int i2 = cursor.getInt(2);
int i3 = cursor.getInt(3);
u uVar = new u(j2, c2, i2, i3);
if (StatConfig.isDebugEnable()) {
com.tencent.odk.player.client.d.i.a("peek event, id=" + j2 + ",send_count=" + i3 + ",timestamp=" + cursor.getLong(4));
}
list.add(uVar);
}
if (cursor != null) {
cursor.close();
}
if (sQLiteDatabase != null) {
sQLiteDatabase.close();
}
} catch (Throwable th) {
th = th;
try {
com.tencent.odk.player.client.d.i.a("", th);
if (cursor != null) {
cursor.close();
}
if (sQLiteDatabase != null) {
sQLiteDatabase.close();
}
} catch (Throwable th2) {
if (cursor != null) {
try {
cursor.close();
} catch (Throwable th3) {
th3.printStackTrace();
throw th2;
}
}
if (sQLiteDatabase != null) {
sQLiteDatabase.close();
}
throw th2;
}
}
} catch (Throwable th4) {
th4.printStackTrace();
}
} catch (Throwable th5) {
th = th5;
sQLiteDatabase = null;
}
}
private void b(boolean z) {
SQLiteDatabase sQLiteDatabase;
try {
try {
sQLiteDatabase = c(z);
try {
sQLiteDatabase.beginTransaction();
ContentValues contentValues = new ContentValues();
contentValues.put("status", (Integer) 1);
int update = sQLiteDatabase.update("events", contentValues, "status=?", new String[]{Long.toString(2L)});
if (StatConfig.isDebugEnable()) {
com.tencent.odk.player.client.d.i.a("update " + update + " unsent events.");
}
sQLiteDatabase.setTransactionSuccessful();
} catch (Throwable th) {
th = th;
try {
com.tencent.odk.player.client.d.i.a("initDbEvent", th);
if (sQLiteDatabase != null) {
sQLiteDatabase.endTransaction();
sQLiteDatabase.close();
}
return;
} catch (Throwable th2) {
if (sQLiteDatabase != null) {
try {
sQLiteDatabase.endTransaction();
sQLiteDatabase.close();
} catch (Throwable th3) {
com.tencent.odk.player.client.d.i.a("initDbEvent", th3);
}
}
throw th2;
}
}
} catch (Throwable th4) {
com.tencent.odk.player.client.d.i.a("initDbEvent", th4);
return;
}
} catch (Throwable th5) {
th = th5;
sQLiteDatabase = null;
}
if (sQLiteDatabase != null) {
sQLiteDatabase.endTransaction();
sQLiteDatabase.close();
}
}
private SQLiteDatabase c(boolean z) {
return (!z ? this.f76415c : this.f76416d).getWritableDatabase();
}
public static String c(String str) {
if (str == null) {
return null;
}
if (Build.VERSION.SDK_INT < 8) {
return str;
}
try {
return new String(com.tencent.odk.player.client.d.n.b(Base64.decode(str.getBytes("UTF-8"), 0)), "UTF-8");
} catch (Throwable th) {
com.tencent.odk.player.client.d.i.a("decode error", th);
return str;
}
}
private void c() {
this.i.set(d() + e());
}
private int d() {
try {
return (int) DatabaseUtils.queryNumEntries(this.f76415c.getReadableDatabase(), "events");
} catch (Throwable th) {
com.tencent.odk.player.client.d.i.a("", th);
return 0;
}
}
private SQLiteDatabase d(boolean z) {
return (!z ? this.f76415c : this.f76416d).getReadableDatabase();
}
private int e() {
try {
return (int) DatabaseUtils.queryNumEntries(this.f76416d.getReadableDatabase(), "events");
} catch (Throwable th) {
com.tencent.odk.player.client.d.i.a("", th);
return 0;
}
}
public void a(int i) {
if (this.m && this.i.get() > 0) {
this.f.a(new s(this));
}
}
public void a(List list, int i, boolean z, boolean z2) {
com.tencent.odk.player.client.d.j jVar = this.f;
if (jVar != null) {
jVar.a(new o(this, list, i, z, z2));
}
}
public void a(List list, l lVar) {
ByteArrayOutputStream byteArrayOutputStream;
HttpResponse execute;
HttpEntity entity;
int statusCode;
long contentLength;
if (list == null || list.isEmpty()) {
return;
}
int size = list.size();
try {
p.delete(0, p.length());
p.append("[");
for (int i = 0; i < size; i++) {
p.append(list.get(i).toString());
if (i != size - 1) {
p.append(Constants.ACCEPT_TIME_SEPARATOR_SP);
}
}
p.append("]");
String sb = p.toString();
int length = sb.length();
String str = a() + "/?index=" + this.e;
this.e++;
if (StatConfig.isDebugEnable()) {
com.tencent.odk.player.client.d.i.a("[" + str + "]Send request(" + length + "bytes), content:" + sb);
}
HttpPost httpPost = new HttpPost(str);
httpPost.addHeader("Accept-Encoding", "gzip");
httpPost.setHeader("Connection", "Keep-Alive");
httpPost.removeHeaders("Cache-Control");
byteArrayOutputStream = new ByteArrayOutputStream(length);
byte[] bytes = sb.getBytes("UTF-8");
int length2 = bytes.length;
if (length > 256) {
httpPost.removeHeaders("Content-Encoding");
httpPost.addHeader("Content-Encoding", "rc4,gzip");
byteArrayOutputStream.write(new byte[4]);
GZIPOutputStream gZIPOutputStream = new GZIPOutputStream(byteArrayOutputStream);
gZIPOutputStream.write(bytes);
gZIPOutputStream.close();
bytes = byteArrayOutputStream.toByteArray();
ByteBuffer.wrap(bytes, 0, 4).putInt(length2);
if (StatConfig.isDebugEnable()) {
com.tencent.odk.player.client.d.i.d("before Gzip:" + length2 + " bytes, after Gzip:" + bytes.length + " bytes");
}
}
httpPost.setEntity(new ByteArrayEntity(com.tencent.odk.player.client.d.n.a(bytes)));
execute = this.f76414a.execute(httpPost);
entity = execute.getEntity();
statusCode = execute.getStatusLine().getStatusCode();
contentLength = entity.getContentLength();
if (StatConfig.isDebugEnable()) {
com.tencent.odk.player.client.d.i.a("http recv response status code:" + statusCode + ", content length:" + contentLength);
}
} catch (Throwable th) {
th = th;
}
if (contentLength <= 0) {
com.tencent.odk.player.client.d.i.b("Server response no data.");
if (lVar != null) {
lVar.b();
}
EntityUtils.toString(entity);
return;
}
InputStream content = entity.getContent();
DataInputStream dataInputStream = new DataInputStream(content);
byte[] bArr = new byte[(int) entity.getContentLength()];
dataInputStream.readFully(bArr);
content.close();
dataInputStream.close();
Header firstHeader = execute.getFirstHeader("Content-Encoding");
com.tencent.odk.player.client.d.i.d("http contentEncoding:" + firstHeader);
if (firstHeader != null) {
if (firstHeader.getValue().equalsIgnoreCase("gzip,rc4")) {
bArr = com.tencent.odk.player.client.d.n.b(a(bArr));
} else if (firstHeader.getValue().equalsIgnoreCase("rc4,gzip")) {
bArr = a(com.tencent.odk.player.client.d.n.b(bArr));
} else if (firstHeader.getValue().equalsIgnoreCase("gzip")) {
bArr = a(bArr);
} else if (firstHeader.getValue().equalsIgnoreCase("rc4")) {
bArr = com.tencent.odk.player.client.d.n.b(bArr);
}
}
String str2 = new String(bArr, "UTF-8");
if (StatConfig.isDebugEnable()) {
com.tencent.odk.player.client.d.i.a("http get response data:" + str2);
}
JSONObject jSONObject = new JSONObject(str2);
if (statusCode == 200) {
if (lVar != null) {
if (jSONObject.optInt("ret") == 0) {
lVar.a();
} else {
com.tencent.odk.player.client.d.i.b("response error data.");
lVar.b();
}
}
content.close();
byteArrayOutputStream.close();
th = null;
if (th == null) {
com.tencent.odk.player.client.d.i.a("", th);
if (lVar != null) {
try {
lVar.b();
} catch (Throwable th2) {
com.tencent.odk.player.client.d.i.a("", th2);
}
}
if (th instanceof OutOfMemoryError) {
System.gc();
p = null;
p = new StringBuilder(2048);
return;
} else {
if (th instanceof UnknownHostException) {
return;
}
boolean z = th instanceof SocketTimeoutException;
return;
}
}
return;
}
com.tencent.odk.player.client.d.i.b("Server response error code:" + statusCode + ", error:" + new String(bArr, "UTF-8"));
if (lVar != null) {
lVar.b();
}
content.close();
byteArrayOutputStream.close();
th = null;
if (th == null) {
}
}
public void a(List list, boolean z, boolean z2) {
com.tencent.odk.player.client.d.j jVar = this.f;
if (jVar != null) {
jVar.a(new p(this, list, z, z2));
}
}
}