package androidx.core.app; import android.app.Activity; import android.app.AppComponentFactory; import android.app.Application; import android.app.Service; import android.content.BroadcastReceiver; import android.content.ContentProvider; import android.content.Intent; import androidx.annotation.NonNull; import androidx.annotation.Nullable; import androidx.annotation.RequiresApi; import androidx.annotation.RestrictTo; @RequiresApi(api = 28) @RestrictTo({RestrictTo.Scope.LIBRARY_GROUP_PREFIX}) public class CoreComponentFactory extends AppComponentFactory { @RestrictTo({RestrictTo.Scope.LIBRARY_GROUP_PREFIX}) public interface CompatWrapped { Object getWrapper(); } public static T checkCompatWrapper(T t) { T t2; return (!(t instanceof CompatWrapped) || (t2 = (T) t.getWrapper()) == null) ? t : t2; } @Override // android.app.AppComponentFactory @NonNull public Activity instantiateActivity(@NonNull ClassLoader classLoader, @NonNull String str, @Nullable Intent intent) throws InstantiationException, IllegalAccessException, ClassNotFoundException { return (Activity) checkCompatWrapper(super.instantiateActivity(classLoader, str, intent)); } @Override // android.app.AppComponentFactory @NonNull public Application instantiateApplication(@NonNull ClassLoader classLoader, @NonNull String str) throws InstantiationException, IllegalAccessException, ClassNotFoundException { return (Application) checkCompatWrapper(super.instantiateApplication(classLoader, str)); } @Override // android.app.AppComponentFactory @NonNull public ContentProvider instantiateProvider(@NonNull ClassLoader classLoader, @NonNull String str) throws InstantiationException, IllegalAccessException, ClassNotFoundException { return (ContentProvider) checkCompatWrapper(super.instantiateProvider(classLoader, str)); } @Override // android.app.AppComponentFactory @NonNull public BroadcastReceiver instantiateReceiver(@NonNull ClassLoader classLoader, @NonNull String str, @Nullable Intent intent) throws InstantiationException, IllegalAccessException, ClassNotFoundException { return (BroadcastReceiver) checkCompatWrapper(super.instantiateReceiver(classLoader, str, intent)); } @Override // android.app.AppComponentFactory @NonNull public Service instantiateService(@NonNull ClassLoader classLoader, @NonNull String str, @Nullable Intent intent) throws InstantiationException, IllegalAccessException, ClassNotFoundException { return (Service) checkCompatWrapper(super.instantiateService(classLoader, str, intent)); } }