ADD week 5
This commit is contained in:
		| @@ -0,0 +1,32 @@ | ||||
| package kotlinx.coroutines.android; | ||||
|  | ||||
| import android.os.Looper; | ||||
| import java.util.List; | ||||
| import kotlin.Metadata; | ||||
| import kotlinx.coroutines.MainCoroutineDispatcher; | ||||
| import kotlinx.coroutines.internal.LockFreeTaskQueueCore; | ||||
| import kotlinx.coroutines.internal.MainDispatcherFactory; | ||||
|  | ||||
| /* compiled from: HandlerDispatcher.kt */ | ||||
| @Metadata(d1 = {"\u0000&\n\u0002\u0018\u0002\n\u0002\u0018\u0002\n\u0002\b\u0002\n\u0002\u0010\b\n\u0002\b\u0003\n\u0002\u0018\u0002\n\u0000\n\u0002\u0010 \n\u0000\n\u0002\u0010\u000e\n\u0000\b\u0000\u0018\u00002\u00020\u0001B\u0005¢\u0006\u0002\u0010\u0002J\u0016\u0010\u0007\u001a\u00020\b2\f\u0010\t\u001a\b\u0012\u0004\u0012\u00020\u00010\nH\u0016J\b\u0010\u000b\u001a\u00020\fH\u0016R\u0014\u0010\u0003\u001a\u00020\u00048VX\u0096\u0004¢\u0006\u0006\u001a\u0004\b\u0005\u0010\u0006¨\u0006\r"}, d2 = {"Lkotlinx/coroutines/android/AndroidDispatcherFactory;", "Lkotlinx/coroutines/internal/MainDispatcherFactory;", "()V", "loadPriority", "", "getLoadPriority", "()I", "createDispatcher", "Lkotlinx/coroutines/MainCoroutineDispatcher;", "allFactories", "", "hintOnError", "", "kotlinx-coroutines-android"}, k = 1, mv = {1, 8, 0}, xi = 48) | ||||
| /* loaded from: classes.dex */ | ||||
| public final class AndroidDispatcherFactory implements MainDispatcherFactory { | ||||
|     @Override // kotlinx.coroutines.internal.MainDispatcherFactory | ||||
|     public int getLoadPriority() { | ||||
|         return LockFreeTaskQueueCore.MAX_CAPACITY_MASK; | ||||
|     } | ||||
|  | ||||
|     @Override // kotlinx.coroutines.internal.MainDispatcherFactory | ||||
|     public String hintOnError() { | ||||
|         return "For tests Dispatchers.setMain from kotlinx-coroutines-test module can be used"; | ||||
|     } | ||||
|  | ||||
|     @Override // kotlinx.coroutines.internal.MainDispatcherFactory | ||||
|     public MainCoroutineDispatcher createDispatcher(List<? extends MainDispatcherFactory> allFactories) { | ||||
|         Looper mainLooper = Looper.getMainLooper(); | ||||
|         if (mainLooper == null) { | ||||
|             throw new IllegalStateException("The main looper is not available"); | ||||
|         } | ||||
|         return new HandlerContext(HandlerDispatcherKt.asHandler(mainLooper, true), null, 2, null); | ||||
|     } | ||||
| } | ||||
| @@ -0,0 +1,55 @@ | ||||
| package kotlinx.coroutines.android; | ||||
|  | ||||
| import android.os.Build; | ||||
| import java.lang.Thread; | ||||
| import java.lang.reflect.Method; | ||||
| import java.lang.reflect.Modifier; | ||||
| import kotlin.Metadata; | ||||
| import kotlin.coroutines.AbstractCoroutineContextElement; | ||||
| import kotlin.coroutines.CoroutineContext; | ||||
| import kotlinx.coroutines.CoroutineExceptionHandler; | ||||
|  | ||||
| /* compiled from: AndroidExceptionPreHandler.kt */ | ||||
| @Metadata(d1 = {"\u0000.\n\u0002\u0018\u0002\n\u0002\u0018\u0002\n\u0002\u0018\u0002\n\u0002\b\u0002\n\u0002\u0010\u0000\n\u0000\n\u0002\u0010\u0002\n\u0000\n\u0002\u0018\u0002\n\u0000\n\u0002\u0010\u0003\n\u0000\n\u0002\u0018\u0002\n\u0000\b\u0000\u0018\u00002\u00020\u00012\u00020\u0002B\u0005¢\u0006\u0002\u0010\u0003J\u0018\u0010\u0006\u001a\u00020\u00072\u0006\u0010\b\u001a\u00020\t2\u0006\u0010\n\u001a\u00020\u000bH\u0016J\n\u0010\f\u001a\u0004\u0018\u00010\rH\u0002R\u0010\u0010\u0004\u001a\u0004\u0018\u00010\u0005X\u0082\u000e¢\u0006\u0002\n\u0000¨\u0006\u000e"}, d2 = {"Lkotlinx/coroutines/android/AndroidExceptionPreHandler;", "Lkotlin/coroutines/AbstractCoroutineContextElement;", "Lkotlinx/coroutines/CoroutineExceptionHandler;", "()V", "_preHandler", "", "handleException", "", "context", "Lkotlin/coroutines/CoroutineContext;", "exception", "", "preHandler", "Ljava/lang/reflect/Method;", "kotlinx-coroutines-android"}, k = 1, mv = {1, 8, 0}, xi = 48) | ||||
| /* loaded from: classes.dex */ | ||||
| public final class AndroidExceptionPreHandler extends AbstractCoroutineContextElement implements CoroutineExceptionHandler { | ||||
|     private volatile Object _preHandler; | ||||
|  | ||||
|     public AndroidExceptionPreHandler() { | ||||
|         super(CoroutineExceptionHandler.INSTANCE); | ||||
|         this._preHandler = this; | ||||
|     } | ||||
|  | ||||
|     private final Method preHandler() { | ||||
|         Object obj = this._preHandler; | ||||
|         if (obj != this) { | ||||
|             return (Method) obj; | ||||
|         } | ||||
|         Method method = null; | ||||
|         try { | ||||
|             Method declaredMethod = Thread.class.getDeclaredMethod("getUncaughtExceptionPreHandler", new Class[0]); | ||||
|             if (Modifier.isPublic(declaredMethod.getModifiers())) { | ||||
|                 if (Modifier.isStatic(declaredMethod.getModifiers())) { | ||||
|                     method = declaredMethod; | ||||
|                 } | ||||
|             } | ||||
|         } catch (Throwable unused) { | ||||
|         } | ||||
|         this._preHandler = method; | ||||
|         return method; | ||||
|     } | ||||
|  | ||||
|     @Override // kotlinx.coroutines.CoroutineExceptionHandler | ||||
|     public void handleException(CoroutineContext context, Throwable exception) { | ||||
|         int i = Build.VERSION.SDK_INT; | ||||
|         if (26 > i || i >= 28) { | ||||
|             return; | ||||
|         } | ||||
|         Method preHandler = preHandler(); | ||||
|         Object invoke = preHandler != null ? preHandler.invoke(null, new Object[0]) : null; | ||||
|         Thread.UncaughtExceptionHandler uncaughtExceptionHandler = invoke instanceof Thread.UncaughtExceptionHandler ? (Thread.UncaughtExceptionHandler) invoke : null; | ||||
|         if (uncaughtExceptionHandler != null) { | ||||
|             uncaughtExceptionHandler.uncaughtException(Thread.currentThread(), exception); | ||||
|         } | ||||
|     } | ||||
| } | ||||
| @@ -0,0 +1,153 @@ | ||||
| package kotlinx.coroutines.android; | ||||
|  | ||||
| import android.os.Handler; | ||||
| import android.os.Looper; | ||||
| import java.util.concurrent.CancellationException; | ||||
| import kotlin.Metadata; | ||||
| import kotlin.Unit; | ||||
| import kotlin.coroutines.CoroutineContext; | ||||
| import kotlin.jvm.functions.Function1; | ||||
| import kotlin.jvm.internal.DefaultConstructorMarker; | ||||
| import kotlin.jvm.internal.Intrinsics; | ||||
| import kotlin.ranges.RangesKt; | ||||
| import kotlin.time.DurationKt; | ||||
| import kotlinx.coroutines.CancellableContinuation; | ||||
| import kotlinx.coroutines.Delay; | ||||
| import kotlinx.coroutines.Dispatchers; | ||||
| import kotlinx.coroutines.DisposableHandle; | ||||
| import kotlinx.coroutines.JobKt; | ||||
| import kotlinx.coroutines.NonDisposableHandle; | ||||
|  | ||||
| /* compiled from: HandlerDispatcher.kt */ | ||||
| @Metadata(d1 = {"\u0000^\n\u0002\u0018\u0002\n\u0002\u0018\u0002\n\u0002\u0018\u0002\n\u0000\n\u0002\u0018\u0002\n\u0000\n\u0002\u0010\u000e\n\u0002\b\u0002\n\u0002\u0010\u000b\n\u0002\b\u0006\n\u0002\u0010\u0002\n\u0000\n\u0002\u0018\u0002\n\u0000\n\u0002\u0018\u0002\n\u0002\u0018\u0002\n\u0002\b\u0003\n\u0002\u0010\u0000\n\u0000\n\u0002\u0010\b\n\u0000\n\u0002\u0018\u0002\n\u0000\n\u0002\u0010\t\n\u0002\b\u0003\n\u0002\u0018\u0002\n\u0002\b\u0002\b\u0000\u0018\u00002\u00020\u00012\u00020\u0002B\u001b\b\u0016\u0012\u0006\u0010\u0003\u001a\u00020\u0004\u0012\n\b\u0002\u0010\u0005\u001a\u0004\u0018\u00010\u0006¢\u0006\u0002\u0010\u0007B!\b\u0002\u0012\u0006\u0010\u0003\u001a\u00020\u0004\u0012\b\u0010\u0005\u001a\u0004\u0018\u00010\u0006\u0012\u0006\u0010\b\u001a\u00020\t¢\u0006\u0002\u0010\nJ\u001c\u0010\u000f\u001a\u00020\u00102\u0006\u0010\u0011\u001a\u00020\u00122\n\u0010\u0013\u001a\u00060\u0014j\u0002`\u0015H\u0002J\u001c\u0010\u0016\u001a\u00020\u00102\u0006\u0010\u0011\u001a\u00020\u00122\n\u0010\u0013\u001a\u00060\u0014j\u0002`\u0015H\u0016J\u0013\u0010\u0017\u001a\u00020\t2\b\u0010\u0018\u001a\u0004\u0018\u00010\u0019H\u0096\u0002J\b\u0010\u001a\u001a\u00020\u001bH\u0016J$\u0010\u001c\u001a\u00020\u001d2\u0006\u0010\u001e\u001a\u00020\u001f2\n\u0010\u0013\u001a\u00060\u0014j\u0002`\u00152\u0006\u0010\u0011\u001a\u00020\u0012H\u0016J\u0010\u0010 \u001a\u00020\t2\u0006\u0010\u0011\u001a\u00020\u0012H\u0016J\u001e\u0010!\u001a\u00020\u00102\u0006\u0010\u001e\u001a\u00020\u001f2\f\u0010\"\u001a\b\u0012\u0004\u0012\u00020\u00100#H\u0016J\b\u0010$\u001a\u00020\u0006H\u0016R\u0010\u0010\u000b\u001a\u0004\u0018\u00010\u0000X\u0082\u000e¢\u0006\u0002\n\u0000R\u000e\u0010\u0003\u001a\u00020\u0004X\u0082\u0004¢\u0006\u0002\n\u0000R\u0014\u0010\f\u001a\u00020\u0000X\u0096\u0004¢\u0006\b\n\u0000\u001a\u0004\b\r\u0010\u000eR\u000e\u0010\b\u001a\u00020\tX\u0082\u0004¢\u0006\u0002\n\u0000R\u0010\u0010\u0005\u001a\u0004\u0018\u00010\u0006X\u0082\u0004¢\u0006\u0002\n\u0000¨\u0006%"}, d2 = {"Lkotlinx/coroutines/android/HandlerContext;", "Lkotlinx/coroutines/android/HandlerDispatcher;", "Lkotlinx/coroutines/Delay;", "handler", "Landroid/os/Handler;", "name", "", "(Landroid/os/Handler;Ljava/lang/String;)V", "invokeImmediately", "", "(Landroid/os/Handler;Ljava/lang/String;Z)V", "_immediate", "immediate", "getImmediate", "()Lkotlinx/coroutines/android/HandlerContext;", "cancelOnRejection", "", "context", "Lkotlin/coroutines/CoroutineContext;", "block", "Ljava/lang/Runnable;", "Lkotlinx/coroutines/Runnable;", "dispatch", "equals", "other", "", "hashCode", "", "invokeOnTimeout", "Lkotlinx/coroutines/DisposableHandle;", "timeMillis", "", "isDispatchNeeded", "scheduleResumeAfterDelay", "continuation", "Lkotlinx/coroutines/CancellableContinuation;", "toString", "kotlinx-coroutines-android"}, k = 1, mv = {1, 8, 0}, xi = 48) | ||||
| /* loaded from: classes.dex */ | ||||
| public final class HandlerContext extends HandlerDispatcher implements Delay { | ||||
|     private volatile HandlerContext _immediate; | ||||
|     private final Handler handler; | ||||
|     private final HandlerContext immediate; | ||||
|     private final boolean invokeImmediately; | ||||
|     private final String name; | ||||
|  | ||||
|     @Override // kotlinx.coroutines.android.HandlerDispatcher, kotlinx.coroutines.MainCoroutineDispatcher | ||||
|     public HandlerContext getImmediate() { | ||||
|         return this.immediate; | ||||
|     } | ||||
|  | ||||
|     private HandlerContext(Handler handler, String str, boolean z) { | ||||
|         super(null); | ||||
|         this.handler = handler; | ||||
|         this.name = str; | ||||
|         this.invokeImmediately = z; | ||||
|         this._immediate = z ? this : null; | ||||
|         HandlerContext handlerContext = this._immediate; | ||||
|         if (handlerContext == null) { | ||||
|             handlerContext = new HandlerContext(handler, str, true); | ||||
|             this._immediate = handlerContext; | ||||
|         } | ||||
|         this.immediate = handlerContext; | ||||
|     } | ||||
|  | ||||
|     public /* synthetic */ HandlerContext(Handler handler, String str, int i, DefaultConstructorMarker defaultConstructorMarker) { | ||||
|         this(handler, (i & 2) != 0 ? null : str); | ||||
|     } | ||||
|  | ||||
|     public HandlerContext(Handler handler, String str) { | ||||
|         this(handler, str, false); | ||||
|     } | ||||
|  | ||||
|     @Override // kotlinx.coroutines.CoroutineDispatcher | ||||
|     public boolean isDispatchNeeded(CoroutineContext context) { | ||||
|         return (this.invokeImmediately && Intrinsics.areEqual(Looper.myLooper(), this.handler.getLooper())) ? false : true; | ||||
|     } | ||||
|  | ||||
|     @Override // kotlinx.coroutines.CoroutineDispatcher | ||||
|     /* renamed from: dispatch */ | ||||
|     public void mo1907dispatch(CoroutineContext context, Runnable block) { | ||||
|         if (this.handler.post(block)) { | ||||
|             return; | ||||
|         } | ||||
|         cancelOnRejection(context, block); | ||||
|     } | ||||
|  | ||||
|     @Override // kotlinx.coroutines.android.HandlerDispatcher, kotlinx.coroutines.Delay | ||||
|     public DisposableHandle invokeOnTimeout(long timeMillis, final Runnable block, CoroutineContext context) { | ||||
|         if (this.handler.postDelayed(block, RangesKt.coerceAtMost(timeMillis, DurationKt.MAX_MILLIS))) { | ||||
|             return new DisposableHandle() { // from class: kotlinx.coroutines.android.HandlerContext$$ExternalSyntheticLambda0 | ||||
|                 @Override // kotlinx.coroutines.DisposableHandle | ||||
|                 public final void dispose() { | ||||
|                     HandlerContext.invokeOnTimeout$lambda$3(HandlerContext.this, block); | ||||
|                 } | ||||
|             }; | ||||
|         } | ||||
|         cancelOnRejection(context, block); | ||||
|         return NonDisposableHandle.INSTANCE; | ||||
|     } | ||||
|  | ||||
|     /* JADX INFO: Access modifiers changed from: private */ | ||||
|     public static final void invokeOnTimeout$lambda$3(HandlerContext handlerContext, Runnable runnable) { | ||||
|         handlerContext.handler.removeCallbacks(runnable); | ||||
|     } | ||||
|  | ||||
|     private final void cancelOnRejection(CoroutineContext context, Runnable block) { | ||||
|         JobKt.cancel(context, new CancellationException("The task was rejected, the handler underlying the dispatcher '" + this + "' was closed")); | ||||
|         Dispatchers.getIO().mo1907dispatch(context, block); | ||||
|     } | ||||
|  | ||||
|     @Override // kotlinx.coroutines.MainCoroutineDispatcher, kotlinx.coroutines.CoroutineDispatcher | ||||
|     public String toString() { | ||||
|         String stringInternalImpl = toStringInternalImpl(); | ||||
|         if (stringInternalImpl != null) { | ||||
|             return stringInternalImpl; | ||||
|         } | ||||
|         String str = this.name; | ||||
|         if (str == null) { | ||||
|             str = this.handler.toString(); | ||||
|         } | ||||
|         if (!this.invokeImmediately) { | ||||
|             return str; | ||||
|         } | ||||
|         return str + ".immediate"; | ||||
|     } | ||||
|  | ||||
|     public boolean equals(Object other) { | ||||
|         return (other instanceof HandlerContext) && ((HandlerContext) other).handler == this.handler; | ||||
|     } | ||||
|  | ||||
|     public int hashCode() { | ||||
|         return System.identityHashCode(this.handler); | ||||
|     } | ||||
|  | ||||
|     @Override // kotlinx.coroutines.Delay | ||||
|     /* renamed from: scheduleResumeAfterDelay */ | ||||
|     public void mo1908scheduleResumeAfterDelay(long timeMillis, final CancellableContinuation<? super Unit> continuation) { | ||||
|         final Runnable runnable = new Runnable() { // from class: kotlinx.coroutines.android.HandlerContext$scheduleResumeAfterDelay$$inlined$Runnable$1 | ||||
|             @Override // java.lang.Runnable | ||||
|             public final void run() { | ||||
|                 CancellableContinuation.this.resumeUndispatched(this, Unit.INSTANCE); | ||||
|             } | ||||
|         }; | ||||
|         if (this.handler.postDelayed(runnable, RangesKt.coerceAtMost(timeMillis, DurationKt.MAX_MILLIS))) { | ||||
|             continuation.invokeOnCancellation(new Function1<Throwable, Unit>() { // from class: kotlinx.coroutines.android.HandlerContext$scheduleResumeAfterDelay$1 | ||||
|                 /* JADX WARN: 'super' call moved to the top of the method (can break code semantics) */ | ||||
|                 { | ||||
|                     super(1); | ||||
|                 } | ||||
|  | ||||
|                 @Override // kotlin.jvm.functions.Function1 | ||||
|                 public /* bridge */ /* synthetic */ Unit invoke(Throwable th) { | ||||
|                     invoke2(th); | ||||
|                     return Unit.INSTANCE; | ||||
|                 } | ||||
|  | ||||
|                 /* renamed from: invoke, reason: avoid collision after fix types in other method */ | ||||
|                 public final void invoke2(Throwable th) { | ||||
|                     Handler handler; | ||||
|                     handler = HandlerContext.this.handler; | ||||
|                     handler.removeCallbacks(runnable); | ||||
|                 } | ||||
|             }); | ||||
|         } else { | ||||
|             cancelOnRejection(continuation.get$context(), runnable); | ||||
|         } | ||||
|     } | ||||
| } | ||||
| @@ -0,0 +1,37 @@ | ||||
| package kotlinx.coroutines.android; | ||||
|  | ||||
| import kotlin.Deprecated; | ||||
| import kotlin.DeprecationLevel; | ||||
| import kotlin.Metadata; | ||||
| import kotlin.Unit; | ||||
| import kotlin.coroutines.Continuation; | ||||
| import kotlin.coroutines.CoroutineContext; | ||||
| import kotlin.jvm.internal.DefaultConstructorMarker; | ||||
| import kotlinx.coroutines.Delay; | ||||
| import kotlinx.coroutines.DisposableHandle; | ||||
| import kotlinx.coroutines.MainCoroutineDispatcher; | ||||
|  | ||||
| /* compiled from: HandlerDispatcher.kt */ | ||||
| @Metadata(d1 = {"\u0000\u0016\n\u0002\u0018\u0002\n\u0002\u0018\u0002\n\u0002\u0018\u0002\n\u0002\b\u0004\n\u0002\u0018\u0002\n\u0000\b6\u0018\u00002\u00020\u00012\u00020\u0002B\u0007\b\u0004¢\u0006\u0002\u0010\u0003R\u0012\u0010\u0004\u001a\u00020\u0000X¦\u0004¢\u0006\u0006\u001a\u0004\b\u0005\u0010\u0006\u0082\u0001\u0001\u0007¨\u0006\b"}, d2 = {"Lkotlinx/coroutines/android/HandlerDispatcher;", "Lkotlinx/coroutines/MainCoroutineDispatcher;", "Lkotlinx/coroutines/Delay;", "()V", "immediate", "getImmediate", "()Lkotlinx/coroutines/android/HandlerDispatcher;", "Lkotlinx/coroutines/android/HandlerContext;", "kotlinx-coroutines-android"}, k = 1, mv = {1, 8, 0}, xi = 48) | ||||
| /* loaded from: classes.dex */ | ||||
| public abstract class HandlerDispatcher extends MainCoroutineDispatcher implements Delay { | ||||
|     public /* synthetic */ HandlerDispatcher(DefaultConstructorMarker defaultConstructorMarker) { | ||||
|         this(); | ||||
|     } | ||||
|  | ||||
|     @Override // kotlinx.coroutines.MainCoroutineDispatcher | ||||
|     public abstract HandlerDispatcher getImmediate(); | ||||
|  | ||||
|     private HandlerDispatcher() { | ||||
|     } | ||||
|  | ||||
|     @Override // kotlinx.coroutines.Delay | ||||
|     @Deprecated(level = DeprecationLevel.ERROR, message = "Deprecated without replacement as an internal method never intended for public use") | ||||
|     public Object delay(long j, Continuation<? super Unit> continuation) { | ||||
|         return Delay.DefaultImpls.delay(this, j, continuation); | ||||
|     } | ||||
|  | ||||
|     public DisposableHandle invokeOnTimeout(long j, Runnable runnable, CoroutineContext coroutineContext) { | ||||
|         return Delay.DefaultImpls.invokeOnTimeout(this, j, runnable, coroutineContext); | ||||
|     } | ||||
| } | ||||
| @@ -0,0 +1,138 @@ | ||||
| package kotlinx.coroutines.android; | ||||
|  | ||||
| import android.os.Build; | ||||
| import android.os.Handler; | ||||
| import android.os.Looper; | ||||
| import android.view.Choreographer; | ||||
| import androidx.constraintlayout.core.motion.utils.TypedValues; | ||||
| import kotlin.Deprecated; | ||||
| import kotlin.DeprecationLevel; | ||||
| import kotlin.Metadata; | ||||
| import kotlin.Result; | ||||
| import kotlin.ResultKt; | ||||
| import kotlin.coroutines.Continuation; | ||||
| import kotlin.coroutines.intrinsics.IntrinsicsKt; | ||||
| import kotlin.coroutines.jvm.internal.DebugProbesKt; | ||||
| import kotlin.jvm.internal.Intrinsics; | ||||
| import kotlinx.coroutines.CancellableContinuation; | ||||
| import kotlinx.coroutines.CancellableContinuationImpl; | ||||
| import kotlinx.coroutines.Dispatchers; | ||||
|  | ||||
| /* compiled from: HandlerDispatcher.kt */ | ||||
| @Metadata(d1 = {"\u0000@\n\u0000\n\u0002\u0010\t\n\u0000\n\u0002\u0018\u0002\n\u0002\b\u0003\n\u0002\u0018\u0002\n\u0002\b\u0004\n\u0002\u0010\u0002\n\u0000\n\u0002\u0018\u0002\n\u0002\b\u0002\n\u0002\u0018\u0002\n\u0000\n\u0002\u0010\u000e\n\u0002\b\u0002\n\u0002\u0018\u0002\n\u0000\n\u0002\u0010\u000b\n\u0000\u001a\u0011\u0010\b\u001a\u00020\u0001H\u0086@ø\u0001\u0000¢\u0006\u0002\u0010\t\u001a\u0011\u0010\n\u001a\u00020\u0001H\u0082@ø\u0001\u0000¢\u0006\u0002\u0010\t\u001a\u001e\u0010\u000b\u001a\u00020\f2\u0006\u0010\u0006\u001a\u00020\u00072\f\u0010\r\u001a\b\u0012\u0004\u0012\u00020\u00010\u000eH\u0002\u001a\u0016\u0010\u000f\u001a\u00020\f2\f\u0010\r\u001a\b\u0012\u0004\u0012\u00020\u00010\u000eH\u0002\u001a\u001d\u0010\u0010\u001a\u00020\u0003*\u00020\u00112\n\b\u0002\u0010\u0012\u001a\u0004\u0018\u00010\u0013H\u0007¢\u0006\u0002\b\u0014\u001a\u0014\u0010\u0015\u001a\u00020\u0011*\u00020\u00162\u0006\u0010\u0017\u001a\u00020\u0018H\u0001\"\u000e\u0010\u0000\u001a\u00020\u0001X\u0082T¢\u0006\u0002\n\u0000\"\u0018\u0010\u0002\u001a\u0004\u0018\u00010\u00038\u0000X\u0081\u0004¢\u0006\b\n\u0000\u0012\u0004\b\u0004\u0010\u0005\"\u0010\u0010\u0006\u001a\u0004\u0018\u00010\u0007X\u0082\u000e¢\u0006\u0002\n\u0000\u0082\u0002\u0004\n\u0002\b\u0019¨\u0006\u0019"}, d2 = {"MAX_DELAY", "", "Main", "Lkotlinx/coroutines/android/HandlerDispatcher;", "getMain$annotations", "()V", "choreographer", "Landroid/view/Choreographer;", "awaitFrame", "(Lkotlin/coroutines/Continuation;)Ljava/lang/Object;", "awaitFrameSlowPath", "postFrameCallback", "", "cont", "Lkotlinx/coroutines/CancellableContinuation;", "updateChoreographerAndPostFrameCallback", "asCoroutineDispatcher", "Landroid/os/Handler;", "name", "", TypedValues.TransitionType.S_FROM, "asHandler", "Landroid/os/Looper;", "async", "", "kotlinx-coroutines-android"}, k = 2, mv = {1, 8, 0}, xi = 48) | ||||
| /* loaded from: classes.dex */ | ||||
| public final class HandlerDispatcherKt { | ||||
|     private static final long MAX_DELAY = 4611686018427387903L; | ||||
|     public static final HandlerDispatcher Main; | ||||
|     private static volatile Choreographer choreographer; | ||||
|  | ||||
|     public static final HandlerDispatcher from(Handler handler) { | ||||
|         return from$default(handler, null, 1, null); | ||||
|     } | ||||
|  | ||||
|     @Deprecated(level = DeprecationLevel.HIDDEN, message = "Use Dispatchers.Main instead") | ||||
|     public static /* synthetic */ void getMain$annotations() { | ||||
|     } | ||||
|  | ||||
|     public static /* synthetic */ HandlerDispatcher from$default(Handler handler, String str, int i, Object obj) { | ||||
|         if ((i & 1) != 0) { | ||||
|             str = null; | ||||
|         } | ||||
|         return from(handler, str); | ||||
|     } | ||||
|  | ||||
|     public static final HandlerDispatcher from(Handler handler, String str) { | ||||
|         return new HandlerContext(handler, str); | ||||
|     } | ||||
|  | ||||
|     public static final Handler asHandler(Looper looper, boolean z) { | ||||
|         if (!z) { | ||||
|             return new Handler(looper); | ||||
|         } | ||||
|         if (Build.VERSION.SDK_INT >= 28) { | ||||
|             Object invoke = Handler.class.getDeclaredMethod("createAsync", Looper.class).invoke(null, looper); | ||||
|             Intrinsics.checkNotNull(invoke, "null cannot be cast to non-null type android.os.Handler"); | ||||
|             return (Handler) invoke; | ||||
|         } | ||||
|         try { | ||||
|             return (Handler) Handler.class.getDeclaredConstructor(Looper.class, Handler.Callback.class, Boolean.TYPE).newInstance(looper, null, true); | ||||
|         } catch (NoSuchMethodException unused) { | ||||
|             return new Handler(looper); | ||||
|         } | ||||
|     } | ||||
|  | ||||
|     static { | ||||
|         Object m288constructorimpl; | ||||
|         try { | ||||
|             Result.Companion companion = Result.INSTANCE; | ||||
|             m288constructorimpl = Result.m288constructorimpl(new HandlerContext(asHandler(Looper.getMainLooper(), true), null, 2, null)); | ||||
|         } catch (Throwable th) { | ||||
|             Result.Companion companion2 = Result.INSTANCE; | ||||
|             m288constructorimpl = Result.m288constructorimpl(ResultKt.createFailure(th)); | ||||
|         } | ||||
|         Main = (HandlerDispatcher) (Result.m294isFailureimpl(m288constructorimpl) ? null : m288constructorimpl); | ||||
|     } | ||||
|  | ||||
|     /* JADX INFO: Access modifiers changed from: private */ | ||||
|     public static final void updateChoreographerAndPostFrameCallback(CancellableContinuation<? super Long> cancellableContinuation) { | ||||
|         Choreographer choreographer2 = choreographer; | ||||
|         if (choreographer2 == null) { | ||||
|             choreographer2 = Choreographer.getInstance(); | ||||
|             Intrinsics.checkNotNull(choreographer2); | ||||
|             choreographer = choreographer2; | ||||
|         } | ||||
|         postFrameCallback(choreographer2, cancellableContinuation); | ||||
|     } | ||||
|  | ||||
|     /* JADX INFO: Access modifiers changed from: private */ | ||||
|     public static final void postFrameCallback(Choreographer choreographer2, final CancellableContinuation<? super Long> cancellableContinuation) { | ||||
|         choreographer2.postFrameCallback(new Choreographer.FrameCallback() { // from class: kotlinx.coroutines.android.HandlerDispatcherKt$$ExternalSyntheticLambda0 | ||||
|             @Override // android.view.Choreographer.FrameCallback | ||||
|             public final void doFrame(long j) { | ||||
|                 HandlerDispatcherKt.postFrameCallback$lambda$6(CancellableContinuation.this, j); | ||||
|             } | ||||
|         }); | ||||
|     } | ||||
|  | ||||
|     /* JADX INFO: Access modifiers changed from: private */ | ||||
|     public static final void postFrameCallback$lambda$6(CancellableContinuation cancellableContinuation, long j) { | ||||
|         cancellableContinuation.resumeUndispatched(Dispatchers.getMain(), Long.valueOf(j)); | ||||
|     } | ||||
|  | ||||
|     public static final Object awaitFrame(Continuation<? super Long> continuation) { | ||||
|         Choreographer choreographer2 = choreographer; | ||||
|         if (choreographer2 == null) { | ||||
|             return awaitFrameSlowPath(continuation); | ||||
|         } | ||||
|         CancellableContinuationImpl cancellableContinuationImpl = new CancellableContinuationImpl(IntrinsicsKt.intercepted(continuation), 1); | ||||
|         cancellableContinuationImpl.initCancellability(); | ||||
|         postFrameCallback(choreographer2, cancellableContinuationImpl); | ||||
|         Object result = cancellableContinuationImpl.getResult(); | ||||
|         if (result == IntrinsicsKt.getCOROUTINE_SUSPENDED()) { | ||||
|             DebugProbesKt.probeCoroutineSuspended(continuation); | ||||
|         } | ||||
|         return result; | ||||
|     } | ||||
|  | ||||
|     /* JADX INFO: Access modifiers changed from: private */ | ||||
|     public static final Object awaitFrameSlowPath(Continuation<? super Long> continuation) { | ||||
|         CancellableContinuationImpl cancellableContinuationImpl = new CancellableContinuationImpl(IntrinsicsKt.intercepted(continuation), 1); | ||||
|         cancellableContinuationImpl.initCancellability(); | ||||
|         final CancellableContinuationImpl cancellableContinuationImpl2 = cancellableContinuationImpl; | ||||
|         if (Looper.myLooper() == Looper.getMainLooper()) { | ||||
|             updateChoreographerAndPostFrameCallback(cancellableContinuationImpl2); | ||||
|         } else { | ||||
|             Dispatchers.getMain().mo1907dispatch(cancellableContinuationImpl2.get$context(), new Runnable() { // from class: kotlinx.coroutines.android.HandlerDispatcherKt$awaitFrameSlowPath$lambda$3$$inlined$Runnable$1 | ||||
|                 @Override // java.lang.Runnable | ||||
|                 public final void run() { | ||||
|                     HandlerDispatcherKt.updateChoreographerAndPostFrameCallback(CancellableContinuation.this); | ||||
|                 } | ||||
|             }); | ||||
|         } | ||||
|         Object result = cancellableContinuationImpl.getResult(); | ||||
|         if (result == IntrinsicsKt.getCOROUTINE_SUSPENDED()) { | ||||
|             DebugProbesKt.probeCoroutineSuspended(continuation); | ||||
|         } | ||||
|         return result; | ||||
|     } | ||||
| } | ||||
		Reference in New Issue
	
	Block a user