Closed flazouh closed 1 year ago
That is smali - https://github.com/google/smali
I don't see a problem here nor what you are expecting. That is perfectly valid output for a disassembly of a dex file into an intermediate language of smali.
Based on your reply I did some research, and I used a program called jadx (https://github.com/skylot/jadx) to reconstruct the java, but the java is very badly written, with multiple methods having just the letter "a" as name and same for the variable, for instance:
package c.e.a.j;
import android.os.Build;
import android.util.Log;
import c.d.a.a.k0;
import c.d.a.a.l0;
import c.d.a.a.n0;
import c.d.a.a.p0;
import c.d.a.a.q0;
import c.d.a.a.u;
import c.d.a.a.u0;
import c.e.a.j.s.b;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.sayhi.android.dataobjects.SubmitFeedbackRequest;
import com.sayhi.android.dataobjects.TranslationMessage;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.nio.ByteBuffer;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import java.util.UUID;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
/* compiled from: WebSocketClient.java */
/* loaded from: classes.dex */
public class o {
private static o j;
/* renamed from: a reason: collision with root package name */
private k0 f4294a;
/* renamed from: b reason: collision with root package name */
private String f4295b;
/* renamed from: c reason: collision with root package name */
private String f4296c;
/* renamed from: d reason: collision with root package name */
private Map<String, c> f4297d = new HashMap();
/* renamed from: e reason: collision with root package name */
private Map<c, c.e.a.j.s.a> f4298e = new HashMap();
/* renamed from: f reason: collision with root package name */
private Map<c, c.e.a.j.r.a> f4299f = new HashMap();
/* renamed from: g reason: collision with root package name */
private Map<c, c.e.a.j.p.a> f4300g = new HashMap();
private Map<c, Boolean> h = new HashMap();
private c i;
/* JADX INFO: Access modifiers changed from: package-private */
/* compiled from: WebSocketClient.java */
/* loaded from: classes.dex */
public class a extends l0 {
a() {
}
private boolean b(JSONObject jSONObject) throws JSONException {
c b2 = o.this.b(jSONObject.getString("messageId"));
if (b2 == null || !o.this.h.containsKey(b2)) {
return false;
}
return ((Boolean) o.this.h.get(b2)).booleanValue();
}
@Override // c.d.a.a.s0
public void a(k0 k0Var, u0 u0Var) throws Exception {
Log.d("WebSocketClient", "State");
}
@Override // c.d.a.a.s0
public void a(k0 k0Var, String str) throws Exception {
}
@Override // c.d.a.a.s0
public void a(k0 k0Var, Map<String, List<String>> map) throws Exception {
Log.d("WebSocketClient", "Connected to server!");
}
private TranslationMessage a(JSONObject jSONObject) throws JSONException {
c b2 = o.this.b(jSONObject.getString("messageId"));
TranslationMessage translationMessage = null;
if (b2 != null) {
c.e.a.j.s.a aVar = (c.e.a.j.s.a) o.this.f4298e.get(b2);
c.e.a.j.r.a aVar2 = (c.e.a.j.r.a) o.this.f4299f.get(b2);
c.e.a.j.p.a aVar3 = (c.e.a.j.p.a) o.this.f4300g.get(b2);
if (aVar != null && aVar2 == null && aVar3 == null) {
translationMessage = aVar.d();
} else if (aVar == null && aVar2 != null && aVar3 == null) {
translationMessage = aVar2.f();
} else if (aVar == null && aVar2 == null && aVar3 != null) {
translationMessage = aVar3.e();
}
o.this.f4298e.remove(b2);
o.this.f4299f.remove(b2);
o.this.f4300g.remove(b2);
}
return translationMessage;
}
@Override // c.d.a.a.s0
public void a(k0 k0Var, byte[] bArr) throws Exception {
try {
JSONObject a2 = o.this.a(new ByteArrayInputStream(bArr), k0Var);
String string = a2.getString("messageType");
if (string.equalsIgnoreCase("asrResult")) {
Log.d("WebSocketClient", "Got ASR Result: " + a2.toString());
o.this.a(a2);
} else if (string.equalsIgnoreCase("ttsStart")) {
Log.d("WebSocketClient", "Got TTS Start: " + a2.toString());
} else if (string.equalsIgnoreCase("translationResult")) {
Log.d("WebSocketClient", "Got Translation result: " + a2.getString("text"));
o.this.e(a2);
} else if (string.equalsIgnoreCase("ttsEnd")) {
Log.d("WebSocketClient", "Got TTS End: " + a2.toString());
o.this.f(a2);
TranslationMessage a3 = a(a2);
boolean b2 = b(a2);
byte[] c2 = o.this.c(a2);
if (a3 != null && a3.m() != null && c2 != null) {
if (c2.length != 0 && c2.length <= 31457280) {
if (b2) {
a3.a(c2);
Log.d("WebSocketClient", "### input audio length: " + a3.d().length);
} else {
a3.b(c2);
Log.d("WebSocketClient", "### output audio length: " + a3.q().length);
}
a3.m().a(b2, a3);
}
Log.d("WebSocketClient", "Audio file size invalid for caching (0 or over 30 Mb) - will not store");
}
o.this.d(a2);
} else if (string.equalsIgnoreCase("audioData")) {
byte[] bArr2 = (byte[]) a2.get("data");
Log.d("WebSocketClient", "Got TTS Data Block: " + bArr2.length);
o.this.b(bArr2, a2.getString("messageId"));
} else if (string.equalsIgnoreCase("eventsResults")) {
o.this.a(a2.getJSONArray("events"));
} else if (string.equalsIgnoreCase("feedbackRequest")) {
Log.d("WebSocketClient", "Got Feedback Request: " + a2.toString());
o.this.b(a2);
}
String optString = a2.optString("txRefId");
if ((optString != null && optString.length() != 0) || string.equalsIgnoreCase("audioData") || string.equalsIgnoreCase("ttsStart") || string.equalsIgnoreCase("ttsEnd") || string.equalsIgnoreCase("error") || string.equalsIgnoreCase("eventsResults") || string.equalsIgnoreCase("beginTransaction")) {
return;
}
Log.e("WebSocketClient", String.format("Transaction missing txRefID (%s)", string));
HashMap hashMap = new HashMap();
hashMap.put("messageType", string);
c.e.a.i.a.a("APIWebSocketServiceClient.MissingTxRefId", hashMap);
} catch (Exception e2) {
Log.e("WebSocketClient", "Exception processing websocket message", e2);
}
}
@Override // c.d.a.a.s0
public void a(k0 k0Var, q0 q0Var, q0 q0Var2, boolean z) throws Exception {
Log.d("WebSocketClient", "Session closed. By server=" + z);
Log.e("WebSocketClient", q0Var.b());
}
@Override // c.d.a.a.s0
public void a(k0 k0Var, n0 n0Var) throws Exception {
Log.e("WebSocketClient", "Got an error on the connection: " + n0Var, n0Var);
}
}
/* compiled from: WebSocketClient.java */
/* loaded from: classes.dex */
public enum b {
Part,
EOM
}
/* compiled from: WebSocketClient.java */
/* loaded from: classes.dex */
public interface c {
b.InterfaceC0106b a();
void a(JSONObject jSONObject);
void a(byte[] bArr);
void b(JSONObject jSONObject);
byte[] b();
void c();
void c(JSONObject jSONObject);
void d(JSONObject jSONObject);
}
private o() {
String str = "------" + UUID.randomUUID().toString().replaceAll("-", JsonProperty.USE_DEFAULT_NAME);
this.f4295b = str + "\r\n";
this.f4296c = str + "--\r\n";
}
/* JADX INFO: Access modifiers changed from: private */
public void e(JSONObject jSONObject) throws JSONException {
c b2 = b(jSONObject.getString("messageId"));
if (b2 != null) {
b2.c(jSONObject);
}
}
/* JADX INFO: Access modifiers changed from: private */
public void f(JSONObject jSONObject) throws JSONException {
c b2 = b(jSONObject.getString("messageId"));
if (b2 != null) {
b2.b(jSONObject);
}
}
/* JADX INFO: Access modifiers changed from: private */
public void b(JSONObject jSONObject) {
if (a() != null) {
a().a(jSONObject);
}
}
private void c() {
k0 k0Var = this.f4294a;
if (k0Var == null || !k0Var.n()) {
try {
this.f4294a = new p0().a("wss://robosock.sayhitranslate.com/v1/streaming");
this.f4294a.a(new a());
this.f4294a.a();
} catch (c.d.a.a.n e2) {
Log.e("WebSocketClient", e2.toString(), e2);
} catch (u e3) {
Log.e("WebSocketClient", e3.toString(), e3);
} catch (n0 e4) {
Log.e("WebSocketClient", e4.toString(), e4);
} catch (Exception e5) {
this.f4294a = null;
Log.e("WebSocketClient", "Exception creating websocket connection", e5);
throw new RuntimeException("Error creating websocket connection", e5);
}
}
}
public static synchronized o d() {
o oVar;
synchronized (o.class) {
if (j == null) {
j = new o();
}
oVar = j;
}
return oVar;
}
/* JADX INFO: Access modifiers changed from: private */
public void b(byte[] bArr, String str) {
c b2 = b(str);
if (b2 != null) {
b2.a(bArr);
}
}
/* JADX INFO: Access modifiers changed from: private */
public void d(JSONObject jSONObject) throws JSONException {
c b2 = b(jSONObject.getString("messageId"));
if (b2 != null) {
b2.c();
}
}
public c a() {
return this.i;
}
/* JADX INFO: Access modifiers changed from: private */
public c b(String str) {
c cVar = this.f4297d.get(str);
if (cVar == null) {
Log.e("WebSocketClient", "Error retrieving callback for message id: " + str);
}
return cVar;
}
public void a(c cVar) {
this.i = cVar;
}
/* JADX INFO: Access modifiers changed from: private */
public void a(JSONObject jSONObject) throws JSONException {
c b2 = b(jSONObject.getString("messageId"));
if (b2 != null) {
b2.d(jSONObject);
}
}
public static Map<String, Object> b() {
HashMap hashMap = new HashMap();
hashMap.put("clientName", d.f4272c);
hashMap.put("clientOS", d.f4273d);
hashMap.put("audioSource", "mic");
if (com.sayhi.android.utils.k.b(d.f4271b)) {
hashMap.put("deviceId", d.f4271b);
hashMap.put("userId", d.f4271b);
}
if (com.sayhi.android.utils.k.b(d.f4270a)) {
hashMap.put("clientReportedIPAddress", d.f4270a);
}
if (com.sayhi.android.utils.k.b(com.sayhi.android.sayhitranslate.c.r())) {
hashMap.put("userSelectedNativeLanguage", com.sayhi.android.sayhitranslate.c.r());
}
String language = Locale.getDefault().getLanguage();
if (com.sayhi.android.utils.k.b(language)) {
hashMap.put("deviceLanguage", language);
}
try {
String iSO3Language = Locale.getDefault().getISO3Language();
if (com.sayhi.android.utils.k.b(iSO3Language)) {
hashMap.put("deviceISO3Language", iSO3Language);
}
} catch (Exception unused) {
Log.i("WebSocketClient", "Can not determine device ISO 3 language code");
}
try {
String iSO3Country = Locale.getDefault().getISO3Country();
if (com.sayhi.android.utils.k.b(iSO3Country)) {
hashMap.put("deviceISO3Country", iSO3Country);
}
} catch (Exception unused2) {
Log.i("WebSocketClient", "Can not determine device ISO 3 country code");
}
String displayLanguage = Locale.getDefault().getDisplayLanguage();
if (com.sayhi.android.utils.k.b(displayLanguage)) {
hashMap.put("deviceLanguageDisplay", displayLanguage);
}
if (Build.VERSION.SDK_INT >= 21) {
String languageTag = Locale.getDefault().toLanguageTag();
if (com.sayhi.android.utils.k.b(languageTag)) {
hashMap.put("deviceLanguageTag", languageTag);
}
}
HashMap hashMap2 = new HashMap();
hashMap2.put("optedOutOfHumanAnnotation", Boolean.valueOf(!com.sayhi.android.sayhitranslate.c.M()));
hashMap2.put("termsAndConditionsAccepted", Boolean.valueOf(com.sayhi.android.sayhitranslate.c.I()));
hashMap.put("privacy", hashMap2);
return hashMap;
}
/* JADX INFO: Access modifiers changed from: private */
public void a(JSONArray jSONArray) {
for (int i = 0; i < jSONArray.length(); i++) {
try {
JSONObject jSONObject = jSONArray.getJSONObject(i);
String string = jSONObject.getString("name");
HashMap hashMap = new HashMap();
if (jSONObject.has("properties")) {
JSONObject jSONObject2 = jSONObject.getJSONObject("properties");
Iterator<String> keys = jSONObject2.keys();
while (keys.hasNext()) {
String next = keys.next();
hashMap.put(next, jSONObject2.getString(next));
}
}
c.e.a.i.a.a(string, hashMap);
} catch (JSONException e2) {
Log.e("WebSocketClient", "Failed to process event at position " + i, e2);
}
}
}
/* JADX INFO: Access modifiers changed from: private */
public byte[] c(JSONObject jSONObject) throws JSONException {
c b2 = b(jSONObject.getString("messageId"));
if (b2 != null) {
return b2.b();
}
return null;
}
public String a(c.e.a.j.r.a aVar, c cVar) throws Exception {
this.f4299f.put(cVar, aVar);
this.h.put(cVar, false);
HashMap hashMap = new HashMap();
hashMap.put("inputLanguage", aVar.b());
hashMap.put("outputLanguage", aVar.d());
c.e.a.i.a.a("Service.translateText", hashMap);
JSONObject jSONObject = new JSONObject();
jSONObject.put("commandType", "translation");
jSONObject.put("inputTypeFormat", "text");
if (aVar.e() == k.VOICE) {
jSONObject.put("outputTypeFormat", "voice");
} else {
jSONObject.put("outputTypeFormat", "text");
}
JSONObject jSONObject2 = new JSONObject();
jSONObject2.put("language", aVar.b());
jSONObject2.put("text", aVar.c());
jSONObject.put("inputTypeData", jSONObject2);
JSONObject jSONObject3 = new JSONObject();
jSONObject3.put("language", aVar.d());
jSONObject3.put("codec", "mp3");
jSONObject3.put("sampleRate", 48000);
boolean c2 = com.sayhi.android.sayhitranslate.c.c(aVar.d());
if (c2) {
jSONObject3.put("gender", "female");
} else {
jSONObject3.put("gender", "male");
}
if (aVar.f() != null) {
aVar.f().c(c2);
}
float a2 = com.sayhi.android.sayhitranslate.c.a(aVar.d(), c2);
if (a2 > 0.0f) {
double d2 = a2;
jSONObject3.put("playbackRate", d2);
if (aVar.f() != null) {
aVar.f().b(d2);
}
}
jSONObject.put("outputTypeData", jSONObject3);
JSONObject jSONObject4 = new JSONObject(a("text"));
if (com.sayhi.android.utils.k.b(aVar.g())) {
jSONObject4.put("updatedFromTransactionRefId", aVar.g());
}
jSONObject.put("metaData", jSONObject4);
return a(jSONObject, cVar);
}
private JSONObject b(String str, InputStream inputStream) throws IOException, JSONException {
StringBuffer stringBuffer = new StringBuffer();
while (true) {
String b2 = b(inputStream);
if (b2.equalsIgnoreCase(str + "--")) {
Log.d("WebSocketClient", "End of section");
return new JSONObject(stringBuffer.toString());
}
stringBuffer.append(b2);
}
}
private String b(InputStream inputStream) throws IOException {
ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
boolean z = true;
byte[] bArr = new byte[1];
boolean z2 = false;
while (true) {
if (inputStream.read(bArr) == -1) {
z = false;
break;
}
if (bArr[0] == 13) {
z2 = true;
} else if (bArr[0] != 10) {
if (z2) {
byteArrayOutputStream.write(13);
}
z2 = false;
} else if (z2) {
break;
}
if (!z2) {
byteArrayOutputStream.write(bArr[0]);
}
}
byte[] byteArray = byteArrayOutputStream.toByteArray();
return (byteArray.length == 0 && z2 && z) ? "\r\n" : new String(byteArray);
}
private void a(c.e.a.j.s.a aVar, TranslationMessage translationMessage, c cVar) {
String b2 = aVar.b();
c.e.a.j.s.c cVar2 = new c.e.a.j.s.c();
cVar2.b(b2);
cVar2.b(aVar.f4341g ? translationMessage.d() : translationMessage.q());
Log.d("WebSocketClient", "### Audio playing from cache");
cVar.a().a(cVar2, 200);
}
public String a(c.e.a.j.s.a aVar, c cVar) throws Exception {
this.f4298e.put(cVar, aVar);
this.h.put(cVar, Boolean.valueOf(aVar.f4341g));
HashMap hashMap = new HashMap();
hashMap.put("language", aVar.b());
TranslationMessage d2 = aVar.d();
boolean z = aVar.f4341g;
if (z) {
c.e.a.i.a.a("APIWebSocketServiceClient Input Audio Requested", hashMap);
} else {
c.e.a.i.a.a("APIWebSocketServiceClient Output Audio Requested", hashMap);
}
if (d2 != null && d2.m() != null && d2.m().f().contains(new com.sayhi.android.dataobjects.b(z, d2))) {
byte[] d3 = z ? d2.d() : d2.q();
double i = z ? d2.i() : d2.k();
boolean h = z ? d2.h() : d2.j();
if (d3 != null && d3.length > 0 && i == aVar.c() && h == aVar.f()) {
a(aVar, d2, cVar);
d2.m().a(new com.sayhi.android.dataobjects.b(z, d2));
c.e.a.i.a.a("APIWebSocketServiceClient.Cache Hit", hashMap);
return UUID.randomUUID().toString();
}
if (h != aVar.f()) {
if (z) {
d2.b(aVar.f());
} else {
d2.c(aVar.f());
}
}
if (i != aVar.c()) {
if (z) {
d2.a(aVar.c());
} else {
d2.b(aVar.c());
}
}
if (d3 != null && d3.length > 0) {
d2.m().b(new com.sayhi.android.dataobjects.b(z, d2));
}
}
c.e.a.i.a.a("APIWebSocketServiceClient.Cache Missed", hashMap);
c.e.a.i.a.a("Service.playTTS", hashMap);
JSONObject jSONObject = new JSONObject();
jSONObject.put("commandType", "tts");
jSONObject.put("inputTypeFormat", "text");
jSONObject.put("outputTypeFormat", "voice");
JSONObject jSONObject2 = new JSONObject();
jSONObject2.put("text", aVar.e());
jSONObject2.put("ttsTimestamp", String.valueOf(System.currentTimeMillis()));
jSONObject.put("inputTypeData", jSONObject2);
JSONObject jSONObject3 = new JSONObject();
jSONObject3.put("language", aVar.b());
jSONObject3.put("codec", "mp3");
jSONObject3.put("sampleRate", 48000);
if (aVar.c() > 0.0d) {
jSONObject3.put("playbackRate", aVar.c());
}
jSONObject.put("outputTypeData", jSONObject3);
if (aVar.f()) {
jSONObject3.put("gender", "female");
} else {
jSONObject3.put("gender", "male");
}
if (d2 != null && aVar.f4341g) {
d2.b(aVar.f());
d2.a(aVar.c());
} else if (d2 != null) {
d2.c(aVar.f());
d2.b(aVar.c());
}
jSONObject.put("metaData", new JSONObject(b()));
return a(jSONObject, cVar);
}
/* JADX WARN: Removed duplicated region for block: B:18:0x00d8 */
/*
Code decompiled incorrectly, please refer to instructions dump.
To view partially-correct add '--show-bad-code' argument
*/
public java.lang.String a(c.e.a.j.p.a r18, c.e.a.j.o.c r19) throws java.lang.Exception {
/*
Method dump skipped, instructions count: 313
To view this dump add '--comments-level debug' option
*/
throw new UnsupportedOperationException("Method not decompiled: c.e.a.j.o.a(c.e.a.j.p.a, c.e.a.j.o$c):java.lang.String");
}
public static Map<String, Object> a(String str) {
Map<String, Object> b2 = b();
if (com.sayhi.android.utils.k.b(str)) {
b2.put("inputMethod", str);
}
return b2;
}
private synchronized String a(JSONObject jSONObject, c cVar) throws Exception {
String uuid;
uuid = UUID.randomUUID().toString();
this.f4297d.put(uuid, cVar);
c();
a(uuid, "beginCommand", "json");
StringBuffer stringBuffer = new StringBuffer();
stringBuffer.append(this.f4295b);
stringBuffer.append(jSONObject.toString() + "\r\n");
stringBuffer.append(this.f4296c);
this.f4294a.b(ByteBuffer.wrap(stringBuffer.toString().getBytes()).array(), false);
this.f4294a.b(ByteBuffer.wrap("====END\r\n".getBytes()).array(), true);
return uuid;
}
public void a(byte[] bArr, String str) throws IOException, JSONException {
c();
try {
c.e.a.c.e.a(bArr, c.e.a.c.d.Java);
} catch (c.e.a.c.c e2) {
Log.e("WebSocketClient", "Compression Exception.", e2);
c.e.a.c.d dVar = c.e.a.c.d.None;
}
a(str, "audioData", "binary", bArr.length, c.e.a.c.d.None);
StringBuffer stringBuffer = new StringBuffer();
stringBuffer.append(this.f4295b);
this.f4294a.b(stringBuffer.toString().getBytes(), false);
this.f4294a.b(ByteBuffer.wrap(bArr, 0, bArr.length).array(), false);
StringBuffer stringBuffer2 = new StringBuffer();
stringBuffer2.append(this.f4296c);
stringBuffer2.append("====END\r\n");
this.f4294a.b(stringBuffer2.toString().getBytes(), true);
Log.d("WebSocketClient", "Send Audio Packet: " + bArr.length);
}
public void a(String str, boolean z) throws IOException, JSONException {
if (z) {
c b2 = b(str);
JSONObject jSONObject = new JSONObject();
jSONObject.put(SubmitFeedbackRequest.OK_VALUE, false);
jSONObject.put("responseCode", 1623);
if (b2 != null) {
b2.d(jSONObject);
this.f4297d.remove(str);
}
}
c();
a(str, "endAudioData", "json");
StringBuffer stringBuffer = new StringBuffer();
stringBuffer.append(this.f4295b);
JSONObject jSONObject2 = new JSONObject();
jSONObject2.put("messageType", "endAudioData");
jSONObject2.put("clientReqInvalid", z);
stringBuffer.append(jSONObject2.toString() + "\r\n");
stringBuffer.append(this.f4296c);
this.f4294a.b(stringBuffer.toString().getBytes(), false);
this.f4294a.b("====END\r\n".getBytes(), true);
}
private void a(String str, String str2, String str3) throws IOException, JSONException {
a(str, str2, str3, -1, c.e.a.c.d.None);
}
private void a(String str, String str2, String str3, int i, c.e.a.c.d dVar) throws IOException, JSONException {
this.f4294a.a(ByteBuffer.wrap("====START\r\n".getBytes()).array(), false);
k0 k0Var = this.f4294a;
k0Var.b(ByteBuffer.wrap(("messageId: " + str + "\r\n").getBytes()).array(), false);
k0 k0Var2 = this.f4294a;
k0Var2.b(ByteBuffer.wrap(("messageType: " + str2 + "\r\n").getBytes()).array(), false);
k0 k0Var3 = this.f4294a;
k0Var3.b(ByteBuffer.wrap(("messagePayloadFormat: " + str3 + "\r\n").getBytes()).array(), false);
if (str3.equalsIgnoreCase("binary") && i >= 0) {
k0 k0Var4 = this.f4294a;
k0Var4.b(ByteBuffer.wrap(("dataSize: " + i + "\r\n").getBytes()).array(), false);
}
k0 k0Var5 = this.f4294a;
k0Var5.b(ByteBuffer.wrap(("serviceKey: " + com.sayhi.android.sayhitranslate.d.a() + "\r\n").getBytes()).array(), false);
k0 k0Var6 = this.f4294a;
k0Var6.b(ByteBuffer.wrap(("compressionType: " + dVar.toString() + "\r\n").getBytes()).array(), false);
k0 k0Var7 = this.f4294a;
k0Var7.b(ByteBuffer.wrap(("boundary: " + this.f4295b).getBytes()).array(), false);
this.f4294a.b(ByteBuffer.wrap("\r\n".getBytes()).array(), false);
}
public JSONObject a(InputStream inputStream, k0 k0Var) throws JSONException {
Log.d("WebSocketClient", "Received binary from client: " + k0Var);
JSONObject jSONObject = new JSONObject();
boolean z = false;
int i = 0;
while (!z) {
try {
String b2 = b(inputStream);
if (com.sayhi.android.utils.k.b(b2)) {
if (b2.startsWith("====START")) {
z = true;
}
} else if (i > 10) {
throw new IOException();
} else {
i++;
}
} catch (Exception e2) {
e = e2;
Log.e("WebSocketClient", "Error in processMessage", e);
k0Var.a(1011, "Unexpected error");
return jSONObject;
}
}
if (z) {
HashMap<String, String> a2 = a(inputStream);
String str = a2.get("boundary");
if (!com.sayhi.android.utils.k.a(str)) {
String str2 = a2.get("messageId");
if (!com.sayhi.android.utils.k.a(str2)) {
if (!com.sayhi.android.utils.k.a(a2.get("messageType"))) {
String str3 = a2.get("messagePayloadFormat");
if (!com.sayhi.android.utils.k.a(str3)) {
while (a(str, inputStream) != b.EOM) {
Log.d("WebSocketClient", "Found new part");
if (str3.equalsIgnoreCase("binary")) {
int parseInt = Integer.parseInt(a2.get("dataSize"));
Log.d("WebSocketClient", "Got a binary part, command=" + str2 + " ,size=" + parseInt);
if (parseInt > 0) {
byte[] a3 = a(parseInt, str, inputStream);
Log.d("WebSocketClient", "Got binary data: " + a3.length);
JSONObject jSONObject2 = new JSONObject();
try {
jSONObject2.put("messageType", "audioData");
jSONObject2.put("data", a3);
jSONObject = jSONObject2;
} catch (Exception e3) {
e = e3;
jSONObject = jSONObject2;
Log.e("WebSocketClient", "Error in processMessage", e);
k0Var.a(1011, "Unexpected error");
return jSONObject;
}
} else {
continue;
}
} else {
Log.d("WebSocketClient", "Got a message part: " + str2);
jSONObject = b(str, inputStream);
Log.d("WebSocketClient", "Got a command: " + jSONObject.toString());
}
}
Log.d("WebSocketClient", "Hit EOM");
jSONObject.put("messageId", str2);
return jSONObject;
}
throw new RuntimeException("Missing messagePayloadFormat header");
}
throw new RuntimeException("Missing messageType header");
}
throw new RuntimeException("Missing messageId header");
}
throw new RuntimeException("Missing boundary header");
}
throw new RuntimeException("Missing start marker");
}
private b a(String str, InputStream inputStream) throws IOException {
b bVar = b.Part;
boolean z = false;
int i = 0;
while (!z) {
if (i <= 10) {
String b2 = b(inputStream);
if (b2 != null) {
if (!b2.equalsIgnoreCase(str)) {
if (b2.equalsIgnoreCase("====END")) {
bVar = b.EOM;
}
}
z = true;
}
i++;
} else {
throw new IOException("Could not find boundary or EOM in message stream");
}
}
return bVar;
}
private HashMap<String, String> a(InputStream inputStream) throws IOException {
Pattern compile = Pattern.compile("(.*?):(.*)");
HashMap<String, String> hashMap = new HashMap<>();
String b2 = b(inputStream);
while (true) {
if (!com.sayhi.android.utils.k.b(b2)) {
break;
}
Log.d("WebSocketClient", "Looking for header on line: " + b2);
Matcher matcher = compile.matcher(b2);
if (matcher.find() && matcher.groupCount() == 2) {
hashMap.put(matcher.group(1), matcher.group(2).trim());
}
b2 = b(inputStream);
if (b2.equalsIgnoreCase("\r\n")) {
Log.d("WebSocketClient", "End of headers");
break;
}
}
return hashMap;
}
/* JADX WARN: Code restructure failed: missing block: B:8:0x0013, code lost:
r0.write(r1, 0, r5);
*/
/*
Code decompiled incorrectly, please refer to instructions dump.
To view partially-correct add '--show-bad-code' argument
*/
private byte[] a(int r7, java.lang.String r8, java.io.InputStream r9) throws java.io.IOException {
/*
r6 = this;
java.io.ByteArrayOutputStream r0 = new java.io.ByteArrayOutputStream
r0.<init>()
byte[] r1 = new byte[r7]
r2 = 0
L8:
r3 = r2
L9:
r4 = 100
if (r3 >= r4) goto L20
int r5 = r9.read(r1)
if (r5 <= 0) goto L1d
r0.write(r1, r2, r5)
int r3 = r0.size()
if (r3 < r7) goto L8
goto L21
L1d:
int r3 = r3 + 1
goto L9
L20:
r2 = r3
L21:
if (r2 >= r4) goto L63
java.lang.String r7 = r6.b(r9)
if (r7 == 0) goto L45
java.lang.StringBuilder r9 = new java.lang.StringBuilder
r9.<init>()
r9.append(r8)
java.lang.String r8 = "--"
r9.append(r8)
java.lang.String r8 = r9.toString()
boolean r8 = r7.equalsIgnoreCase(r8)
if (r8 == 0) goto L45
byte[] r7 = r0.toByteArray()
return r7
L45:
java.lang.StringBuilder r8 = new java.lang.StringBuilder
r8.<init>()
java.lang.String r9 = "Bad? "
r8.append(r9)
r8.append(r7)
java.lang.String r7 = r8.toString()
java.lang.String r8 = "WebSocketClient"
android.util.Log.d(r8, r7)
java.io.IOException r7 = new java.io.IOException
java.lang.String r8 = "End of part boundary not found."
r7.<init>(r8)
throw r7
L63:
java.io.IOException r7 = new java.io.IOException
java.lang.String r8 = "Could not get binary data in max attempts."
r7.<init>(r8)
throw r7
*/
throw new UnsupportedOperationException("Method not decompiled: c.e.a.j.o.a(int, java.lang.String, java.io.InputStream):byte[]");
}
}
Do you know of any way of have a better result ?
Sorry @alexandredepape - this is not related to Apktool now and I fear you are missing some common knowledge around reverse engineering. You'll find in any modern published software that debug information, symbol information and properties/variables are stripped down/obfuscated/minified or even more confusing - protected.
So when you try and reverse that, I think you are expecting to see absolutely original variable names, method names, etc. You won't. Not only will you not, but tools such as the ones above have to fight and compete against an increasingly difficult level of tricks which attempt to make the reversed code very difficult to follow.
This is why tools like JEB and IDA exist - for some this is a full time job with tons of tools at hand to slowly reverse software with renames/notes into something usable.
Sure go try some other decoders and see if they offer a different insight, but at that point - you are far from Apktool.
Thanks for you insights 👍 I will look into it
When doing "apktool d Downloads/SayHi\ Translate_5.0.12_Apkpure.apk"
I get really weird code like this in the files.
Is that normal ? can you guys try with this apk ? Thanks in advance.
https://apkpure.com/sayhi-translate/com.sayhi.android.sayhitranslate