package com.kuaishou.weapon.p0; import com.mbridge.msdk.foundation.entity.CampaignUnit; import java.io.BufferedInputStream; import java.io.BufferedOutputStream; import java.io.IOException; public class b0 { public static volatile b0 a; public static synchronized b0 a() { b0 b0Var; synchronized (b0.class) { if (a == null) { synchronized (b0.class) { if (a == null) { a = new b0(); } } } b0Var = a; } return b0Var; } public static String a(BufferedInputStream bufferedInputStream) { int read; if (bufferedInputStream == null) { return ""; } byte[] bArr = new byte[512]; StringBuilder sb = new StringBuilder(); do { try { read = bufferedInputStream.read(bArr); if (read > 0) { sb.append(new String(bArr, 0, read)); continue; } } catch (Exception unused) { } } while (read >= 512); return sb.toString(); } /* JADX WARNING: Failed to process nested try/catch */ /* JADX WARNING: Missing exception handler attribute for start block: B:11:0x0039 */ /* JADX WARNING: Removed duplicated region for block: B:15:0x0040 */ /* JADX WARNING: Removed duplicated region for block: B:29:0x0055 A[SYNTHETIC, Splitter:B:29:0x0055] */ /* JADX WARNING: Removed duplicated region for block: B:33:0x005c A[SYNTHETIC, Splitter:B:33:0x005c] */ /* JADX WARNING: Removed duplicated region for block: B:37:0x0063 */ /* JADX WARNING: Removed duplicated region for block: B:44:0x006c A[SYNTHETIC, Splitter:B:44:0x006c] */ /* JADX WARNING: Removed duplicated region for block: B:48:0x0073 A[SYNTHETIC, Splitter:B:48:0x0073] */ /* JADX WARNING: Removed duplicated region for block: B:52:0x007a */ public String a(String str) { BufferedInputStream bufferedInputStream; BufferedOutputStream bufferedOutputStream; Process process; Throwable th; BufferedOutputStream bufferedOutputStream2 = null; try { process = Runtime.getRuntime().exec(CampaignUnit.JSON_KEY_SH); try { bufferedOutputStream = new BufferedOutputStream(process.getOutputStream()); } catch (Exception unused) { bufferedOutputStream = null; bufferedInputStream = null; if (bufferedOutputStream != null) { try { bufferedOutputStream.close(); } catch (IOException unused2) { } } if (bufferedInputStream != null) { try { bufferedInputStream.close(); } catch (IOException unused3) { } } if (process != null) { process.destroy(); } return null; } catch (Throwable th2) { th = th2; bufferedInputStream = null; if (bufferedOutputStream2 != null) { try { bufferedOutputStream2.close(); } catch (IOException unused4) { } } if (bufferedInputStream != null) { try { bufferedInputStream.close(); } catch (IOException unused5) { } } if (process != null) { process.destroy(); } throw th; } try { bufferedInputStream = new BufferedInputStream(process.getInputStream()); try { bufferedOutputStream.write(str.getBytes()); bufferedOutputStream.write(10); bufferedOutputStream.flush(); bufferedOutputStream.close(); process.waitFor(); String a2 = a(bufferedInputStream); bufferedOutputStream.close(); try { bufferedInputStream.close(); } catch (IOException unused6) { } if (process != null) { process.destroy(); } return a2; } catch (Exception unused7) { if (bufferedOutputStream != null) { } if (bufferedInputStream != null) { } if (process != null) { } return null; } catch (Throwable th3) { th = th3; bufferedOutputStream2 = bufferedOutputStream; if (bufferedOutputStream2 != null) { } if (bufferedInputStream != null) { } if (process != null) { } throw th; } } catch (Exception unused8) { bufferedInputStream = null; if (bufferedOutputStream != null) { } if (bufferedInputStream != null) { } if (process != null) { } return null; } catch (Throwable th4) { th = th4; bufferedInputStream = null; bufferedOutputStream2 = bufferedOutputStream; if (bufferedOutputStream2 != null) { } if (bufferedInputStream != null) { } if (process != null) { } throw th; } } catch (Exception unused9) { process = null; bufferedOutputStream = null; bufferedInputStream = null; if (bufferedOutputStream != null) { } if (bufferedInputStream != null) { } if (process != null) { } return null; } catch (Throwable th5) { th = th5; process = null; bufferedInputStream = null; if (bufferedOutputStream2 != null) { } if (bufferedInputStream != null) { } if (process != null) { } throw th; } } /* JADX WARNING: Code restructure failed: missing block: B:9:?, code lost: return null; */ /* JADX WARNING: Exception block dominator not found, dom blocks: [] */ public String b(String str) { Object invoke = Class.forName("android.os.SystemProperties").getMethod("get", String.class).invoke(null, str); if (invoke != null) { return (String) invoke; } return null; } }