Merge "Fixes around extract mode"
diff --git a/core/java/android/inputmethodservice/ExtractEditText.java b/core/java/android/inputmethodservice/ExtractEditText.java
index 10c1195..23ae21b 100644
--- a/core/java/android/inputmethodservice/ExtractEditText.java
+++ b/core/java/android/inputmethodservice/ExtractEditText.java
@@ -100,6 +100,9 @@
     
     @Override public boolean onTextContextMenuItem(int id) {
         if (mIME != null && mIME.onExtractTextContextMenuItem(id)) {
+            // Mode was started on Extracted, needs to be stopped here.
+            // Cut and paste will change the text, which stops selection mode.
+            if (id == android.R.id.copy) stopSelectionActionMode();
             return true;
         }
         return super.onTextContextMenuItem(id);
diff --git a/core/java/android/widget/TextView.java b/core/java/android/widget/TextView.java
index 02144a8..c3b54f4 100644
--- a/core/java/android/widget/TextView.java
+++ b/core/java/android/widget/TextView.java
@@ -5273,10 +5273,8 @@
                         state.handleUpEvent(event);
                     }
                     if (event.isTracking() && !event.isCanceled()) {
-                        if (isInSelectionMode) {
-                            stopSelectionActionMode();
-                            return true;
-                        }
+                        stopSelectionActionMode();
+                        return true;
                     }
                 }
             }
@@ -10184,7 +10182,10 @@
         return false;
     }
 
-    private void stopSelectionActionMode() {
+    /**
+     * @hide
+     */
+    protected void stopSelectionActionMode() {
         if (mSelectionActionMode != null) {
             // This will hide the mSelectionModifierCursorController
             mSelectionActionMode.finish();