package X6FRs_4.IMuAHx_6.Mqv2r_3;

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;
/* compiled from: BundleCompat.java */
/* loaded from: classes.dex */
public final class PGPF6hQ_2 {
    public static IBinder KQgRr5e_0(Bundle bundle, String str) {
        if (Build.VERSION.SDK_INT >= 18) {
            return bundle.getBinder(str);
        }
        return KQgRr5e_0.KQgRr5e_0(bundle, str);
    }

    public static void KQgRr5e_0(Bundle bundle, String str, IBinder iBinder) {
        if (Build.VERSION.SDK_INT >= 18) {
            bundle.putBinder(str, iBinder);
        } else {
            KQgRr5e_0.KQgRr5e_0(bundle, str, iBinder);
        }
    }

    /* compiled from: BundleCompat.java */
    /* loaded from: classes.dex */
    public static class KQgRr5e_0 {
        public static Method KQgRr5e_0;

        /* renamed from: KQgRr5e_0  reason: collision with other field name */
        public static boolean f466KQgRr5e_0;
        public static Method QxJ9d_1;

        /* renamed from: QxJ9d_1  reason: collision with other field name */
        public static boolean f467QxJ9d_1;

        public static IBinder KQgRr5e_0(Bundle bundle, String str) {
            if (!f466KQgRr5e_0) {
                try {
                    Method method = Bundle.class.getMethod("getIBinder", String.class);
                    KQgRr5e_0 = method;
                    method.setAccessible(true);
                } catch (NoSuchMethodException e) {
                    Log.i("BundleCompatBaseImpl", "Failed to retrieve getIBinder method", e);
                }
                f466KQgRr5e_0 = true;
            }
            Method method2 = KQgRr5e_0;
            if (method2 != null) {
                try {
                    return (IBinder) method2.invoke(bundle, str);
                } catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException e2) {
                    Log.i("BundleCompatBaseImpl", "Failed to invoke getIBinder via reflection", e2);
                    KQgRr5e_0 = null;
                }
            }
            return null;
        }

        public static void KQgRr5e_0(Bundle bundle, String str, IBinder iBinder) {
            if (!f467QxJ9d_1) {
                try {
                    Method method = Bundle.class.getMethod("putIBinder", String.class, IBinder.class);
                    QxJ9d_1 = method;
                    method.setAccessible(true);
                } catch (NoSuchMethodException e) {
                    Log.i("BundleCompatBaseImpl", "Failed to retrieve putIBinder method", e);
                }
                f467QxJ9d_1 = true;
            }
            Method method2 = QxJ9d_1;
            if (method2 != null) {
                try {
                    method2.invoke(bundle, str, iBinder);
                } catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException e2) {
                    Log.i("BundleCompatBaseImpl", "Failed to invoke putIBinder via reflection", e2);
                    QxJ9d_1 = null;
                }
            }
        }
    }
}
