Fix an exception in Contacts when you select text backwards from the end.

It was assuming that the end of the selection always came after or at the
start of the selection, and that therefore (start,end) was a safe range
to replace, but this is not actually the case when you select backwards --
in this case, the end comes before the start.

Bug 2087034
diff --git a/src/com/android/contacts/TwelveKeyDialer.java b/src/com/android/contacts/TwelveKeyDialer.java
index aa7cc70..0e9503a 100644
--- a/src/com/android/contacts/TwelveKeyDialer.java
+++ b/src/com/android/contacts/TwelveKeyDialer.java
@@ -1011,8 +1011,11 @@
         int selectionEnd;
 
         // SpannableStringBuilder editable_text = new SpannableStringBuilder(mDigits.getText());
-        selectionStart = mDigits.getSelectionStart();
-        selectionEnd = mDigits.getSelectionEnd();
+        int anchor = mDigits.getSelectionStart();
+        int point = mDigits.getSelectionEnd();
+
+        selectionStart = Math.min(anchor, point);
+        selectionEnd = Math.max(anchor, point);
 
         Editable digits = mDigits.getText();
         if (selectionStart != -1 ) {