package o; import android.app.Activity; import android.app.Application; import android.content.res.Configuration; import android.os.Build; import android.os.Bundle; import android.os.Handler; import android.os.IBinder; import android.os.Looper; import java.lang.reflect.Field; import java.lang.reflect.Method; import java.util.List; /* renamed from: o.Epo, reason: case insensitive filesystem */ /* loaded from: classes.dex */ public final class C0348Epo { protected static final Method a; private static final Handler b = new Handler(Looper.getMainLooper()); private static Field c; protected static final Method d; private static Method e; private static Field j; static { Class c2 = c(); c = b(); j = a(); d = a(c2); a = d(c2); e = c(c2); } public static boolean mh_(Activity activity) { Object obj; if (Build.VERSION.SDK_INT >= 28) { activity.recreate(); return true; } if ((Build.VERSION.SDK_INT == 26 || Build.VERSION.SDK_INT == 27) && e == null) { return false; } if (a == null && d == null) { return false; } try { Object obj2 = j.get(activity); if (obj2 == null || (obj = c.get(activity)) == null) { return false; } Application application = activity.getApplication(); LWm lWm = new LWm(activity); application.registerActivityLifecycleCallbacks(lWm); Handler handler = b; handler.post(new Runnable(lWm, obj2) { // from class: o.Epo.3 final Object b; final LWm c; { this.c = lWm; this.b = obj2; } @Override // java.lang.Runnable public final void run() { this.c.a = this.b; } }); try { if (Build.VERSION.SDK_INT == 26 || Build.VERSION.SDK_INT == 27) { e.invoke(obj, obj2, null, null, 0, Boolean.FALSE, null, null, Boolean.FALSE, Boolean.FALSE); } else { activity.recreate(); } handler.post(new Runnable(application, lWm) { // from class: o.Epo.1 final LWm b; final Application d; { this.d = application; this.b = lWm; } @Override // java.lang.Runnable public final void run() { this.d.unregisterActivityLifecycleCallbacks(this.b); } }); return true; } catch (Throwable th) { b.post(new Runnable(application, lWm) { // from class: o.Epo.1 final LWm b; final Application d; { this.d = application; this.b = lWm; } @Override // java.lang.Runnable public final void run() { this.d.unregisterActivityLifecycleCallbacks(this.b); } }); throw th; } } catch (Throwable unused) { return false; } } /* renamed from: o.Epo$LWm */ /* loaded from: classes.dex */ static final class LWm implements Application.ActivityLifecycleCallbacks { Object a; private Activity c; private final int d; private boolean b = false; private boolean e = false; private boolean g = false; @Override // android.app.Application.ActivityLifecycleCallbacks public final void onActivityCreated(Activity activity, Bundle bundle) { } @Override // android.app.Application.ActivityLifecycleCallbacks public final void onActivityResumed(Activity activity) { } @Override // android.app.Application.ActivityLifecycleCallbacks public final void onActivitySaveInstanceState(Activity activity, Bundle bundle) { } @Override // android.app.Application.ActivityLifecycleCallbacks public final void onActivityStopped(Activity activity) { } LWm(Activity activity) { this.c = activity; this.d = activity.hashCode(); } @Override // android.app.Application.ActivityLifecycleCallbacks public final void onActivityPaused(Activity activity) { if (!this.e || this.g || this.b || !C0348Epo.mg_(this.a, this.d, activity)) { return; } this.g = true; this.a = null; } @Override // android.app.Application.ActivityLifecycleCallbacks public final void onActivityStarted(Activity activity) { if (this.c == activity) { this.b = true; } } @Override // android.app.Application.ActivityLifecycleCallbacks public final void onActivityDestroyed(Activity activity) { if (this.c == activity) { this.c = null; this.e = true; } } } protected static boolean mg_(Object obj, int i, Activity activity) { try { Object obj2 = j.get(activity); if (obj2 == obj && activity.hashCode() == i) { b.postAtFrontOfQueue(new Runnable(c.get(activity), obj2) { // from class: o.Epo.4 final Object a; final Object c; { this.c = r1; this.a = obj2; } @Override // java.lang.Runnable public final void run() { try { if (C0348Epo.d != null) { C0348Epo.d.invoke(this.c, this.a, Boolean.FALSE, "AppCompat recreation"); } else { C0348Epo.a.invoke(this.c, this.a, Boolean.FALSE); } } catch (RuntimeException e2) { if (e2.getClass() == RuntimeException.class && e2.getMessage() != null && e2.getMessage().startsWith("Unable to stop")) { throw e2; } } catch (Throwable unused) { } } }); return true; } } catch (Throwable unused) { } return false; } private static Method a(Class cls) { if (cls == null) { return null; } try { Method declaredMethod = cls.getDeclaredMethod("performStopActivity", IBinder.class, Boolean.TYPE, String.class); declaredMethod.setAccessible(true); return declaredMethod; } catch (Throwable unused) { return null; } } private static Method d(Class cls) { if (cls == null) { return null; } try { Method declaredMethod = cls.getDeclaredMethod("performStopActivity", IBinder.class, Boolean.TYPE); declaredMethod.setAccessible(true); return declaredMethod; } catch (Throwable unused) { return null; } } private static Field b() { try { Field declaredField = Activity.class.getDeclaredField("mMainThread"); declaredField.setAccessible(true); return declaredField; } catch (Throwable unused) { return null; } } private static Field a() { try { Field declaredField = Activity.class.getDeclaredField("mToken"); declaredField.setAccessible(true); return declaredField; } catch (Throwable unused) { return null; } } private static Class c() { try { return Class.forName("android.app.ActivityThread"); } catch (Throwable unused) { return null; } } private static Method c(Class cls) { if ((Build.VERSION.SDK_INT != 26 && Build.VERSION.SDK_INT != 27) || cls == null) { return null; } try { Method declaredMethod = cls.getDeclaredMethod("requestRelaunchActivity", IBinder.class, List.class, List.class, Integer.TYPE, Boolean.TYPE, Configuration.class, Configuration.class, Boolean.TYPE, Boolean.TYPE); declaredMethod.setAccessible(true); return declaredMethod; } catch (Throwable unused) { return null; } } }