Skip deleteSurroundingText when there is an invalid selection

Since InputConnection#deleteSurroundingText the design is to delete the
text before the selection start and after the selection end range,

it would be possible that the exception may happened when the obsolete
selection range which is not aligned with the current text content.

Add a check to make sure the text will be deleted when the number of
text before / selection the selection is > 0.

Also, skip the delection when the selection is not yet attached

Bug: 130979263
Test: atest BaseInputConnectionTest
Change-Id: I93b69b71531bcab4ae204c1c1287b8fbe0224ea8
1 file changed