package com.yxcorp.kuaishou.addfp.c.a; import android.content.Context; import android.os.Build; import android.provider.Settings; import android.text.TextUtils; import android.util.Base64; import com.kuaishou.weapon.p0.h; import com.kuaishou.weapon.p0.i1; import com.mbridge.msdk.foundation.entity.CampaignUnit; import com.yxcorp.kuaishou.addfp.KWEGIDDFP; import com.yxcorp.kuaishou.addfp.android.a.d; import com.yxcorp.kuaishou.addfp.android.b.e; import com.yxcorp.kuaishou.addfp.android.b.g; import java.io.BufferedReader; import java.io.DataOutputStream; import java.io.IOException; import java.io.InputStreamReader; import java.util.ArrayList; import java.util.LinkedHashMap; import java.util.ListIterator; import java.util.Map; import org.json.JSONObject; public final class a { /* JADX DEBUG: Failed to insert an additional move for type inference into block B:104:0x015e */ /* JADX WARN: Multi-variable type inference failed */ /* JADX WARN: Type inference failed for: r12v4, types: [java.lang.String] */ /* JADX WARN: Type inference failed for: r12v7 */ /* JADX WARN: Type inference failed for: r12v9 */ /* JADX WARN: Type inference failed for: r12v10 */ /* JADX WARN: Type inference failed for: r12v14 */ /* JADX WARN: Type inference failed for: r12v17 */ /* JADX WARN: Type inference failed for: r12v34 */ /* JADX WARN: Type inference failed for: r12v35 */ /* JADX WARNING: Code restructure failed: missing block: B:104:0x015e, code lost: if (r1 == null) goto L_0x0169; */ /* JADX WARNING: Code restructure failed: missing block: B:105:0x0160, code lost: r11 = r0; r1 = r12; r12 = r1; */ /* JADX WARNING: Code restructure failed: missing block: B:43:0x00ca, code lost: r11 = th; */ /* JADX WARNING: Code restructure failed: missing block: B:44:0x00cd, code lost: r0 = move-exception; */ /* JADX WARNING: Code restructure failed: missing block: B:45:0x00ce, code lost: r1 = r0; r0 = null; */ /* JADX WARNING: Code restructure failed: missing block: B:47:0x00d4, code lost: r0 = move-exception; */ /* JADX WARNING: Code restructure failed: missing block: B:48:0x00d5, code lost: r1 = r0; r0 = null; */ /* JADX WARNING: Code restructure failed: missing block: B:88:0x0139, code lost: if (r1 == null) goto L_0x0169; */ /* JADX WARNING: Failed to process nested try/catch */ /* JADX WARNING: Removed duplicated region for block: B:100:0x0152 A[Catch:{ IOException -> 0x014e }] */ /* JADX WARNING: Removed duplicated region for block: B:102:0x0157 A[Catch:{ IOException -> 0x014e }] */ /* JADX WARNING: Removed duplicated region for block: B:114:0x0177 A[SYNTHETIC, Splitter:B:114:0x0177] */ /* JADX WARNING: Removed duplicated region for block: B:119:0x017f A[Catch:{ IOException -> 0x017b }] */ /* JADX WARNING: Removed duplicated region for block: B:121:0x0184 A[Catch:{ IOException -> 0x017b }] */ /* JADX WARNING: Removed duplicated region for block: B:124:0x018d */ /* JADX WARNING: Removed duplicated region for block: B:43:0x00ca A[ExcHandler: all (th java.lang.Throwable), Splitter:B:19:0x006b] */ /* JADX WARNING: Removed duplicated region for block: B:79:0x0125 A[SYNTHETIC, Splitter:B:79:0x0125] */ /* JADX WARNING: Removed duplicated region for block: B:84:0x012d A[Catch:{ IOException -> 0x0129 }] */ /* JADX WARNING: Removed duplicated region for block: B:86:0x0132 A[Catch:{ IOException -> 0x0129 }] */ /* JADX WARNING: Removed duplicated region for block: B:95:0x014a A[SYNTHETIC, Splitter:B:95:0x014a] */ public static e a(String str, boolean z) { Process process; BufferedReader bufferedReader; BufferedReader bufferedReader2; Throwable th; String str2; String str3; String str4; String str5; Process process2; IOException iOException; IOException iOException2; Exception exc; Exception exc2; DataOutputStream dataOutputStream; DataOutputStream dataOutputStream2; String[] strArr = {str}; DataOutputStream dataOutputStream3 = null; int i = -1; try { process = Runtime.getRuntime().exec(z ? i1.w : CampaignUnit.JSON_KEY_SH); try { DataOutputStream dataOutputStream4 = new DataOutputStream(process.getOutputStream()); for (int i2 = 0; i2 <= 0; i2++) { try { String str6 = strArr[0]; if (str6 != null) { dataOutputStream4.write(str6.getBytes()); dataOutputStream4.writeBytes("\n"); dataOutputStream4.flush(); } } catch (IOException e) { bufferedReader2 = null; bufferedReader = null; process2 = process; iOException = e; dataOutputStream = null; str3 = null; dataOutputStream3 = dataOutputStream4; str2 = dataOutputStream; iOException.printStackTrace(); if (dataOutputStream3 != null) { try { dataOutputStream3.close(); } catch (IOException e2) { e2.printStackTrace(); } } if (bufferedReader2 != null) { bufferedReader2.close(); } if (bufferedReader != null) { bufferedReader.close(); } } catch (Exception e3) { bufferedReader2 = null; bufferedReader = null; process2 = process; exc = e3; dataOutputStream2 = null; str3 = null; dataOutputStream3 = dataOutputStream4; str2 = dataOutputStream2; try { exc.printStackTrace(); if (dataOutputStream3 != null) { try { dataOutputStream3.close(); } catch (IOException e4) { e4.printStackTrace(); } } if (bufferedReader2 != null) { bufferedReader2.close(); } if (bufferedReader != null) { bufferedReader.close(); } } catch (Throwable th2) { dataOutputStream4 = dataOutputStream3; Throwable th3 = th2; process = process2; th = th3; dataOutputStream3 = dataOutputStream4; if (dataOutputStream3 != null) { } if (bufferedReader2 != null) { } if (bufferedReader != null) { } if (process != null) { } throw th; } } catch (Throwable th4) { th = th4; bufferedReader2 = null; bufferedReader = null; dataOutputStream3 = dataOutputStream4; if (dataOutputStream3 != null) { try { dataOutputStream3.close(); } catch (IOException e5) { e5.printStackTrace(); if (process != null) { process.destroy(); } throw th; } } if (bufferedReader2 != null) { bufferedReader2.close(); } if (bufferedReader != null) { bufferedReader.close(); } if (process != null) { } throw th; } } dataOutputStream4.writeBytes("exit\n"); dataOutputStream4.flush(); i = process.waitFor(); StringBuilder sb = new StringBuilder(); StringBuilder sb2 = new StringBuilder(); bufferedReader2 = new BufferedReader(new InputStreamReader(process.getInputStream())); try { bufferedReader = new BufferedReader(new InputStreamReader(process.getErrorStream())); while (true) { try { String readLine = bufferedReader2.readLine(); if (readLine == null) { break; } sb.append(readLine); sb.append("|"); } catch (IOException e6) { str3 = null; dataOutputStream3 = str5; IOException iOException3 = e6; iOException = iOException3; process2 = process; dataOutputStream = dataOutputStream3; dataOutputStream3 = dataOutputStream4; str2 = dataOutputStream; iOException.printStackTrace(); if (dataOutputStream3 != null) { } if (bufferedReader2 != null) { } if (bufferedReader != null) { } } catch (Exception e7) { str3 = null; dataOutputStream3 = str5; Exception exc3 = e7; exc = exc3; process2 = process; dataOutputStream2 = dataOutputStream3; dataOutputStream3 = dataOutputStream4; str2 = dataOutputStream2; exc.printStackTrace(); if (dataOutputStream3 != null) { } if (bufferedReader2 != null) { } if (bufferedReader != null) { } } catch (Throwable th5) { } } str5 = sb.toString(); if (str5.length() > 0) { str5 = str5.substring(0, str5.length() - 1); } while (true) { String readLine2 = bufferedReader.readLine(); if (readLine2 == null) { break; } sb2.append(readLine2); sb2.append("|"); } str4 = sb2.toString(); if (str4.length() > 0) { str4 = str4.substring(0, str4.length() - 1); } try { dataOutputStream4.close(); bufferedReader2.close(); bufferedReader.close(); } catch (IOException e8) { e8.printStackTrace(); } } catch (IOException e9) { str3 = null; bufferedReader = null; iOException = e9; process2 = process; dataOutputStream3 = dataOutputStream4; str2 = bufferedReader; iOException.printStackTrace(); if (dataOutputStream3 != null) { } if (bufferedReader2 != null) { } if (bufferedReader != null) { } } catch (Exception e10) { str3 = null; bufferedReader = null; exc = e10; process2 = process; dataOutputStream3 = dataOutputStream4; str2 = bufferedReader; exc.printStackTrace(); if (dataOutputStream3 != null) { } if (bufferedReader2 != null) { } if (bufferedReader != null) { } } catch (Throwable th6) { th = th6; bufferedReader = null; dataOutputStream3 = dataOutputStream4; if (dataOutputStream3 != null) { } if (bufferedReader2 != null) { } if (bufferedReader != null) { } if (process != null) { } throw th; } } catch (IOException e11) { iOException2 = e11; str3 = null; bufferedReader2 = null; bufferedReader = null; iOException = iOException2; process2 = process; str2 = bufferedReader; iOException.printStackTrace(); if (dataOutputStream3 != null) { } if (bufferedReader2 != null) { } if (bufferedReader != null) { } } catch (Exception e12) { exc2 = e12; str3 = null; bufferedReader2 = null; bufferedReader = null; exc = exc2; process2 = process; str2 = bufferedReader; exc.printStackTrace(); if (dataOutputStream3 != null) { } if (bufferedReader2 != null) { } if (bufferedReader != null) { } } catch (Throwable th7) { th = th7; bufferedReader2 = null; bufferedReader = null; if (dataOutputStream3 != null) { } if (bufferedReader2 != null) { } if (bufferedReader != null) { } if (process != null) { } throw th; } } catch (IOException e13) { iOException2 = e13; process = null; str3 = null; bufferedReader2 = null; bufferedReader = null; iOException = iOException2; process2 = process; str2 = bufferedReader; iOException.printStackTrace(); if (dataOutputStream3 != null) { } if (bufferedReader2 != null) { } if (bufferedReader != null) { } } catch (Exception e14) { exc2 = e14; process = null; str3 = null; bufferedReader2 = null; bufferedReader = null; exc = exc2; process2 = process; str2 = bufferedReader; exc.printStackTrace(); if (dataOutputStream3 != null) { } if (bufferedReader2 != null) { } if (bufferedReader != null) { } } catch (Throwable th8) { th = th8; process = null; bufferedReader2 = null; bufferedReader = null; if (dataOutputStream3 != null) { } if (bufferedReader2 != null) { } if (bufferedReader != null) { } if (process != null) { } throw th; } process.destroy(); str3 = str4; str2 = str5; return new e(i, str2, str3); } /* JADX WARNING: Removed duplicated region for block: B:13:0x0037 */ /* JADX WARNING: Removed duplicated region for block: B:39:0x008e A[RETURN, SYNTHETIC] */ /* JADX WARNING: Removed duplicated region for block: B:40:0x0092 */ /* JADX WARNING: Removed duplicated region for block: B:59:0x00d3 */ public static String a() { boolean z; boolean z2; boolean z3; String str = Build.MANUFACTURER; boolean z4 = false; if (!str.equalsIgnoreCase("XIAOMI")) { String str2 = Build.BRAND; if (!str2.equalsIgnoreCase("XIAOMI") && !str2.equalsIgnoreCase("REDMI") && !str2.equalsIgnoreCase("MEITU") && TextUtils.isEmpty(a("ro.miui.ui.version.name", ""))) { z = false; if (!z) { if (!(str.equalsIgnoreCase("BLACKSHARK") || Build.BRAND.equalsIgnoreCase("BLACKSHARK"))) { if (str.equalsIgnoreCase("SAMSUNG") || Build.BRAND.equalsIgnoreCase("SAMSUNG")) { return "3"; } if (!str.equalsIgnoreCase("VIVO")) { String str3 = Build.BRAND; if (!str3.equalsIgnoreCase("VIVO") && !str3.equalsIgnoreCase("IQOO") && TextUtils.isEmpty(a("ro.vivo.os.version", ""))) { z2 = false; if (!z2) { return "2"; } if (str.equalsIgnoreCase("HUAWEI") || Build.BRAND.equalsIgnoreCase("HUAWEI")) { return "1"; } if (!str.equalsIgnoreCase("OPPO")) { String str4 = Build.BRAND; if (!str4.equalsIgnoreCase("OPPO") && !str4.equalsIgnoreCase("REALME") && TextUtils.isEmpty(a("ro.build.version.opporom", ""))) { z3 = false; if (!z3) { if (str.equalsIgnoreCase("ONEPLUS") || Build.BRAND.equalsIgnoreCase("ONEPLUS")) { z4 = true; } if (!z4) { return Build.BRAND.equalsIgnoreCase("HONOR") ? "7" : "0"; } } return "5"; } } z3 = true; if (!z3) { } return "5"; } } z2 = true; if (!z2) { } } } return "4"; } } z = true; if (!z) { } return "4"; } public static String a(int i, String str) { String str2; Context paramContext = KWEGIDDFP.instance().getParamContext(); if (paramContext == null) { return ""; } String[] split = new String(Base64.decode("U3lzdGVtQFNlY3VyZUBHbG9iYWw=", 0)).split("@"); String str3 = split[0]; String str4 = split[1]; String str5 = split[2]; if (i == 0) { str2 = com.yxcorp.kuaishou.addfp.android.b.a.a(paramContext, split[0], str); if (TextUtils.isEmpty(str2)) { str2 = Settings.System.getString(paramContext.getContentResolver(), str); } } else if (i == 1) { str2 = com.yxcorp.kuaishou.addfp.android.b.a.a(paramContext, split[1], str); if (TextUtils.isEmpty(str2)) { str2 = Settings.Secure.getString(paramContext.getContentResolver(), str); } } else if (i == 2) { str2 = com.yxcorp.kuaishou.addfp.android.b.a.a(paramContext, split[2], str); if (TextUtils.isEmpty(str2)) { str2 = Settings.Global.getString(paramContext.getContentResolver(), str); } } else { str2 = ""; } return str2 == null ? "" : str2; } /* JADX WARNING: Removed duplicated region for block: B:40:0x00ab A[Catch:{ all -> 0x0099 }] */ /* JADX WARNING: Removed duplicated region for block: B:44:0x00c1 */ public static String a(Context context) { String str; LinkedHashMap b; int i; ListIterator listIterator; JSONObject jSONObject; Map.Entry entry; try { String a = a(context, "k_w_o_d_out_dtt"); String str2 = ""; if (TextUtils.isEmpty(a)) { if (g.a(context, new String[]{h.i, h.j})) { str2 = d.a(context).a("Lm91a2R0ZnQ="); if (!TextUtils.isEmpty(str2)) { try { Settings.System.putString(context.getContentResolver(), "k_w_o_d_out_dtt", str2); } catch (Throwable unused) { } } } else { str = "KWE_PN"; if (!TextUtils.isEmpty(a) && TextUtils.isEmpty(str2)) { return "KWE_N"; } b = d.a(context).b(a); if (b == null || b.size() == 0) { b = d.a(context).b(str2); } if (b != null && b.size() > 0) { i = 0; listIterator = new ArrayList(b.entrySet()).listIterator(b.size()); jSONObject = new JSONObject(); while (listIterator.hasPrevious() && i < 10) { try { entry = (Map.Entry) listIterator.previous(); if (entry != null) { jSONObject.put((String) entry.getKey(), entry.getValue()); } i++; } catch (Throwable unused2) { } } if (jSONObject.length() > 0) { return jSONObject.toString(); } } return str; } } else if (g.a(context, new String[]{h.i, h.j})) { str2 = d.a(context).a("Lm91a2R0ZnQ="); if (TextUtils.isEmpty(str2)) { d.a(context, a); } } str = "KWE_N"; if (!TextUtils.isEmpty(a)) { } b = d.a(context).b(a); b = d.a(context).b(str2); i = 0; listIterator = new ArrayList(b.entrySet()).listIterator(b.size()); jSONObject = new JSONObject(); while (listIterator.hasPrevious()) { entry = (Map.Entry) listIterator.previous(); if (entry != null) { } i++; } if (jSONObject.length() > 0) { } return str; } catch (Throwable th) { th.printStackTrace(); return "KWE_PE"; } } public static String a(Context context, String str) { try { return Settings.System.getString(context.getContentResolver(), str); } catch (Throwable th) { th.printStackTrace(); return ""; } } public static String a(String str, String str2) { String str3; try { Class<?> cls = Class.forName("android.os.SystemProperties"); str3 = (String) cls.getMethod("get", String.class, String.class).invoke(cls, str, str2); } catch (Exception unused) { str3 = null; } return str3 == null ? "" : str3; } }