package com.google.firebase.crashlytics.internal.common; import com.google.firebase.crashlytics.internal.model.CrashlyticsReport; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.IOException; import java.io.InputStream; import java.util.zip.GZIPOutputStream; /* loaded from: classes3.dex */ public class BytesBackedNativeSessionFile implements NativeSessionFile { public final byte[] bytes; public final String dataTransportFilename; public final String reportsEndpointFilename; @Override // com.google.firebase.crashlytics.internal.common.NativeSessionFile public String getReportsEndpointFilename() { return this.reportsEndpointFilename; } public BytesBackedNativeSessionFile(String str, String str2, byte[] bArr) { this.dataTransportFilename = str; this.reportsEndpointFilename = str2; this.bytes = bArr; } @Override // com.google.firebase.crashlytics.internal.common.NativeSessionFile public InputStream getStream() { if (isEmpty()) { return null; } return new ByteArrayInputStream(this.bytes); } @Override // com.google.firebase.crashlytics.internal.common.NativeSessionFile public CrashlyticsReport.FilesPayload.File asFilePayload() { byte[] asGzippedBytes = asGzippedBytes(); if (asGzippedBytes == null) { return null; } return CrashlyticsReport.FilesPayload.File.builder().setContents(asGzippedBytes).setFilename(this.dataTransportFilename).build(); } public final boolean isEmpty() { byte[] bArr = this.bytes; return bArr == null || bArr.length == 0; } public final byte[] asGzippedBytes() { if (isEmpty()) { return null; } try { ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream(); try { GZIPOutputStream gZIPOutputStream = new GZIPOutputStream(byteArrayOutputStream); try { gZIPOutputStream.write(this.bytes); gZIPOutputStream.finish(); byte[] byteArray = byteArrayOutputStream.toByteArray(); gZIPOutputStream.close(); byteArrayOutputStream.close(); return byteArray; } finally { } } finally { } } catch (IOException unused) { return null; } } }