package ῲ.ᨨ.ᨨ;

import android.app.Activity;
import android.app.Dialog;
import android.content.DialogInterface;
import android.os.Build;
import android.view.KeyEvent;
import android.view.View;
import android.view.Window;
import java.lang.reflect.Field;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;

/* renamed from: ῲ.ᨨ.ᨨ.㸾  reason: contains not printable characters */
/* compiled from: KeyEventDispatcher */
public class C1773 {

    /* renamed from: ʬ  reason: contains not printable characters */
    public static boolean f6110 = false;

    /* renamed from: ῲ  reason: contains not printable characters */
    public static Method f6111 = null;

    /* renamed from: K  reason: contains not printable characters */
    public static boolean f6112 = false;

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

    /* renamed from: ῲ.ᨨ.ᨨ.㸾$K  reason: contains not printable characters */
    /* compiled from: KeyEventDispatcher */
    public interface AbstractC1774 {
        boolean superDispatchKeyEvent(KeyEvent keyEvent);
    }

    /* JADX WARNING: Removed duplicated region for block: B:53:0x00bf  */
    /* JADX WARNING: Removed duplicated region for block: B:70:? A[RETURN, SYNTHETIC] */
    /* renamed from: K  reason: contains not printable characters */
    public static boolean m4623(AbstractC1774 k, View view, Window.Callback callback, KeyEvent keyEvent) {
        DialogInterface.OnKeyListener onKeyListener;
        Window window;
        boolean z = false;
        if (k == null) {
            return false;
        }
        if (Build.VERSION.SDK_INT >= 28) {
            return k.superDispatchKeyEvent(keyEvent);
        }
        KeyEvent.DispatcherState dispatcherState = null;
        if (callback instanceof Activity) {
            Activity activity = (Activity) callback;
            activity.onUserInteraction();
            Window window2 = activity.getWindow();
            if (window2.hasFeature(8)) {
                Object actionBar = activity.getActionBar();
                if (keyEvent.getKeyCode() == 82 && actionBar != null) {
                    if (!f6112) {
                        try {
                            f6111 = actionBar.getClass().getMethod("onMenuKeyEvent", KeyEvent.class);
                        } catch (NoSuchMethodException unused) {
                        }
                        f6112 = true;
                    }
                    Method method = f6111;
                    if (method != null) {
                        try {
                            z = ((Boolean) method.invoke(actionBar, keyEvent)).booleanValue();
                        } catch (IllegalAccessException | InvocationTargetException unused2) {
                        }
                    }
                    if (z) {
                        return true;
                    }
                }
            }
            if (window2.superDispatchKeyEvent(keyEvent)) {
                return true;
            }
            View decorView = window2.getDecorView();
            if (C1729.m4491(decorView, keyEvent)) {
                return true;
            }
            if (decorView != null) {
                dispatcherState = decorView.getKeyDispatcherState();
            }
            return keyEvent.dispatch(activity, dispatcherState, activity);
        } else if (callback instanceof Dialog) {
            Dialog dialog = (Dialog) callback;
            if (!f6110) {
                try {
                    f6113 = Dialog.class.getDeclaredField("mOnKeyListener");
                    f6113.setAccessible(true);
                } catch (NoSuchFieldException unused3) {
                }
                f6110 = true;
            }
            Field field = f6113;
            if (field != null) {
                try {
                    onKeyListener = (DialogInterface.OnKeyListener) field.get(dialog);
                } catch (IllegalAccessException unused4) {
                }
                if (onKeyListener == null && onKeyListener.onKey(dialog, keyEvent.getKeyCode(), keyEvent)) {
                    return true;
                }
                window = dialog.getWindow();
                if (!window.superDispatchKeyEvent(keyEvent)) {
                    return true;
                }
                View decorView2 = window.getDecorView();
                if (C1729.m4491(decorView2, keyEvent)) {
                    return true;
                }
                if (decorView2 != null) {
                    dispatcherState = decorView2.getKeyDispatcherState();
                }
                return keyEvent.dispatch(dialog, dispatcherState, dialog);
            }
            onKeyListener = null;
            if (onKeyListener == null) {
            }
            window = dialog.getWindow();
            if (!window.superDispatchKeyEvent(keyEvent)) {
            }
        } else if ((view == null || !C1729.m4491(view, keyEvent)) && !k.superDispatchKeyEvent(keyEvent)) {
            return false;
        } else {
            return true;
        }
    }
}
