package androidx.activity;

import android.app.Activity;
import android.view.View;
import android.view.inputmethod.InputMethodManager;
import androidx.lifecycle.Lifecycle;
import java.lang.reflect.Field;
import ῲ.ؿ.AbstractC1569;
import ῲ.ؿ.AbstractC1574;

public final class ImmLeaksCleaner implements AbstractC1569 {

    /* renamed from: ʬ  reason: contains not printable characters */
    public static Field f128;

    /* renamed from: ඓ  reason: contains not printable characters */
    public static Field f129;

    /* renamed from: ῲ  reason: contains not printable characters */
    public static int f130;

    /* renamed from: 㸾  reason: contains not printable characters */
    public static Field f131;

    /* renamed from: K  reason: contains not printable characters */
    public Activity f132;

    public ImmLeaksCleaner(Activity activity) {
        this.f132 = activity;
    }

    @Override // ῲ.ؿ.AbstractC1569
    /* renamed from: K  reason: contains not printable characters */
    public void m120(AbstractC1574 r3, Lifecycle.Event event) {
        if (event == Lifecycle.Event.ON_DESTROY) {
            if (f130 == 0) {
                try {
                    f130 = 2;
                    f131 = InputMethodManager.class.getDeclaredField("mServedView");
                    f131.setAccessible(true);
                    f129 = InputMethodManager.class.getDeclaredField("mNextServedView");
                    f129.setAccessible(true);
                    f128 = InputMethodManager.class.getDeclaredField("mH");
                    f128.setAccessible(true);
                    f130 = 1;
                } catch (NoSuchFieldException unused) {
                }
            }
            if (f130 == 1) {
                InputMethodManager inputMethodManager = (InputMethodManager) this.f132.getSystemService("input_method");
                try {
                    Object obj = f128.get(inputMethodManager);
                    if (obj != null) {
                        synchronized (obj) {
                            try {
                                View view = (View) f131.get(inputMethodManager);
                                if (view != null) {
                                    if (!view.isAttachedToWindow()) {
                                        try {
                                            f129.set(inputMethodManager, null);
                                            inputMethodManager.isActive();
                                        } catch (IllegalAccessException unused2) {
                                        }
                                    }
                                }
                            } catch (IllegalAccessException unused3) {
                            } catch (ClassCastException unused4) {
                            }
                        }
                    }
                } catch (IllegalAccessException unused5) {
                }
            }
        }
    }
}
