content: package androidx.core.view;
  
  import android.content.Context;
  import android.os.Build;
  import android.util.AttributeSet;
  import android.util.Log;
  import android.view.LayoutInflater;
  import android.view.View;
  import java.lang.reflect.Field;
  
  public final class LayoutInflaterCompat {
      private static final String TAG = "LayoutInflaterCompatHC";
      private static boolean sCheckedField;
      private static Field sLayoutInflaterFactory2Field;
  
      static class Factory2Wrapper implements LayoutInflater.Factory2 {
          final LayoutInflaterFactory mDelegateFactory;
  
          Factory2Wrapper(LayoutInflaterFactory delegateFactory) {
              this.mDelegateFactory = delegateFactory;
          }
  
          public View onCreateView(View parent, String name, Context context, AttributeSet attributeSet) {
              return this.mDelegateFactory.onCreateView(parent, name, context, attributeSet);
          }
  
          public View onCreateView(String name, Context context, AttributeSet attrs) {
              return this.mDelegateFactory.onCreateView((View) null, name, context, attrs);
          }
  
          public String toString() {
              return getClass().getName() + "{" + this.mDelegateFactory + "}";
          }
      }
  
      private LayoutInflaterCompat() {
      }
  
      private static void forceSetFactory2(LayoutInflater inflater, LayoutInflater.Factory2 factory) {
          if (!sCheckedField) {
              try {
                  Field declaredField = LayoutInflater.class.getDeclaredField("mFactory2");
                  sLayoutInflaterFactory2Field = declaredField;
                  declaredField.setAccessible(true);
              } catch (NoSuchFieldException e) {
                  Log.e(TAG, "forceSetFactory2 Could not find field 'mFactory2' on class " + LayoutInflater.class.getName() + "; inflation may have unexpected results.", e);
              }
              sCheckedField = true;
          }
          Field field = sLayoutInflaterFactory2Field;
          if (field != null) {
              try {
                  field.set(inflater, factory);
              } catch (IllegalAccessException e2) {
                  Log.e(TAG, "forceSetFactory2 could not set the Factory2 on LayoutInflater " + inflater + "; inflation may have unexpected results.", e2);
              }
          }
      }
  
      @Deprecated
      public static LayoutInflaterFactory getFactory(LayoutInflater inflater) {
          LayoutInflater.Factory factory = inflater.getFactory();
          if (factory instanceof Factory2Wrapper) {
              return ((Factory2Wrapper) factory).mDelegateFactory;
          }
          return null;
      }
  
      @Deprecated
      public static void setFactory(LayoutInflater inflater, LayoutInflaterFactory factory) {
          if (Build.VERSION.SDK_INT >= 21) {
              inflater.setFactory2(new Factory2Wrapper(factory));
              return;
          }
          Factory2Wrapper factory2Wrapper = new Factory2Wrapper(factory);
          inflater.setFactory2(factory2Wrapper);
          LayoutInflater.Factory factory2 = inflater.getFactory();
          if (factory2 instanceof LayoutInflater.Factory2) {
              forceSetFactory2(inflater, (LayoutInflater.Factory2) factory2);
          } else {
              forceSetFactory2(inflater, factory2Wrapper);
          }
      }
  
      public static void setFactory2(LayoutInflater inflater, LayoutInflater.Factory2 factory) {
          inflater.setFactory2(factory);
          if (Build.VERSION.SDK_INT < 21) {
              LayoutInflater.Factory factory2 = inflater.getFactory();
              if (factory2 instanceof LayoutInflater.Factory2) {
                  forceSetFactory2(inflater, (LayoutInflater.Factory2) factory2);
              } else {
                  forceSetFactory2(inflater, factory);
              }
          }
      }
  }
  