2021-06-27 20:44:35 +00:00
package androidx.work ;
import android.content.Context ;
import androidx.annotation.NonNull ;
import androidx.annotation.Nullable ;
import androidx.annotation.RestrictTo ;
import c.d.b.a.a ;
public abstract class WorkerFactory {
private static final String TAG = Logger . tagWithPrefix ( " WorkerFactory " ) ;
/* renamed from: androidx.work.WorkerFactory$1 reason: invalid class name */
public class AnonymousClass1 extends WorkerFactory {
@Override // androidx.work.WorkerFactory
@Nullable
public ListenableWorker createWorker ( @NonNull Context context , @NonNull String str , @NonNull WorkerParameters workerParameters ) {
return null ;
}
}
@NonNull
@RestrictTo ( { RestrictTo . Scope . LIBRARY_GROUP } )
public static WorkerFactory getDefaultWorkerFactory ( ) {
return new AnonymousClass1 ( ) ;
}
@Nullable
public abstract ListenableWorker createWorker ( @NonNull Context context , @NonNull String str , @NonNull WorkerParameters workerParameters ) ;
@Nullable
@RestrictTo ( { RestrictTo . Scope . LIBRARY_GROUP } )
public final ListenableWorker createWorkerWithDefaultFallback ( @NonNull Context context , @NonNull String str , @NonNull WorkerParameters workerParameters ) {
ListenableWorker createWorker = createWorker ( context , str , workerParameters ) ;
if ( createWorker = = null ) {
Class cls = null ;
try {
cls = Class . forName ( str ) . asSubclass ( ListenableWorker . class ) ;
} catch ( Throwable th ) {
2021-07-13 20:23:20 +00:00
Logger . get ( ) . error ( TAG , a . t ( " Invalid class: " , str ) , th ) ;
2021-06-27 20:44:35 +00:00
}
if ( cls ! = null ) {
try {
createWorker = ( ListenableWorker ) cls . getDeclaredConstructor ( Context . class , WorkerParameters . class ) . newInstance ( context , workerParameters ) ;
} catch ( Throwable th2 ) {
2021-07-13 20:23:20 +00:00
Logger . get ( ) . error ( TAG , a . t ( " Could not instantiate " , str ) , th2 ) ;
2021-06-27 20:44:35 +00:00
}
}
}
if ( createWorker = = null | | ! createWorker . isUsed ( ) ) {
return createWorker ;
}
throw new IllegalStateException ( String . format ( " WorkerFactory (%s) returned an instance of a ListenableWorker (%s) which has already been invoked. createWorker() must always return a new instance of a ListenableWorker. " , getClass ( ) . getName ( ) , str ) ) ;
}
}