package com.facetec.sdk; import android.content.Context; import java.io.ByteArrayOutputStream; import java.io.File; import java.io.FileInputStream; import java.io.FileOutputStream; import java.io.IOException; /* JADX INFO: Access modifiers changed from: package-private */ /* loaded from: classes.dex */ public final class bh { bh() { } private static byte[] d(File file) throws IOException { FileInputStream fileInputStream = new FileInputStream(file); try { return b(fileInputStream); } finally { fileInputStream.close(); } } /* JADX INFO: Access modifiers changed from: package-private */ public static byte[] e(Context context, String str) throws Exception { FileInputStream openFileInput = context.openFileInput(str); try { byte[] b = b(openFileInput); if (openFileInput != null) { openFileInput.close(); } return b; } catch (Throwable th) { if (openFileInput != null) { try { openFileInput.close(); } catch (Throwable th2) { th.addSuppressed(th2); } } throw th; } } private static byte[] b(FileInputStream fileInputStream) throws IOException { ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream(); byte[] bArr = new byte[(int) fileInputStream.getChannel().size()]; while (fileInputStream.available() > 0) { byteArrayOutputStream.write(bArr, 0, fileInputStream.read(bArr)); } return byteArrayOutputStream.toByteArray(); } /* JADX INFO: Access modifiers changed from: package-private */ public static byte d(Context context, String str) throws Exception { return (byte) context.openFileInput(str).read(); } /* JADX INFO: Access modifiers changed from: package-private */ public static void a(Context context, String str, byte[] bArr) throws IOException { FileOutputStream openFileOutput = context.openFileOutput(str, 0); openFileOutput.write(bArr); openFileOutput.close(); } private static void b(File file, byte[] bArr) throws IOException { FileOutputStream fileOutputStream = new FileOutputStream(file); try { try { fileOutputStream.write(bArr); } catch (IOException e) { throw e; } } finally { fileOutputStream.close(); } } /* JADX INFO: Access modifiers changed from: package-private */ public static void d(File file, byte[] bArr, byte[] bArr2) throws Exception { b(file, new aa(bArr).c(bArr2)); } /* JADX INFO: Access modifiers changed from: package-private */ public static void b(Context context, String str, byte[] bArr, byte[] bArr2) throws Exception { a(context, str, new aa(bArr).c(bArr2)); } /* JADX INFO: Access modifiers changed from: package-private */ public static byte[] a(File file, byte[] bArr) throws Exception { return new aa(bArr).e(d(file)); } /* JADX INFO: Access modifiers changed from: package-private */ public static byte[] e(Context context, String str, byte[] bArr) throws Exception { return new aa(bArr).e(e(context, str)); } }