Fixes #1937447. Home was not saving the appropriate state when losing focus.
diff --git a/src/com/android/launcher/Launcher.java b/src/com/android/launcher/Launcher.java
index 2e72818..328a5ca 100644
--- a/src/com/android/launcher/Launcher.java
+++ b/src/com/android/launcher/Launcher.java
@@ -519,6 +519,8 @@
             mRestoring = true;
         }
 
+        mCurrentGesture = (Gesture) savedState.get(RUNTIME_STATE_PENDING_GESTURE);
+
         boolean gesturesShowing = savedState.getBoolean(RUNTIME_STATE_GESTURES_PANEL, false);
         if (gesturesShowing) {
             final Gesture gesture = (Gesture) savedState.get(RUNTIME_STATE_GESTURES_PANEL_GESTURE);
@@ -536,8 +538,6 @@
                 }
             });
         }
-
-        mCurrentGesture = (Gesture) savedState.get(RUNTIME_STATE_PENDING_GESTURE);
     }
 
     /**
@@ -1056,12 +1056,14 @@
             outState.putParcelable(RUNTIME_STATE_PENDING_GESTURE, mCurrentGesture);
         }
 
-        if (mGesturesWindow != null && mGesturesWindow.isShowing() && isConfigurationChange) {
+        if (mGesturesWindow != null && mGesturesWindow.isShowing()) {
             outState.putBoolean(RUNTIME_STATE_GESTURES_PANEL, true);
 
-            final Gesture gesture = mGesturesOverlay.getGesture();
-            if (gesture != null) {
-                outState.putParcelable(RUNTIME_STATE_GESTURES_PANEL_GESTURE, gesture);
+            if (mCurrentGesture == null || !mWaitingForResult) {
+                final Gesture gesture = mGesturesOverlay.getGesture();
+                if (gesture != null) {
+                    outState.putParcelable(RUNTIME_STATE_GESTURES_PANEL_GESTURE, gesture);
+                }
             }
         }
     }
@@ -2427,6 +2429,10 @@
                 mMatcher.gesture = overlay.getGesture();
                 if (mMatcher.gesture.getLength() < GesturesConstants.LENGTH_THRESHOLD) {
                     overlay.clear(false);
+                    if (mGesturesAction.intent != null) {
+                        mGesturesAction.intent = null;
+                        setGesturesNextPrompt(null, getString(R.string.gestures_unknown));
+                    }
                 } else {
                     mMatcher.run();
                 }
@@ -2436,6 +2442,10 @@
                 mMatcher.gesture = overlay.getGesture();
                 if (mMatcher.gesture.getLength() < GesturesConstants.LENGTH_THRESHOLD) {
                     overlay.clear(false);
+                    if (mGesturesAction.intent != null) {
+                        mGesturesAction.intent = null;
+                        setGesturesNextPrompt(null, getString(R.string.gestures_unknown));
+                    }
                 } else {
                     overlay.postDelayed(mMatcher, GesturesConstants.MATCH_DELAY);
                 }
@@ -2473,6 +2483,7 @@
                 }
 
                 if (!match){
+                    mGesturesAction.intent = null;
                     if (animate) {
                         setGesturesNextPrompt(null, getString(R.string.gestures_unknown));
                     } else {
@@ -2488,7 +2499,7 @@
 
         private void updatePrompt(ApplicationInfo info, boolean animate) {
             if (mGesturesAction.intent != null &&
-                    info.intent.toURI().equals(mGesturesAction.intent.toURI()) &&
+                    info.intent.toUri(0).equals(mGesturesAction.intent.toUri(0)) &&
                     info.title.equals(((TextView) mGesturesPrompt.getCurrentView()).getText())) {
                 return;
             }