package okhttp3.internal.platform.android; import java.lang.reflect.Method; import o.C14953gcr; import o.C14957gcv; /* loaded from: classes.dex */ public final class CloseGuard { public static final Companion Companion = new Companion(null); private final Method getMethod; private final Method openMethod; private final Method warnIfOpenMethod; public CloseGuard(Method method, Method method2, Method method3) { this.getMethod = method; this.openMethod = method2; this.warnIfOpenMethod = method3; } public final Object createAndOpen(String str) { C14957gcv.e(str, ""); Method method = this.getMethod; if (method != null) { try { Object invoke = method.invoke(null, new Object[0]); Method method2 = this.openMethod; C14957gcv.e(method2); method2.invoke(invoke, str); return invoke; } catch (Exception unused) { } } return null; } public final boolean warnIfOpen(Object obj) { if (obj == null) { return false; } try { Method method = this.warnIfOpenMethod; C14957gcv.e(method); method.invoke(obj, new Object[0]); return true; } catch (Exception unused) { return false; } } /* loaded from: classes.dex */ public static final class Companion { private Companion() { } public final CloseGuard get() { Method method; Method method2; Method method3; try { Class cls = Class.forName("dalvik.system.CloseGuard"); method = cls.getMethod("get", new Class[0]); method3 = cls.getMethod("open", String.class); method2 = cls.getMethod("warnIfOpen", new Class[0]); } catch (Exception unused) { method = null; method2 = null; method3 = null; } return new CloseGuard(method, method3, method2); } public /* synthetic */ Companion(C14953gcr c14953gcr) { this(); } } }