RbChat v4.56630229版本的 MD5 值为:d137f4b55d6b64b50641a810905f5957
以下内容为反编译后的 O.java 源代码,内容仅作参考
package io.card.payment;
import android.content.Context;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
import io.netty.handler.codec.http.HttpHeaders;
import java.io.UnsupportedEncodingException;
import java.lang.ref.WeakReference;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.text.StringCharacterIterator;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;
import java.util.UUID;
import org.apache.http.entity.StringEntity;
import org.json.JSONException;
import org.json.JSONObject;
public final class O {
private String a;
private JSONObject c;
private WeakReference e;
private boolean f;
private String b = UUID.randomUUID().toString();
private C0144a d = W.a();
public O(Context context, String str, boolean z) {
this.a = str;
this.f = z;
this.e = new WeakReference(context);
}
public static String a(String str, boolean z, CardType cardType) {
String c = z ? c(str) : str;
if (cardType == null) {
cardType = CardType.fromCardNumber(c);
}
int numberLength = cardType.numberLength();
if (c.length() == numberLength) {
if (numberLength != 16) {
return numberLength == 15 ? d(c) : str;
}
StringBuilder sb = new StringBuilder();
for (int i = 0; i < 16; i++) {
if (i != 0 && i % 4 == 0) {
sb.append(' ');
}
sb.append(c.charAt(i));
}
return sb.toString();
}
return str;
}
private void a(String str, Map map) {
try {
JSONObject jSONObject = map != null ? new JSONObject(map) : new JSONObject();
jSONObject.put("app_token", this.a);
jSONObject.put("detect_card_only", this.f);
jSONObject.put("event_name", str);
jSONObject.put("session_id", this.b);
jSONObject.put("timestamp", System.currentTimeMillis() / 1000);
jSONObject.put("device", new JSONObject(T.a((Context) this.e.get())));
jSONObject.put("android", new JSONObject(T.a()));
jSONObject.put("application_identifiers", b());
this.d.a((Context) this.e.get(), "https://api.card.io/0/sdk/analytics.json", new StringEntity(jSONObject.toString()), HttpHeaders.Values.APPLICATION_JSON, new P(str));
} catch (UnsupportedEncodingException e) {
e.getMessage();
} catch (JSONException e2) {
e2.getMessage();
}
}
public static boolean a(String str) {
int[][] iArr = {new int[]{0, 1, 2, 3, 4, 5, 6, 7, 8, 9}, new int[]{0, 2, 4, 6, 8, 1, 3, 5, 7, 9}};
StringCharacterIterator stringCharacterIterator = new StringCharacterIterator(str);
char last = stringCharacterIterator.last();
int i = 0;
int i2 = 0;
while (last != 65535) {
if (!Character.isDigit(last)) {
return false;
}
i += iArr[i2 & 1][last - '0'];
last = stringCharacterIterator.previous();
i2++;
}
return i % 10 == 0;
}
public static Date b(String str) {
String c = c(str);
int length = c.length();
SimpleDateFormat simpleDateFormat = length == 4 ? new SimpleDateFormat("MMyy") : length == 6 ? new SimpleDateFormat("MMyyyy") : null;
if (simpleDateFormat != null) {
try {
simpleDateFormat.setLenient(false);
return simpleDateFormat.parse(c);
} catch (ParseException unused) {
}
}
return null;
}
private JSONObject b() {
if (this.c == null) {
this.c = new JSONObject();
Context context = (Context) this.e.get();
String packageName = context.getPackageName();
this.c.put("package_name", context.getPackageName());
try {
PackageManager packageManager = context.getPackageManager();
PackageInfo packageInfo = packageManager.getPackageInfo(packageName, 0);
this.c.put("package_display_name", packageInfo.applicationInfo.loadLabel(packageManager).toString());
this.c.put("package_version", packageInfo.versionName);
} catch (PackageManager.NameNotFoundException unused) {
}
}
return this.c;
}
public static String c(String str) {
char[] charArray;
StringBuilder sb = new StringBuilder();
for (char c : str.toCharArray()) {
if (Character.isDigit(c)) {
sb.append(c);
}
}
return sb.toString();
}
private static String d(String str) {
StringBuilder sb = new StringBuilder();
for (int i = 0; i < 15; i++) {
if (i == 4 || i == 10) {
sb.append(' ');
}
sb.append(str.charAt(i));
}
return sb.toString();
}
public final void a() {
a("scan_start", (Map) null);
}
public final void a(am amVar, Throwable th, Map map) {
if (map == null) {
map = new HashMap();
}
map.put("error", amVar.toString());
if (th != null) {
map.put("error_detail", th.toString());
}
a("device_error", map);
}
public final void a(am amVar, Map map) {
a(amVar, (Throwable) null, map);
}
public final void a(Map map) {
a("scan_cancel", map);
}
public final void b(Map map) {
a("scan_manual_entry", map);
}
public final void c(Map map) {
a("scan_success", map);
}
}