package p023h0; import android.app.ActionBar; 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: h0.s */ /* loaded from: classes.dex */ public class C0944s { /* renamed from: a */ public static boolean f2494a = false; /* renamed from: b */ public static Method f2495b = null; /* renamed from: c */ public static boolean f2496c = false; /* renamed from: d */ public static Field f2497d; /* renamed from: h0.s$a */ /* loaded from: classes.dex */ public interface InterfaceC0945a { /* renamed from: f */ boolean mo420f(KeyEvent keyEvent); } /* renamed from: a */ public static boolean m2502a(ActionBar actionBar, KeyEvent keyEvent) { if (!f2494a) { try { f2495b = actionBar.getClass().getMethod("onMenuKeyEvent", KeyEvent.class); } catch (NoSuchMethodException unused) { } f2494a = true; } Method method = f2495b; if (method != null) { try { Object invoke = method.invoke(actionBar, keyEvent); if (invoke == null) { return false; } return ((Boolean) invoke).booleanValue(); } catch (IllegalAccessException | InvocationTargetException unused2) { } } return false; } /* renamed from: b */ public static boolean m2501b(Activity activity, KeyEvent keyEvent) { activity.onUserInteraction(); Window window = activity.getWindow(); if (window.hasFeature(8)) { ActionBar actionBar = activity.getActionBar(); if (keyEvent.getKeyCode() == 82 && actionBar != null && m2502a(actionBar, keyEvent)) { return true; } } if (window.superDispatchKeyEvent(keyEvent)) { return true; } View decorView = window.getDecorView(); if (C0829h1.m2828f(decorView, keyEvent)) { return true; } return keyEvent.dispatch(activity, decorView != null ? decorView.getKeyDispatcherState() : null, activity); } /* renamed from: c */ public static boolean m2500c(Dialog dialog, KeyEvent keyEvent) { DialogInterface.OnKeyListener m2497f = m2497f(dialog); if (m2497f == null || !m2497f.onKey(dialog, keyEvent.getKeyCode(), keyEvent)) { Window window = dialog.getWindow(); if (window.superDispatchKeyEvent(keyEvent)) { return true; } View decorView = window.getDecorView(); if (C0829h1.m2828f(decorView, keyEvent)) { return true; } return keyEvent.dispatch(dialog, decorView != null ? decorView.getKeyDispatcherState() : null, dialog); } return true; } /* renamed from: d */ public static boolean m2499d(View view, KeyEvent keyEvent) { return C0829h1.m2827g(view, keyEvent); } /* renamed from: e */ public static boolean m2498e(InterfaceC0945a interfaceC0945a, View view, Window.Callback callback, KeyEvent keyEvent) { if (interfaceC0945a == null) { return false; } return Build.VERSION.SDK_INT >= 28 ? interfaceC0945a.mo420f(keyEvent) : callback instanceof Activity ? m2501b((Activity) callback, keyEvent) : callback instanceof Dialog ? m2500c((Dialog) callback, keyEvent) : (view != null && C0829h1.m2828f(view, keyEvent)) || interfaceC0945a.mo420f(keyEvent); } /* renamed from: f */ public static DialogInterface.OnKeyListener m2497f(Dialog dialog) { if (!f2496c) { try { Field declaredField = Dialog.class.getDeclaredField("mOnKeyListener"); f2497d = declaredField; declaredField.setAccessible(true); } catch (NoSuchFieldException unused) { } f2496c = true; } Field field = f2497d; if (field != null) { try { return (DialogInterface.OnKeyListener) field.get(dialog); } catch (IllegalAccessException unused2) { return null; } } return null; } }