Fix app crash if the selection is from reverse direction.

When user types some text and then long presses on end of empty area
to open context menu, if user opens Gboard and selects text from the
reverse direction, SelectionEnd will be less than SelectionStart. The
IllegalArgumentException occurred because TextClassification does not
allow SelectionEnd is less than SelectionStart. We swap the start and
end index if end index is less than start index.

Bug: 150916165
Test: Manual. No crash occurs.
Test: atest FrameworksCoreTests:android.widget.TextViewActivityTest

Change-Id: I8dbc92f0f31e64b7e3a45ae91762e1b741629a8e
1 file changed