package defpackage;

import android.os.ParcelFileDescriptor;
import androidx.datastore.core.NativeSharedCounter;
import java.io.File;
import java.io.IOException;

/* JADX INFO: renamed from: ˑᵤ, reason: contains not printable characters */
/* JADX INFO: loaded from: classes3.dex */
public final class C2108 extends AbstractC4516 implements InterfaceC1841 {

    /* JADX INFO: renamed from: ᵔᵖᵹᵫ, reason: contains not printable characters */
    public final /* synthetic */ C1201 f8394;

    /* JADX INFO: renamed from: ᵜᵪʾ, reason: contains not printable characters */
    public final /* synthetic */ int f8395;

    /* JADX WARN: 'super' call moved to the top of the method (can break code semantics) */
    public /* synthetic */ C2108(C1201 c1201, int i) {
        super(0);
        this.f8395 = i;
        this.f8394 = c1201;
    }

    @Override // defpackage.InterfaceC1841
    /* JADX INFO: renamed from: ᵲᵶᵳˈ */
    public final Object mo1021() throws Throwable {
        ParcelFileDescriptor parcelFileDescriptorOpen;
        int i = this.f8395;
        C1201 c1201 = this.f8394;
        switch (i) {
            case 0:
                System.loadLibrary("datastore_shared_counter");
                File file = new File(c1201.f5106.getAbsolutePath() + c1201.f5109);
                C1201.m3695(c1201, file);
                try {
                    parcelFileDescriptorOpen = ParcelFileDescriptor.open(file, 939524096);
                    try {
                        int fd = parcelFileDescriptorOpen.getFd();
                        NativeSharedCounter nativeSharedCounter = C5203.f19608;
                        if (nativeSharedCounter.nativeTruncateFile(fd) != 0) {
                            throw new IOException("Failed to truncate counter file");
                        }
                        long jNativeCreateSharedCounter = nativeSharedCounter.nativeCreateSharedCounter(fd);
                        if (jNativeCreateSharedCounter < 0) {
                            throw new IOException("Failed to mmap counter file");
                        }
                        C5203 c5203 = new C5203(jNativeCreateSharedCounter);
                        parcelFileDescriptorOpen.close();
                        return c5203;
                    } catch (Throwable th) {
                        th = th;
                        if (parcelFileDescriptorOpen != null) {
                            parcelFileDescriptorOpen.close();
                        }
                        throw th;
                    }
                } catch (Throwable th2) {
                    th = th2;
                    parcelFileDescriptorOpen = null;
                }
                break;
            default:
                File file2 = new File(c1201.f5106.getAbsolutePath() + c1201.f5112);
                C1201.m3695(c1201, file2);
                return file2;
        }
    }
}
