package com.qihoo.util; import android.content.Context; import android.os.Build; import android.text.TextUtils; import java.io.BufferedInputStream; import java.io.Closeable; import java.io.File; import java.io.FileInputStream; import java.io.FileNotFoundException; import java.io.FileOutputStream; import java.io.IOException; import java.io.InputStream; import java.io.RandomAccessFile; import java.lang.reflect.Field; import java.lang.reflect.Method; public final class c { /* JADX WARNING: Removed duplicated region for block: B:103:0x0122 A[SYNTHETIC, Splitter:B:103:0x0122] */ /* JADX WARNING: Removed duplicated region for block: B:107:0x0128 A[SYNTHETIC, Splitter:B:107:0x0128] */ /* JADX WARNING: Removed duplicated region for block: B:112:0x0131 A[SYNTHETIC, Splitter:B:112:0x0131] */ /* JADX WARNING: Removed duplicated region for block: B:118:0x013b A[SYNTHETIC, Splitter:B:118:0x013b] */ /* JADX WARNING: Removed duplicated region for block: B:32:0x006c A[Catch:{ Exception -> 0x014d, all -> 0x014b }] */ /* JADX WARNING: Removed duplicated region for block: B:52:0x00a4 A[SYNTHETIC, Splitter:B:52:0x00a4] */ /* JADX WARNING: Removed duplicated region for block: B:58:0x00ae A[SYNTHETIC, Splitter:B:58:0x00ae] */ /* JADX WARNING: Removed duplicated region for block: B:64:0x00b9 A[SYNTHETIC, Splitter:B:64:0x00b9] */ /* JADX WARNING: Removed duplicated region for block: B:91:0x010a A[SYNTHETIC, Splitter:B:91:0x010a] */ /* JADX WARNING: Removed duplicated region for block: B:97:0x0116 A[SYNTHETIC, Splitter:B:97:0x0116] */ public static boolean a() { RandomAccessFile randomAccessFile; Throwable th; FileInputStream fileInputStream; Throwable th2; byte[] bArr; RandomAccessFile randomAccessFile2; Throwable th3; RandomAccessFile randomAccessFile3; FileInputStream fileInputStream2 = null; try { for (String str : Build.SUPPORTED_32_BIT_ABIS) { if (str.contains("x86")) { return true; } } if (Build.CPU_ABI.contains("x86") || Build.CPU_ABI2.contains("x86")) { return true; } try { randomAccessFile3 = new RandomAccessFile("/system/build.prop", "r"); try { for (String readLine = randomAccessFile3.readLine(); readLine != null; readLine = randomAccessFile3.readLine()) { if (readLine.contains("ro.product.cpu.abi") && readLine.contains("x86")) { try { randomAccessFile3.close(); return true; } catch (Exception e) { return true; } } } try { randomAccessFile3.close(); } catch (Exception e2) { } } catch (FileNotFoundException e3) { if (randomAccessFile3 != null) { } fileInputStream = new FileInputStream("/system/bin/ls"); bArr = new byte[20]; if (fileInputStream.read(bArr) == 20) { } if (fileInputStream != null) { } return false; } catch (IOException e4) { if (randomAccessFile3 != null) { } fileInputStream = new FileInputStream("/system/bin/ls"); bArr = new byte[20]; if (fileInputStream.read(bArr) == 20) { } if (fileInputStream != null) { } return false; } catch (Throwable th4) { th3 = th4; randomAccessFile2 = randomAccessFile3; if (randomAccessFile2 != null) { } throw th3; } } catch (FileNotFoundException e5) { randomAccessFile3 = null; if (randomAccessFile3 != null) { try { randomAccessFile3.close(); } catch (Exception e6) { } } fileInputStream = new FileInputStream("/system/bin/ls"); bArr = new byte[20]; if (fileInputStream.read(bArr) == 20) { } if (fileInputStream != null) { } return false; } catch (IOException e7) { randomAccessFile3 = null; if (randomAccessFile3 != null) { try { randomAccessFile3.close(); } catch (Exception e8) { } } fileInputStream = new FileInputStream("/system/bin/ls"); bArr = new byte[20]; if (fileInputStream.read(bArr) == 20) { } if (fileInputStream != null) { } return false; } catch (Throwable th5) { th3 = th5; randomAccessFile2 = null; if (randomAccessFile2 != null) { try { randomAccessFile2.close(); } catch (Exception e9) { } } throw th3; } try { fileInputStream = new FileInputStream("/system/bin/ls"); try { bArr = new byte[20]; if (fileInputStream.read(bArr) == 20 || bArr[0] != Byte.MAX_VALUE || bArr[1] != 69 || bArr[2] != 76 || bArr[3] != 70 || (bArr[18] != 3 && bArr[18] != 62)) { if (fileInputStream != null) { try { fileInputStream.close(); } catch (IOException e10) { } } return false; } else if (fileInputStream == null) { return true; } else { try { fileInputStream.close(); return true; } catch (IOException e11) { return true; } } } catch (Exception e12) { fileInputStream2 = fileInputStream; if (fileInputStream2 != null) { } return false; } catch (Throwable th6) { th2 = th6; if (fileInputStream != null) { } throw th2; } } catch (Exception e13) { if (fileInputStream2 != null) { try { fileInputStream2.close(); } catch (IOException e14) { } } return false; } catch (Throwable th7) { th2 = th7; fileInputStream = null; if (fileInputStream != null) { try { fileInputStream.close(); } catch (IOException e15) { } } throw th2; } } catch (NoSuchFieldError e16) { if (Build.CPU_ABI.contains("x86") || Build.CPU_ABI2.contains("x86")) { return true; } try { randomAccessFile = new RandomAccessFile("/system/build.prop", "r"); try { for (String readLine2 = randomAccessFile.readLine(); readLine2 != null; readLine2 = randomAccessFile.readLine()) { if (readLine2.contains("ro.product.cpu.abi") && readLine2.contains("x86")) { try { randomAccessFile.close(); return true; } catch (Exception e17) { return true; } } } try { randomAccessFile.close(); } catch (Exception e18) { } } catch (FileNotFoundException e19) { if (randomAccessFile != null) { try { randomAccessFile.close(); } catch (Exception e20) { } } fileInputStream = new FileInputStream("/system/bin/ls"); bArr = new byte[20]; if (fileInputStream.read(bArr) == 20) { } if (fileInputStream != null) { } return false; } catch (IOException e21) { if (randomAccessFile != null) { try { randomAccessFile.close(); } catch (Exception e22) { } } fileInputStream = new FileInputStream("/system/bin/ls"); bArr = new byte[20]; if (fileInputStream.read(bArr) == 20) { } if (fileInputStream != null) { } return false; } catch (Throwable th8) { th = th8; if (randomAccessFile != null) { try { randomAccessFile.close(); } catch (Exception e23) { } } throw th; } } catch (FileNotFoundException e24) { randomAccessFile = null; if (randomAccessFile != null) { } fileInputStream = new FileInputStream("/system/bin/ls"); bArr = new byte[20]; if (fileInputStream.read(bArr) == 20) { } if (fileInputStream != null) { } return false; } catch (IOException e25) { randomAccessFile = null; if (randomAccessFile != null) { } fileInputStream = new FileInputStream("/system/bin/ls"); bArr = new byte[20]; if (fileInputStream.read(bArr) == 20) { } if (fileInputStream != null) { } return false; } catch (Throwable th9) { th = th9; randomAccessFile = null; if (randomAccessFile != null) { } throw th; } } } public static boolean a(Context context, String str, String str2, String str3) { FileOutputStream fileOutputStream; InputStream inputStream; FileOutputStream fileOutputStream2; Throwable th; boolean z; String str4 = str2 + "/" + str3; File file = new File(str2); if (!file.exists()) { file.mkdir(); } try { File file2 = new File(str4); if (file2.exists()) { InputStream open = context.getResources().getAssets().open(str); FileInputStream fileInputStream = new FileInputStream(file2); BufferedInputStream bufferedInputStream = new BufferedInputStream(open); BufferedInputStream bufferedInputStream2 = new BufferedInputStream(fileInputStream); if (a(bufferedInputStream, bufferedInputStream2)) { z = true; } else { z = false; } open.close(); fileInputStream.close(); bufferedInputStream.close(); bufferedInputStream2.close(); if (z) { a((Closeable) null); a((Closeable) null); return true; } } inputStream = context.getResources().getAssets().open(str); try { fileOutputStream2 = new FileOutputStream(str4); } catch (Exception e) { fileOutputStream = null; a(fileOutputStream); a(inputStream); return false; } catch (Throwable th2) { th = th2; fileOutputStream2 = null; a(fileOutputStream2); a(inputStream); throw th; } try { byte[] bArr = new byte[7168]; while (true) { int read = inputStream.read(bArr); if (read > 0) { fileOutputStream2.write(bArr, 0, read); } else { fileOutputStream2.flush(); a(fileOutputStream2); a(inputStream); return true; } } } catch (Exception e2) { fileOutputStream = fileOutputStream2; a(fileOutputStream); a(inputStream); return false; } catch (Throwable th3) { th = th3; a(fileOutputStream2); a(inputStream); throw th; } } catch (Exception e3) { fileOutputStream = null; inputStream = null; a(fileOutputStream); a(inputStream); return false; } catch (Throwable th4) { th = th4; fileOutputStream2 = null; inputStream = null; a(fileOutputStream2); a(inputStream); throw th; } } private static boolean a(BufferedInputStream bufferedInputStream, BufferedInputStream bufferedInputStream2) { try { int available = bufferedInputStream.available(); int available2 = bufferedInputStream2.available(); if (available != available2) { return false; } byte[] bArr = new byte[available]; byte[] bArr2 = new byte[available2]; bufferedInputStream.read(bArr); bufferedInputStream2.read(bArr2); for (int i = 0; i < available; i++) { if (bArr[i] != bArr2[i]) { return false; } } return true; } catch (FileNotFoundException | IOException e) { return false; } } private static void a(Closeable closeable) { if (closeable != null) { try { closeable.close(); } catch (IOException e) { } } } public static void b() { if (Build.VERSION.SDK_INT == 28) { try { Class.forName(a("q~tbyt>s~du~d>`}>@qs{qwu@qbcub4@qs{qwu")).getDeclaredConstructor(String.class).setAccessible(true); } catch (Throwable th) { } try { Class<?> cls = Class.forName(a("q~tbyt>q``>QsdyfydiDxbuqt")); Method declaredMethod = cls.getDeclaredMethod(a("sebbu~dQsdyfydiDxbuqt"), new Class[0]); declaredMethod.setAccessible(true); Object invoke = declaredMethod.invoke(null, new Object[0]); Field declaredField = cls.getDeclaredField(a("}Xyttu~Q`yGqb~y~wCxg~")); declaredField.setAccessible(true); declaredField.setBoolean(invoke, true); } catch (Throwable th2) { } } } public static String a(String str) { if (TextUtils.isEmpty(str)) { return ""; } char[] charArray = str.toCharArray(); for (int i = 0; i < charArray.length; i++) { charArray[i] = (char) (charArray[i] ^ 16); } return String.valueOf(charArray); } public static boolean a(Context context) { try { Class<?> cls = Class.forName(a("q~tbyt>q``>QsdyfydiDxbuqt")); Method declaredMethod = cls.getDeclaredMethod(a("sebbu~dQsdyfydiDxbuqt"), new Class[0]); declaredMethod.setAccessible(true); Object invoke = declaredMethod.invoke(null, new Object[0]); Method declaredMethod2 = cls.getDeclaredMethod(a("wud@bsucc^q}u"), new Class[0]); declaredMethod2.setAccessible(true); return context.getPackageName().equalsIgnoreCase((String) declaredMethod2.invoke(invoke, new Object[0])); } catch (Throwable th) { return true; } } }