From 6a5b0a367389a8aa57cb1c82cd3d63f1ca67cc66 Mon Sep 17 00:00:00 2001 From: Adam Powell Date: Fri, 28 Sep 2012 14:24:48 -0700 Subject: [PATCH] Don't try to open action bar overflow menus from bogus events Some monkey tests could hit a case where a posted overflow button click event was still lingering after the menu was no longer in a created state, which could lead apps to crash. Just drop open-overflow requests on the floor if the menu is in a weird state when we try. Bug 7242431 Change-Id: Ieebb1fccfeeccbf17fd7c6cff06efbcb19b11ce3 --- .../src/com/android/internal/policy/impl/PhoneWindow.java | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/policy/src/com/android/internal/policy/impl/PhoneWindow.java b/policy/src/com/android/internal/policy/impl/PhoneWindow.java index bba2c7fd8b6b0..72cb1ddf1c60d 100644 --- a/policy/src/com/android/internal/policy/impl/PhoneWindow.java +++ b/policy/src/com/android/internal/policy/impl/PhoneWindow.java @@ -993,7 +993,11 @@ public class PhoneWindow extends Window implements MenuBuilder.Callback { if (!mActionBar.isOverflowMenuShowing() || !toggleMenuMode) { if (cb != null && !isDestroyed() && mActionBar.getVisibility() == View.VISIBLE) { final PanelFeatureState st = getPanelState(FEATURE_OPTIONS_PANEL, true); - if (cb.onPreparePanel(FEATURE_OPTIONS_PANEL, st.createdPanelView, st.menu)) { + + // If we don't have a menu or we're waiting for a full content refresh, + // forget it. This is a lingering event that no longer matters. + if (st.menu != null && !st.refreshMenuContent && + cb.onPreparePanel(FEATURE_OPTIONS_PANEL, st.createdPanelView, st.menu)) { cb.onMenuOpened(FEATURE_ACTION_BAR, st.menu); mActionBar.showOverflowMenu(); }