You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

325 lines
9.8 KiB

package p067w;
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 android.util.Log;
import java.lang.reflect.Field;
import java.lang.reflect.Method;
import java.util.List;
/* renamed from: w.c */
/* loaded from: classes.dex */
public final class C1767c {
/* renamed from: a */
public static final Class<?> f4482a;
/* renamed from: b */
public static final Field f4483b;
/* renamed from: c */
public static final Field f4484c;
/* renamed from: d */
public static final Method f4485d;
/* renamed from: e */
public static final Method f4486e;
/* renamed from: f */
public static final Method f4487f;
/* renamed from: g */
public static final Handler f4488g = new Handler(Looper.getMainLooper());
/* renamed from: w.c$a */
/* loaded from: classes.dex */
public class RunnableC1768a implements Runnable {
/* renamed from: d */
public final /* synthetic */ C1771d f4489d;
/* renamed from: e */
public final /* synthetic */ Object f4490e;
public RunnableC1768a(C1771d c1771d, Object obj) {
this.f4489d = c1771d;
this.f4490e = obj;
}
@Override // java.lang.Runnable
public void run() {
this.f4489d.f4495a = this.f4490e;
}
}
/* renamed from: w.c$b */
/* loaded from: classes.dex */
public class RunnableC1769b implements Runnable {
/* renamed from: d */
public final /* synthetic */ Application f4491d;
/* renamed from: e */
public final /* synthetic */ C1771d f4492e;
public RunnableC1769b(Application application, C1771d c1771d) {
this.f4491d = application;
this.f4492e = c1771d;
}
@Override // java.lang.Runnable
public void run() {
this.f4491d.unregisterActivityLifecycleCallbacks(this.f4492e);
}
}
/* renamed from: w.c$c */
/* loaded from: classes.dex */
public class RunnableC1770c implements Runnable {
/* renamed from: d */
public final /* synthetic */ Object f4493d;
/* renamed from: e */
public final /* synthetic */ Object f4494e;
public RunnableC1770c(Object obj, Object obj2) {
this.f4493d = obj;
this.f4494e = obj2;
}
@Override // java.lang.Runnable
public void run() {
try {
Method method = C1767c.f4485d;
if (method != null) {
method.invoke(this.f4493d, this.f4494e, Boolean.FALSE, "AppCompat recreation");
} else {
C1767c.f4486e.invoke(this.f4493d, this.f4494e, Boolean.FALSE);
}
} catch (RuntimeException e) {
if (e.getClass() == RuntimeException.class && e.getMessage() != null && e.getMessage().startsWith("Unable to stop")) {
throw e;
}
} catch (Throwable th) {
Log.e("ActivityRecreator", "Exception while invoking performStopActivity", th);
}
}
}
/* renamed from: w.c$d */
/* loaded from: classes.dex */
public static final class C1771d implements Application.ActivityLifecycleCallbacks {
/* renamed from: a */
public Object f4495a;
/* renamed from: b */
public Activity f4496b;
/* renamed from: c */
public final int f4497c;
/* renamed from: d */
public boolean f4498d = false;
/* renamed from: e */
public boolean f4499e = false;
/* renamed from: f */
public boolean f4500f = false;
public C1771d(Activity activity) {
this.f4496b = activity;
this.f4497c = activity.hashCode();
}
@Override // android.app.Application.ActivityLifecycleCallbacks
public void onActivityCreated(Activity activity, Bundle bundle) {
}
@Override // android.app.Application.ActivityLifecycleCallbacks
public void onActivityDestroyed(Activity activity) {
if (this.f4496b == activity) {
this.f4496b = null;
this.f4499e = true;
}
}
@Override // android.app.Application.ActivityLifecycleCallbacks
public void onActivityPaused(Activity activity) {
if (!this.f4499e || this.f4500f || this.f4498d || !C1767c.m438h(this.f4495a, this.f4497c, activity)) {
return;
}
this.f4500f = true;
this.f4495a = null;
}
@Override // android.app.Application.ActivityLifecycleCallbacks
public void onActivityResumed(Activity activity) {
}
@Override // android.app.Application.ActivityLifecycleCallbacks
public void onActivitySaveInstanceState(Activity activity, Bundle bundle) {
}
@Override // android.app.Application.ActivityLifecycleCallbacks
public void onActivityStarted(Activity activity) {
if (this.f4496b == activity) {
this.f4498d = true;
}
}
@Override // android.app.Application.ActivityLifecycleCallbacks
public void onActivityStopped(Activity activity) {
}
}
static {
Class<?> m445a = m445a();
f4482a = m445a;
f4483b = m444b();
f4484c = m440f();
f4485d = m442d(m445a);
f4486e = m443c(m445a);
f4487f = m441e(m445a);
}
/* renamed from: a */
public static Class<?> m445a() {
try {
return Class.forName("android.app.ActivityThread");
} catch (Throwable unused) {
return null;
}
}
/* renamed from: b */
public static Field m444b() {
try {
Field declaredField = Activity.class.getDeclaredField("mMainThread");
declaredField.setAccessible(true);
return declaredField;
} catch (Throwable unused) {
return null;
}
}
/* renamed from: c */
public static Method m443c(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;
}
}
/* renamed from: d */
public static Method m442d(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;
}
}
/* renamed from: e */
public static Method m441e(Class<?> cls) {
if (m439g() && cls != null) {
try {
Class<?> cls2 = Boolean.TYPE;
Method declaredMethod = cls.getDeclaredMethod("requestRelaunchActivity", IBinder.class, List.class, List.class, Integer.TYPE, cls2, Configuration.class, Configuration.class, cls2, cls2);
declaredMethod.setAccessible(true);
return declaredMethod;
} catch (Throwable unused) {
}
}
return null;
}
/* renamed from: f */
public static Field m440f() {
try {
Field declaredField = Activity.class.getDeclaredField("mToken");
declaredField.setAccessible(true);
return declaredField;
} catch (Throwable unused) {
return null;
}
}
/* renamed from: g */
public static boolean m439g() {
int i = Build.VERSION.SDK_INT;
return i == 26 || i == 27;
}
/* renamed from: h */
public static boolean m438h(Object obj, int i, Activity activity) {
try {
Object obj2 = f4484c.get(activity);
if (obj2 == obj && activity.hashCode() == i) {
f4488g.postAtFrontOfQueue(new RunnableC1770c(f4483b.get(activity), obj2));
return true;
}
return false;
} catch (Throwable th) {
Log.e("ActivityRecreator", "Exception while fetching field values", th);
return false;
}
}
/* renamed from: i */
public static boolean m437i(Activity activity) {
Object obj;
if (Build.VERSION.SDK_INT >= 28) {
activity.recreate();
return true;
} else if (m439g() && f4487f == null) {
return false;
} else {
if (f4486e == null && f4485d == null) {
return false;
}
try {
Object obj2 = f4484c.get(activity);
if (obj2 == null || (obj = f4483b.get(activity)) == null) {
return false;
}
Application application = activity.getApplication();
C1771d c1771d = new C1771d(activity);
application.registerActivityLifecycleCallbacks(c1771d);
Handler handler = f4488g;
handler.post(new RunnableC1768a(c1771d, obj2));
if (m439g()) {
Method method = f4487f;
Boolean bool = Boolean.FALSE;
method.invoke(obj, obj2, null, null, 0, bool, null, null, bool, bool);
} else {
activity.recreate();
}
handler.post(new RunnableC1769b(application, c1771d));
return true;
} catch (Throwable unused) {
return false;
}
}
}
}