Initial commit
This commit is contained in:
73
sources/androidx/core/app/BundleCompat.java
Normal file
73
sources/androidx/core/app/BundleCompat.java
Normal file
@@ -0,0 +1,73 @@
|
||||
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;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public final class BundleCompat {
|
||||
public static IBinder a(Bundle bundle, String str) {
|
||||
return Build.VERSION.SDK_INT >= 18 ? bundle.getBinder(str) : BundleCompatBaseImpl.a(bundle, str);
|
||||
}
|
||||
|
||||
public static void a(Bundle bundle, String str, IBinder iBinder) {
|
||||
if (Build.VERSION.SDK_INT >= 18) {
|
||||
bundle.putBinder(str, iBinder);
|
||||
} else {
|
||||
BundleCompatBaseImpl.a(bundle, str, iBinder);
|
||||
}
|
||||
}
|
||||
|
||||
static class BundleCompatBaseImpl {
|
||||
private static Method a;
|
||||
private static boolean b;
|
||||
private static Method c;
|
||||
private static boolean d;
|
||||
|
||||
public static IBinder a(Bundle bundle, String str) {
|
||||
if (!b) {
|
||||
try {
|
||||
a = Bundle.class.getMethod("getIBinder", String.class);
|
||||
a.setAccessible(true);
|
||||
} catch (NoSuchMethodException e) {
|
||||
Log.i("BundleCompatBaseImpl", "Failed to retrieve getIBinder method", e);
|
||||
}
|
||||
b = true;
|
||||
}
|
||||
Method method = a;
|
||||
if (method != null) {
|
||||
try {
|
||||
return (IBinder) method.invoke(bundle, str);
|
||||
} catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException e2) {
|
||||
Log.i("BundleCompatBaseImpl", "Failed to invoke getIBinder via reflection", e2);
|
||||
a = null;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static void a(Bundle bundle, String str, IBinder iBinder) {
|
||||
if (!d) {
|
||||
try {
|
||||
c = Bundle.class.getMethod("putIBinder", String.class, IBinder.class);
|
||||
c.setAccessible(true);
|
||||
} catch (NoSuchMethodException e) {
|
||||
Log.i("BundleCompatBaseImpl", "Failed to retrieve putIBinder method", e);
|
||||
}
|
||||
d = true;
|
||||
}
|
||||
Method method = c;
|
||||
if (method != null) {
|
||||
try {
|
||||
method.invoke(bundle, str, iBinder);
|
||||
} catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException e2) {
|
||||
Log.i("BundleCompatBaseImpl", "Failed to invoke putIBinder via reflection", e2);
|
||||
c = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user