package androidx.activity; import android.app.Activity; import android.view.View; import android.view.inputmethod.InputMethodManager; import androidx.lifecycle.AbstractC0424i; import androidx.lifecycle.InterfaceC0432k; import androidx.lifecycle.InterfaceC0434m; import java.lang.reflect.Field; /* loaded from: classes.dex */ final class ImmLeaksCleaner implements InterfaceC0432k { /* renamed from: b */ public static int f44b; /* renamed from: c */ public static Field f45c; /* renamed from: d */ public static Field f46d; /* renamed from: e */ public static Field f47e; /* renamed from: a */ public Activity f48a; public ImmLeaksCleaner(Activity activity) { this.f48a = activity; } /* renamed from: h */ public static void m5020h() { try { f44b = 2; Field declaredField = InputMethodManager.class.getDeclaredField("mServedView"); f46d = declaredField; declaredField.setAccessible(true); Field declaredField2 = InputMethodManager.class.getDeclaredField("mNextServedView"); f47e = declaredField2; declaredField2.setAccessible(true); Field declaredField3 = InputMethodManager.class.getDeclaredField("mH"); f45c = declaredField3; declaredField3.setAccessible(true); f44b = 1; } catch (NoSuchFieldException unused) { } } @Override // androidx.lifecycle.InterfaceC0432k /* renamed from: d */ public void mo472d(InterfaceC0434m interfaceC0434m, AbstractC0424i.EnumC0426b enumC0426b) { boolean isAttachedToWindow; if (enumC0426b != AbstractC0424i.EnumC0426b.ON_DESTROY) { return; } if (f44b == 0) { m5020h(); } if (f44b == 1) { InputMethodManager inputMethodManager = (InputMethodManager) this.f48a.getSystemService("input_method"); try { Object obj = f45c.get(inputMethodManager); if (obj == null) { return; } synchronized (obj) { try { try { View view = (View) f46d.get(inputMethodManager); if (view == null) { return; } isAttachedToWindow = view.isAttachedToWindow(); if (isAttachedToWindow) { return; } try { f47e.set(inputMethodManager, null); inputMethodManager.isActive(); } catch (IllegalAccessException unused) { } } catch (ClassCastException unused2) { } catch (IllegalAccessException unused3) { } } catch (Throwable th) { throw th; } } } catch (IllegalAccessException unused4) { } } } }