alexandroid/decompiled/jadx/sources/okio/Timeout.java
KaKi87 a47fad5135 📦 Add decompiled Alexa 2.2.730155.0 (jadx, apktool, Hermes strings)
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-11-07 00:04:16 +01:00

231 lines
10 KiB
Java

package okio;
import androidx.compose.animation.core.ArcMode$$ExternalSyntheticOutline0;
import androidx.exifinterface.media.ExifInterface;
import com.amazon.alexa.redesign.view.container.CardStudioAgentSpaceMetrics;
import java.io.IOException;
import java.io.InterruptedIOException;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.locks.Condition;
import kotlin.Metadata;
import kotlin.jvm.JvmField;
import kotlin.jvm.functions.Function0;
import kotlin.jvm.internal.DefaultConstructorMarker;
import kotlin.jvm.internal.InlineMarker;
import kotlin.jvm.internal.SourceDebugExtension;
import org.jetbrains.annotations.NotNull;
import rx.Single$$ExternalSyntheticBUOutline0;
/* compiled from: r8-map-id-b9432e0f623b4a4bff4ba50a8a24c4aafad2c1e11092747b9fb5e6a22af5a940 */
@Metadata(d1 = {"\u00008\n\u0002\u0018\u0002\n\u0002\u0010\u0000\n\u0002\b\u0002\n\u0002\u0010\t\n\u0000\n\u0002\u0010\u000b\n\u0002\b\u0002\n\u0002\u0010\u0002\n\u0000\n\u0002\u0018\u0002\n\u0002\b\u0005\n\u0002\u0018\u0002\n\u0002\b\u0004\n\u0002\u0018\u0002\n\u0002\b\u0007\b\u0016\u0018\u0000 \u001c2\u00020\u0001:\u0001\u001cB\u0005¢\u0006\u0002\u0010\u0002J\u000e\u0010\b\u001a\u00020\t2\u0006\u0010\n\u001a\u00020\u000bJ\b\u0010\f\u001a\u00020\u0000H\u0016J\b\u0010\r\u001a\u00020\u0000H\u0016J\u0016\u0010\u000e\u001a\u00020\u00002\u0006\u0010\u000f\u001a\u00020\u00042\u0006\u0010\u0010\u001a\u00020\u0011J\b\u0010\u0003\u001a\u00020\u0004H\u0016J\u0010\u0010\u0003\u001a\u00020\u00002\u0006\u0010\u0003\u001a\u00020\u0004H\u0016J\b\u0010\u0005\u001a\u00020\u0006H\u0016J-\u0010\u0012\u001a\u0002H\u0013\"\u0004\b\u0000\u0010\u00132\u0006\u0010\u0014\u001a\u00020\u00002\f\u0010\u0015\u001a\b\u0012\u0004\u0012\u0002H\u00130\u0016H\u0086\bø\u0001\u0000¢\u0006\u0002\u0010\u0017J\b\u0010\u0018\u001a\u00020\tH\u0016J\u0018\u0010\u0019\u001a\u00020\u00002\u0006\u0010\u0019\u001a\u00020\u00042\u0006\u0010\u0010\u001a\u00020\u0011H\u0016J\b\u0010\u0007\u001a\u00020\u0004H\u0016J\u000e\u0010\u001a\u001a\u00020\t2\u0006\u0010\u001b\u001a\u00020\u0001R\u000e\u0010\u0003\u001a\u00020\u0004X\u0082\u000e¢\u0006\u0002\n\u0000R\u000e\u0010\u0005\u001a\u00020\u0006X\u0082\u000e¢\u0006\u0002\n\u0000R\u000e\u0010\u0007\u001a\u00020\u0004X\u0082\u000e¢\u0006\u0002\n\u0000\u0082\u0002\u0007\n\u0005\b\u009920\u0001¨\u0006\u001d"}, d2 = {"Lokio/Timeout;", "", "()V", "deadlineNanoTime", "", "hasDeadline", "", "timeoutNanos", "awaitSignal", "", "condition", "Ljava/util/concurrent/locks/Condition;", "clearDeadline", "clearTimeout", "deadline", "duration", "unit", "Ljava/util/concurrent/TimeUnit;", "intersectWith", ExifInterface.GPS_DIRECTION_TRUE, CardStudioAgentSpaceMetrics.DimensionValue.SCHEME_OTHER, "block", "Lkotlin/Function0;", "(Lokio/Timeout;Lkotlin/jvm/functions/Function0;)Ljava/lang/Object;", "throwIfReached", "timeout", "waitUntilNotified", "monitor", "Companion", "okio"}, k = 1, mv = {1, 9, 0}, xi = 48)
@SourceDebugExtension({"SMAP\nTimeout.kt\nKotlin\n*S Kotlin\n*F\n+ 1 Timeout.kt\nokio/Timeout\n+ 2 fake.kt\nkotlin/jvm/internal/FakeKt\n*L\n1#1,316:1\n1#2:317\n*E\n"})
/* loaded from: classes10.dex */
public class Timeout {
/* renamed from: Companion, reason: from kotlin metadata */
@NotNull
public static final Companion INSTANCE = new Companion(null);
@JvmField
@NotNull
public static final Timeout NONE = new Timeout() { // from class: okio.Timeout$Companion$NONE$1
@Override // okio.Timeout
@NotNull
public Timeout timeout(long timeout, @NotNull TimeUnit unit) {
unit.getClass();
return this;
}
@Override // okio.Timeout
public void throwIfReached() {
}
@Override // okio.Timeout
@NotNull
public Timeout deadlineNanoTime(long deadlineNanoTime) {
return this;
}
};
private long deadlineNanoTime;
private boolean hasDeadline;
private long timeoutNanos;
public final void awaitSignal(@NotNull Condition condition) throws InterruptedIOException {
condition.getClass();
try {
boolean hasDeadline = getHasDeadline();
long timeoutNanos = getTimeoutNanos();
long j = 0;
if (!hasDeadline && timeoutNanos == 0) {
condition.await();
return;
}
long nanoTime = System.nanoTime();
if (hasDeadline && timeoutNanos != 0) {
timeoutNanos = Math.min(timeoutNanos, deadlineNanoTime() - nanoTime);
} else if (hasDeadline) {
timeoutNanos = deadlineNanoTime() - nanoTime;
}
if (timeoutNanos > 0) {
condition.await(timeoutNanos, TimeUnit.NANOSECONDS);
j = System.nanoTime() - nanoTime;
}
if (j >= timeoutNanos) {
throw new InterruptedIOException("timeout");
}
} catch (InterruptedException unused) {
Thread.currentThread().interrupt();
throw new InterruptedIOException("interrupted");
}
}
@NotNull
public Timeout clearDeadline() {
this.hasDeadline = false;
return this;
}
@NotNull
public Timeout clearTimeout() {
this.timeoutNanos = 0L;
return this;
}
@NotNull
public final Timeout deadline(long duration, @NotNull TimeUnit unit) {
unit.getClass();
if (duration > 0) {
return deadlineNanoTime(unit.toNanos(duration) + System.nanoTime());
}
Path$$ExternalSyntheticBUOutline0.m((Object) ArcMode$$ExternalSyntheticOutline0.m(duration, "duration <= 0: "));
return null;
}
public long deadlineNanoTime() {
if (this.hasDeadline) {
return this.deadlineNanoTime;
}
Single$$ExternalSyntheticBUOutline0.m$2("No deadline");
return 0L;
}
/* renamed from: hasDeadline, reason: from getter */
public boolean getHasDeadline() {
return this.hasDeadline;
}
public final <T> T intersectWith(@NotNull Timeout other, @NotNull Function0<? extends T> block) {
other.getClass();
block.getClass();
long timeoutNanos = getTimeoutNanos();
long minTimeout = INSTANCE.minTimeout(other.getTimeoutNanos(), getTimeoutNanos());
TimeUnit timeUnit = TimeUnit.NANOSECONDS;
timeout(minTimeout, timeUnit);
if (!getHasDeadline()) {
if (other.getHasDeadline()) {
deadlineNanoTime(other.deadlineNanoTime());
}
try {
return block.invoke();
} finally {
InlineMarker.finallyStart(1);
timeout(timeoutNanos, timeUnit);
if (other.getHasDeadline()) {
clearDeadline();
}
InlineMarker.finallyEnd(1);
}
}
long deadlineNanoTime = deadlineNanoTime();
if (other.getHasDeadline()) {
deadlineNanoTime(Math.min(deadlineNanoTime(), other.deadlineNanoTime()));
}
try {
return block.invoke();
} finally {
InlineMarker.finallyStart(1);
timeout(timeoutNanos, timeUnit);
if (other.getHasDeadline()) {
deadlineNanoTime(deadlineNanoTime);
}
InlineMarker.finallyEnd(1);
}
}
public void throwIfReached() throws IOException {
if (Thread.currentThread().isInterrupted()) {
throw new InterruptedIOException("interrupted");
}
if (this.hasDeadline && this.deadlineNanoTime - System.nanoTime() <= 0) {
throw new InterruptedIOException("deadline reached");
}
}
@NotNull
public Timeout timeout(long timeout, @NotNull TimeUnit unit) {
unit.getClass();
if (timeout >= 0) {
this.timeoutNanos = unit.toNanos(timeout);
return this;
}
Path$$ExternalSyntheticBUOutline0.m((Object) ArcMode$$ExternalSyntheticOutline0.m(timeout, "timeout < 0: "));
return null;
}
/* renamed from: timeoutNanos, reason: from getter */
public long getTimeoutNanos() {
return this.timeoutNanos;
}
public final void waitUntilNotified(@NotNull Object monitor) throws InterruptedIOException {
monitor.getClass();
try {
boolean hasDeadline = getHasDeadline();
long timeoutNanos = getTimeoutNanos();
long j = 0;
if (!hasDeadline && timeoutNanos == 0) {
monitor.wait();
return;
}
long nanoTime = System.nanoTime();
if (hasDeadline && timeoutNanos != 0) {
timeoutNanos = Math.min(timeoutNanos, deadlineNanoTime() - nanoTime);
} else if (hasDeadline) {
timeoutNanos = deadlineNanoTime() - nanoTime;
}
if (timeoutNanos > 0) {
long j2 = timeoutNanos / 1000000;
monitor.wait(j2, (int) (timeoutNanos - (1000000 * j2)));
j = System.nanoTime() - nanoTime;
}
if (j >= timeoutNanos) {
throw new InterruptedIOException("timeout");
}
} catch (InterruptedException unused) {
Thread.currentThread().interrupt();
throw new InterruptedIOException("interrupted");
}
}
/* compiled from: r8-map-id-b9432e0f623b4a4bff4ba50a8a24c4aafad2c1e11092747b9fb5e6a22af5a940 */
@Metadata(d1 = {"\u0000\u001a\n\u0002\u0018\u0002\n\u0002\u0010\u0000\n\u0002\b\u0002\n\u0002\u0018\u0002\n\u0000\n\u0002\u0010\t\n\u0002\b\u0003\b\u0086\u0003\u0018\u00002\u00020\u0001B\u0007\b\u0002¢\u0006\u0002\u0010\u0002J\u0016\u0010\u0005\u001a\u00020\u00062\u0006\u0010\u0007\u001a\u00020\u00062\u0006\u0010\b\u001a\u00020\u0006R\u0010\u0010\u0003\u001a\u00020\u00048\u0006X\u0087\u0004¢\u0006\u0002\n\u0000¨\u0006\t"}, d2 = {"Lokio/Timeout$Companion;", "", "()V", "NONE", "Lokio/Timeout;", "minTimeout", "", "aNanos", "bNanos", "okio"}, k = 1, mv = {1, 9, 0}, xi = 48)
public static final class Companion {
public /* synthetic */ Companion(DefaultConstructorMarker defaultConstructorMarker) {
this();
}
public final long minTimeout(long aNanos, long bNanos) {
return (aNanos != 0 && (bNanos == 0 || aNanos < bNanos)) ? aNanos : bNanos;
}
private Companion() {
}
}
@NotNull
public Timeout deadlineNanoTime(long deadlineNanoTime) {
this.hasDeadline = true;
this.deadlineNanoTime = deadlineNanoTime;
return this;
}
}