Fix monkey crash in smart selection animation

In Id65443e93d277c106ea955c867d39e94192cc55d we fixed a monkey crash
happening when the smart selected text had changed while the smart
selection animation was running. However, the change introduced a new
crash, happening when the smart selection result was null. This CL fixes
it, and lets startSelectionActionMode run even when the result is null,
as there seems to be some logic there which should happen in this case.

Bug: 80244201
Test: none
Change-Id: I7f0304446dec85578bdcd5011d2e9ea2737d3c36
(cherry picked from commit a9d27ea8692dbf6c6def6bd21754af0ad67d1675)
Merged-in: I7f0304446dec85578bdcd5011d2e9ea2737d3c36
diff --git a/core/java/android/widget/SelectionActionModeHelper.java b/core/java/android/widget/SelectionActionModeHelper.java
index d22b1e6..6cb0eaa 100644
--- a/core/java/android/widget/SelectionActionModeHelper.java
+++ b/core/java/android/widget/SelectionActionModeHelper.java
@@ -285,10 +285,14 @@
         final Layout layout = mTextView.getLayout();
 
         final Runnable onAnimationEndCallback = () -> {
-            if (result.mStart >= 0 && result.mEnd <= getText(mTextView).length()
+            final SelectionResult startSelectionResult;
+            if (result != null && result.mStart >= 0 && result.mEnd <= getText(mTextView).length()
                     && result.mStart <= result.mEnd) {
-                startSelectionActionMode(result);
+                startSelectionResult = result;
+            } else {
+                startSelectionResult = null;
             }
+            startSelectionActionMode(startSelectionResult);
         };
         // TODO do not trigger the animation if the change included only non-printable characters
         final boolean didSelectionChange =