package defpackage;

import androidx.media3.container.NalUnitUtil;
import com.google.android.gms.tasks.Task;
import java.util.concurrent.CancellationException;
import kotlin.Metadata;
import kotlin.coroutines.Continuation;
import kotlin.coroutines.jvm.internal.DebugProbesKt;

/* JADX INFO: loaded from: classes3.dex */
@Metadata(d1 = {"\u0000\u0002\n\u0000¨\u0006\u0000"}, d2 = {"kotlinx-coroutines-play-services"}, k = 2, mv = {2, 0, 0}, xi = NalUnitUtil.H265_NAL_UNIT_TYPE_UNSPECIFIED)
@vx8
public final class ak9 {
    public static final Object a(Task task, Continuation continuation) throws Exception {
        if (!task.isComplete()) {
            ts0 ts0Var = new ts0(1, dr4.d(continuation));
            ts0Var.r();
            task.addOnCompleteListener(ab2.a, new yj9(ts0Var));
            Object objQ = ts0Var.q();
            if (objQ == ck1.a) {
                DebugProbesKt.probeCoroutineSuspended(continuation);
            }
            return objQ;
        }
        Exception exception = task.getException();
        if (exception != null) {
            throw exception;
        }
        if (!task.isCanceled()) {
            return task.getResult();
        }
        throw new CancellationException("Task " + task + " was cancelled normally.");
    }
}
