discord-jadx/app/src/main/java/androidx/core/app/BundleCompat.java

80 lines
3.0 KiB
Java

package androidx.core.app;
import android.os.Bundle;
import android.os.IBinder;
import android.util.Log;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
public final class BundleCompat {
public static class BundleCompatBaseImpl {
private static final String TAG = "BundleCompatBaseImpl";
private static Method sGetIBinderMethod;
private static boolean sGetIBinderMethodFetched;
private static Method sPutIBinderMethod;
private static boolean sPutIBinderMethodFetched;
private BundleCompatBaseImpl() {
}
public static IBinder getBinder(Bundle bundle, String str) {
if (!sGetIBinderMethodFetched) {
try {
Method method = Bundle.class.getMethod("getIBinder", String.class);
sGetIBinderMethod = method;
method.setAccessible(true);
} catch (NoSuchMethodException e) {
Log.i("BundleCompatBaseImpl", "Failed to retrieve getIBinder method", e);
}
sGetIBinderMethodFetched = true;
}
Method method2 = sGetIBinderMethod;
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);
sGetIBinderMethod = null;
}
}
return null;
}
public static void putBinder(Bundle bundle, String str, IBinder iBinder) {
if (!sPutIBinderMethodFetched) {
try {
Method method = Bundle.class.getMethod("putIBinder", String.class, IBinder.class);
sPutIBinderMethod = method;
method.setAccessible(true);
} catch (NoSuchMethodException e) {
Log.i("BundleCompatBaseImpl", "Failed to retrieve putIBinder method", e);
}
sPutIBinderMethodFetched = true;
}
Method method2 = sPutIBinderMethod;
if (method2 != null) {
try {
method2.invoke(bundle, str, iBinder);
} catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException e2) {
Log.i("BundleCompatBaseImpl", "Failed to invoke putIBinder via reflection", e2);
sPutIBinderMethod = null;
}
}
}
}
private BundleCompat() {
}
@Nullable
public static IBinder getBinder(@NonNull Bundle bundle, @Nullable String str) {
return bundle.getBinder(str);
}
public static void putBinder(@NonNull Bundle bundle, @Nullable String str, @Nullable IBinder iBinder) {
bundle.putBinder(str, iBinder);
}
}