package com.pingan.ai; import android.content.Context; import android.content.res.AssetManager; import android.os.Process; import android.text.TextUtils; import com.pingan.ai.face.utils.PaFaceLogger; import java.io.File; import java.io.FileInputStream; import java.io.FileOutputStream; import java.io.IOException; import java.io.InputStream; import java.lang.reflect.Method; import o.xzZ; /* loaded from: classes3.dex */ public class p { public static final String a = "p"; private static int b = 0; private static int e = 1; /* JADX WARN: Removed duplicated region for block: B:6:0x001b A[ORIG_RETURN, RETURN] */ /* Code decompiled incorrectly, please refer to instructions dump. To view partially-correct add '--show-bad-code' argument */ public static int a(int r4, int r5) { /* r0 = 180(0xb4, float:2.52E-43) r1 = 270(0x10e, float:3.78E-43) r2 = 90 r3 = 1 if (r4 != r3) goto L10 if (r5 == r2) goto L16 if (r5 == r1) goto L12 if (r5 != r0) goto L1b goto L1c L10: if (r5 != r2) goto L14 L12: r3 = 0 goto L1c L14: if (r5 != r1) goto L18 L16: r3 = 2 goto L1c L18: if (r5 != r0) goto L1b goto L1c L1b: r3 = 3 L1c: return r3 */ throw new UnsupportedOperationException("Method not decompiled: com.pingan.ai.p.a(int, int):int"); } public static void a(Context context) { String str = a; PaFaceLogger.i(str, "preLoadModel start"); long currentTimeMillis = System.currentTimeMillis(); StringBuilder sb = new StringBuilder(); sb.append(context.getFilesDir().getAbsolutePath()); sb.append("/model"); File file = new File(sb.toString()); StringBuilder sb2 = new StringBuilder(); sb2.append(context.getFilesDir().getAbsolutePath()); sb2.append("/model/4.9.0"); String obj = sb2.toString(); File file2 = new File(obj); if (!file.exists()) { PaFaceLogger.i(str, "oldFile.mkdir:".concat(String.valueOf(file.mkdir()))); } if (!file2.exists()) { boolean b2 = y.b(file); boolean mkdirs = file2.mkdirs(); StringBuilder sb3 = new StringBuilder("preLoadModel deleteDirWithFile : dir1="); sb3.append(b2); sb3.append(",modeldir="); sb3.append(mkdirs); PaFaceLogger.i(str, sb3.toString()); try { a(context, obj); } catch (Exception e2) { String str2 = a; StringBuilder sb4 = new StringBuilder("preLoadModel copyAllModel exception : "); sb4.append(e2.getMessage()); PaFaceLogger.error(str2, sb4.toString()); } } String str3 = a; StringBuilder sb5 = new StringBuilder("preLoadModel end use time : "); sb5.append(System.currentTimeMillis() - currentTimeMillis); PaFaceLogger.i(str3, sb5.toString()); } public static void b(Context context, String str, String str2, String str3) { StringBuilder sb = new StringBuilder(); sb.append(str); sb.append(File.separator); sb.append(str2); String obj = sb.toString(); if (a(obj)) { File file = new File(obj); if (str3.equals(a(file))) { return; } else { file.delete(); } } a(context, str2, str, str2); } public static void a(Context context, String str) { try { b(context, str, "blur_nx.dat", "3754244cc3ede570b0a6c9d8fa36affc"); b(context, str, "detect_nx.dat", "0f19d184dc00f49c90200be7914f2db7"); b(context, str, "eye_close_nx.dat", "915d4b4961d131ad3e589939565631f9"); b(context, str, "head_pose_nx.dat", "1663571f19ca714c05ad43c75645d9dc"); b(context, str, "landmark_nx_106.dat", "14e8a4c80ae42e3570a7fbfd5d29bd19"); b(context, str, "license.txt", "ec60d4305b43308e9ad8f7ed7cbf9c0e"); b(context, str, "live_nx_224.dat", "036035c3716efbee62f68333ecf8152d"); b(context, str, "live_nx_320.dat", "a1e2a6c9ae95ad1269519660516fe08a"); b(context, str, "occ_nx.dat", "ab472620bd3e330318c5058aae482763"); b(context, str, "ranking_nx.dat", "a3bed8b8ac0f0f6da2a5d817c024f4ab"); b(context, str, "reg_nx.dat", "45d3438d2baf4aab6a861858289c612f"); b(context, str, "anti_splicing_nx.dat", "094a25e2802d39c5c22f30584ed133bf"); b(context, str, "live_nx_light.dat", "9c8a45eb2e779a25fae3bc4bc73e5f0b"); b(context, str, "live_nx_light_0.dat", "b1b8bcd66fa85a40c2f091751ae9d814"); b(context, str, "live_nx_light_1.dat", "6823f392a8c6ff0fae9a388067ba65aa"); b(context, str, "live_nx_light_2.dat", "4af132fbbb699d3b3522bacd238d5335"); b(context, str, "live_nx_light_3.dat", "6437acaf700b7fcb1c1ff49ac0e53b8c"); } catch (Exception e2) { StringBuilder sb = new StringBuilder("copy model error, "); sb.append(e2.getMessage()); PaFaceLogger.error(sb.toString()); } } public static boolean a(String str) { try { return new File(str).exists(); } catch (Exception unused) { return false; } } /* JADX WARN: Multi-variable type inference failed */ /* JADX WARN: Type inference failed for: r10v0, types: [java.lang.Object, java.lang.String] */ /* JADX WARN: Type inference failed for: r10v1 */ /* JADX WARN: Type inference failed for: r10v3, types: [java.io.OutputStream] */ /* JADX WARN: Type inference failed for: r10v34 */ /* JADX WARN: Type inference failed for: r9v0, types: [android.content.Context] */ /* JADX WARN: Type inference failed for: r9v10, types: [java.io.InputStream] */ /* JADX WARN: Type inference failed for: r9v14 */ /* JADX WARN: Type inference failed for: r9v15, types: [java.io.InputStream] */ /* JADX WARN: Type inference failed for: r9v2 */ /* JADX WARN: Type inference failed for: r9v25, types: [java.io.InputStream] */ /* JADX WARN: Type inference failed for: r9v4 */ /* JADX WARN: Type inference failed for: r9v5, types: [java.io.InputStream] */ public static void a(Context context, String str, String str2, String str3) { Throwable th; Exception e2; FileOutputStream fileOutputStream; int i = 2 % 2; StringBuilder sb = new StringBuilder(); sb.append(str2); sb.append(File.separator); sb.append(str3); String obj = sb.toString(); File file = new File(str2); if (!file.exists()) { boolean mkdir = file.mkdir(); StringBuilder sb2 = new StringBuilder("copy model,mkdir : "); sb2.append(mkdir); sb2.append(",dir:"); sb2.append(file.getAbsolutePath()); PaFaceLogger.error(sb2.toString()); } try { try { if (new File(obj).exists()) { context = 0; fileOutputStream = null; } else { try { Object[] objArr = {context.getResources().getAssets(), str}; Object obj2 = xzZ.y.get(-867414553); if (obj2 == null) { obj2 = ((Class) xzZ.c(4 - TextUtils.lastIndexOf("", '0', 0, 0), (Process.myPid() >> 22) + 5, (char) TextUtils.getOffsetAfter("", 0))).getMethod("NN_", AssetManager.class, String.class); xzZ.y.put(-867414553, obj2); } context = (InputStream) ((Method) obj2).invoke(null, objArr); try { fileOutputStream = new FileOutputStream(obj); try { byte[] bArr = new byte[7168]; while (true) { int read = context.read(bArr); if (read <= 0) { break; } else { fileOutputStream.write(bArr, 0, read); } } } catch (Exception e3) { e2 = e3; StringBuilder sb3 = new StringBuilder(); sb3.append("copy model exception : "); sb3.append(e2.getMessage()); PaFaceLogger.error(sb3.toString()); if (fileOutputStream != null) { try { fileOutputStream.close(); } catch (IOException e4) { StringBuilder sb4 = new StringBuilder("copy model FileOutputStream close exception : "); sb4.append(e4.getMessage()); PaFaceLogger.error(sb4.toString()); } } if (context != 0) { int i2 = e + 9; b = i2 % 128; int i3 = i2 % 2; try { context.close(); return; } catch (IOException e5) { StringBuilder sb5 = new StringBuilder("copy model InputStream close exception : "); sb5.append(e5.getMessage()); PaFaceLogger.error(sb5.toString()); return; } } return; } } catch (Exception e6) { e2 = e6; fileOutputStream = null; } catch (Throwable th2) { th = th2; str = 0; if (str != 0) { int i4 = b + 49; e = i4 % 128; try { if (i4 % 2 == 0) { str.close(); throw null; } str.close(); } catch (IOException e7) { StringBuilder sb6 = new StringBuilder("copy model FileOutputStream close exception : "); sb6.append(e7.getMessage()); PaFaceLogger.error(sb6.toString()); } } if (context != 0) { try { context.close(); } catch (IOException e8) { StringBuilder sb7 = new StringBuilder("copy model InputStream close exception : "); sb7.append(e8.getMessage()); PaFaceLogger.error(sb7.toString()); } } throw th; } } catch (Throwable th3) { Throwable cause = th3.getCause(); if (cause == null) { throw th3; } throw cause; } } if (fileOutputStream != null) { int i5 = b + 117; e = i5 % 128; try { if (i5 % 2 == 0) { fileOutputStream.close(); throw null; } fileOutputStream.close(); } catch (IOException e9) { StringBuilder sb8 = new StringBuilder("copy model FileOutputStream close exception : "); sb8.append(e9.getMessage()); PaFaceLogger.error(sb8.toString()); } } if (context != 0) { try { context.close(); } catch (IOException e10) { StringBuilder sb9 = new StringBuilder("copy model InputStream close exception : "); sb9.append(e10.getMessage()); PaFaceLogger.error(sb9.toString()); } } } catch (Throwable th4) { th = th4; } } catch (Exception e11) { e2 = e11; context = 0; fileOutputStream = null; } catch (Throwable th5) { th = th5; context = 0; str = 0; } } public static boolean a(String str, String str2) { File file = new File(str2); if (!file.exists()) { file.mkdir(); } y.b(file); return y.a(str, str2); } public static String a(File file) { if (!file.isFile()) { return null; } try { return v.b(new FileInputStream(file)); } catch (IOException unused) { return ""; } } }