package o; import android.content.Context; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.File; import java.io.FileInputStream; import java.io.FileOutputStream; import java.io.IOException; import java.util.Arrays; import java.util.List; import java.util.UUID; /* loaded from: classes.dex */ public final class DYW { private static final List c = Arrays.asList("FNumber", "ExposureTime", "ISOSpeedRatings", "GPSAltitude", "GPSAltitudeRef", "FocalLength", "GPSDateStamp", "WhiteBalance", "GPSProcessingMethod", "GPSTimeStamp", "DateTime", "Flash", "GPSLatitude", "GPSLatitudeRef", "GPSLongitude", "GPSLongitudeRef", "Make", "Model"); private final hvV a; public DYW(String str) throws IOException { this.a = new hvV(str); } public DYW(byte[] bArr) throws IOException { this.a = new hvV(new ByteArrayInputStream(bArr)); } public final ByteArrayOutputStream c(Context context, ByteArrayOutputStream byteArrayOutputStream) { FileOutputStream fileOutputStream; ByteArrayOutputStream byteArrayOutputStream2; FileInputStream fileInputStream; FileInputStream fileInputStream2 = null; try { String obj = UUID.randomUUID().toString(); File cacheDir = context.getCacheDir(); StringBuilder sb = new StringBuilder(); sb.append(obj); sb.append(".jpg"); File file = new File(cacheDir, sb.toString()); fileOutputStream = new FileOutputStream(file); try { C15195gjp.b(byteArrayOutputStream.toByteArray(), fileOutputStream); fileOutputStream.close(); hvV hvv = new hvV(file.getAbsolutePath()); hvV hvv2 = this.a; for (String str : c) { if (hvv2.a(str) != null) { hvv.d(str, hvv2.a(str)); } } try { hvv.e(); } catch (IOException unused) { } hvv.e(); fileOutputStream.close(); byteArrayOutputStream2 = new ByteArrayOutputStream(); fileInputStream = new FileInputStream(file); } catch (Exception unused2) { } } catch (Exception unused3) { fileOutputStream = null; } try { C15195gjp.c(fileInputStream, byteArrayOutputStream2); fileInputStream.close(); return byteArrayOutputStream2; } catch (Exception unused4) { fileInputStream2 = fileInputStream; if (fileInputStream2 != null) { try { fileInputStream2.close(); } catch (IOException unused5) { } } if (fileOutputStream != null) { try { fileOutputStream.close(); } catch (IOException unused6) { } } return byteArrayOutputStream; } } }