content: package androidx.core.app;
  
  import android.os.Build;
  import android.os.Bundle;
  import android.os.IBinder;
  import android.util.Log;
  import java.lang.reflect.InvocationTargetException;
  import java.lang.reflect.Method;
  
  public final class BundleCompat {
  
      static class Api18Impl {
          private Api18Impl() {
          }
  
          static IBinder getBinder(Bundle bundle, String key) {
              return bundle.getBinder(key);
          }
  
          static void putBinder(Bundle bundle, String key, IBinder value) {
              bundle.putBinder(key, value);
          }
      }
  
      static class BeforeApi18Impl {
          private static final String TAG = "BundleCompatBaseImpl";
          private static Method sGetIBinderMethod;
          private static boolean sGetIBinderMethodFetched;
          private static Method sPutIBinderMethod;
          private static boolean sPutIBinderMethodFetched;
  
          private BeforeApi18Impl() {
          }
  
          public static IBinder getBinder(Bundle bundle, String key) {
              if (!sGetIBinderMethodFetched) {
                  try {
                      Method method = Bundle.class.getMethod("getIBinder", new Class[]{String.class});
                      sGetIBinderMethod = method;
                      method.setAccessible(true);
                  } catch (NoSuchMethodException e) {
                      Log.i(TAG, "Failed to retrieve getIBinder method", e);
                  }
                  sGetIBinderMethodFetched = true;
              }
              Method method2 = sGetIBinderMethod;
              if (method2 != null) {
                  try {
                      return (IBinder) method2.invoke(bundle, new Object[]{key});
                  } catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException e2) {
                      Log.i(TAG, "Failed to invoke getIBinder via reflection", e2);
                      sGetIBinderMethod = null;
                  }
              }
              return null;
          }
  
          public static void putBinder(Bundle bundle, String key, IBinder binder) {
              if (!sPutIBinderMethodFetched) {
                  try {
                      Method method = Bundle.class.getMethod("putIBinder", new Class[]{String.class, IBinder.class});
                      sPutIBinderMethod = method;
                      method.setAccessible(true);
                  } catch (NoSuchMethodException e) {
                      Log.i(TAG, "Failed to retrieve putIBinder method", e);
                  }
                  sPutIBinderMethodFetched = true;
              }
              Method method2 = sPutIBinderMethod;
              if (method2 != null) {
                  try {
                      method2.invoke(bundle, new Object[]{key, binder});
                  } catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException e2) {
                      Log.i(TAG, "Failed to invoke putIBinder via reflection", e2);
                      sPutIBinderMethod = null;
                  }
              }
          }
      }
  
      private BundleCompat() {
      }
  
      public static IBinder getBinder(Bundle bundle, String key) {
          return Build.VERSION.SDK_INT >= 18 ? Api18Impl.getBinder(bundle, key) : BeforeApi18Impl.getBinder(bundle, key);
      }
  
      public static void putBinder(Bundle bundle, String key, IBinder binder) {
          if (Build.VERSION.SDK_INT >= 18) {
              Api18Impl.putBinder(bundle, key, binder);
          } else {
              BeforeApi18Impl.putBinder(bundle, key, binder);
          }
      }
  }
  