package defpackage;

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

/* renamed from: ᵨːʗ, reason: contains not printable characters */
/* loaded from: classes3.dex */
public final class C3734 extends AbstractC3447 implements InterfaceC4622 {

    /* renamed from: ᵢˇᵭ, reason: contains not printable characters */
    public final /* synthetic */ int f13943;

    /* renamed from: ᵿʗᵝʽ, reason: contains not printable characters */
    public final /* synthetic */ C4160 f13944;

    /* JADX WARN: 'super' call moved to the top of the method (can break code semantics) */
    public /* synthetic */ C3734(C4160 c4160, int i) {
        super(0);
        this.f13943 = i;
        this.f13944 = c4160;
    }

    @Override // defpackage.InterfaceC4622
    /* renamed from: ᵥᵯˎ */
    public final Object mo1401() throws Throwable {
        ParcelFileDescriptor parcelFileDescriptorOpen;
        int i = this.f13943;
        C4160 c4160 = this.f13944;
        switch (i) {
            case 0:
                System.loadLibrary("datastore_shared_counter");
                File file = new File(c4160.f15550.getAbsolutePath() + c4160.f15544);
                C4160.m9065(c4160, file);
                try {
                    parcelFileDescriptorOpen = ParcelFileDescriptor.open(file, 939524096);
                    try {
                        int fd = parcelFileDescriptorOpen.getFd();
                        NativeSharedCounter nativeSharedCounter = C4303.f16128;
                        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");
                        }
                        C4303 c4303 = new C4303(jNativeCreateSharedCounter);
                        parcelFileDescriptorOpen.close();
                        return c4303;
                    } catch (Throwable th) {
                        th = th;
                        if (parcelFileDescriptorOpen != null) {
                            parcelFileDescriptorOpen.close();
                        }
                        throw th;
                    }
                } catch (Throwable th2) {
                    th = th2;
                    parcelFileDescriptorOpen = null;
                }
            default:
                File file2 = new File(c4160.f15550.getAbsolutePath() + c4160.f15552);
                C4160.m9065(c4160, file2);
                return file2;
        }
    }
}
