From 8a009498bfca64556c2082cbb32f68506d6962db Mon Sep 17 00:00:00 2001 From: Michael Kolb Date: Mon, 15 Aug 2011 15:37:30 -0700 Subject: Fix monkey bug Bug: 5166733 added missing return statements and valid active tab check Change-Id: Ida7ffa6faf77a95eaf19ef566176ad522be4efef --- src/com/android/browser/Controller.java | 19 ++++++++++++++----- src/com/android/browser/PhoneUi.java | 2 ++ 2 files changed, 16 insertions(+), 5 deletions(-) (limited to 'src/com') diff --git a/src/com/android/browser/Controller.java b/src/com/android/browser/Controller.java index 3f126c0..24072c9 100644 --- a/src/com/android/browser/Controller.java +++ b/src/com/android/browser/Controller.java @@ -2684,23 +2684,32 @@ public class Controller } public boolean dispatchKeyEvent(KeyEvent event) { - return mBlockEvents; + return mBlockEvents || hasNoActiveTab(); } public boolean dispatchKeyShortcutEvent(KeyEvent event) { - return mBlockEvents; + return mBlockEvents || hasNoActiveTab(); } public boolean dispatchTouchEvent(MotionEvent ev) { - return mBlockEvents; + return mBlockEvents || hasNoActiveTab(); } public boolean dispatchTrackballEvent(MotionEvent ev) { - return mBlockEvents; + return mBlockEvents || hasNoActiveTab(); } public boolean dispatchGenericMotionEvent(MotionEvent ev) { - return mBlockEvents; + return mBlockEvents || hasNoActiveTab(); + } + + private boolean hasNoActiveTab() { + Tab tab = getCurrentTab(); + if (tab == null) { + Log.w(LOGTAG, "Received event with no active tab. Tab count: " + + mTabControl.getTabCount()); + } + return tab == null; } } diff --git a/src/com/android/browser/PhoneUi.java b/src/com/android/browser/PhoneUi.java index d77fcdb..23d7abb 100644 --- a/src/com/android/browser/PhoneUi.java +++ b/src/com/android/browser/PhoneUi.java @@ -329,10 +329,12 @@ public class PhoneUi extends BaseUi { final Tab tab = mNavScreen.getSelectedTab(); if ((tab != null) && !animate) { finishAnimateOut(tab); + return; } NavTabView tabview = (NavTabView) mNavScreen.getSelectedTabView(); if (tabview == null) { finishAnimateOut(tab); + return; } mUiController.setBlockEvents(true); mUiController.setActiveTab(tab); -- cgit v1.1