Make PrecomputedText Spannable for supporting selection

This is 2nd attempt of I072dfd70b9a687d9c47e310d8cdb34f988fbb32e

The root cause of crashing is unexpected copying of NoCopySpan by
SpannableString constructor. To prevent crashing, stop copying
NoCopySpan by passing ignoreNoCopySpan=true to SpannableString
copy constructor.

The original commit message is following:

To support selectable TextView, make PrecomputedText spannable.
By this change, TextView start using DynamicLayout instead of
StaticLayout. DynamicLayout requires boundary rectangle of the
text, so this CL also adds getBounds method to PrecomputedText
which retrieves measured boundary box from native.

By this change, the selectable TextView performance for the
precomputed text 10x faster. On the other hand, the performacne
for the non-selectable text gets 2.5x slower. However, we concluded
that we accept this performance regression since it still 10 times
faster than non precomputed text.

Here is a precomputed text performance result of TextView.
android.widget.TextViewPrecomputedTextPerfTest:
  newLayout_PrecomputedText           :    736,130 ->  1,648,694: (+124.0%)
  newLayout_PrecomputedText_Selectable: 17,379,765 ->  1,700,146: (-90.2%)
  onDraw_PrecomputedText              :  1,274,921 ->  1,848,076: (+45.0%)
  onDraw_PrecomputedText_Selectable   : 17,367,238 ->  1,399,169: (-91.9%)
  onMeasure_PrecomputedText           :    752,875 ->  1,766,606: (+134.6%)
  onMeasure_PrecomputedText_Selectable: 17,647,842 ->  1,810,704: (-89.7%)
  setText_PrecomputedText             :     92,894 ->    135,471: (+45.8%)
  setText_PrecomputedText_Selectable  :    145,134 ->    215,757: (+48.7%)

Bug: 72998298
Test: atest CtsWidgetTestCases:EditTextTest
    CtsWidgetTestCases:TextViewFadingEdgeTest
    FrameworksCoreTests:TextViewFallbackLineSpacingTest
    FrameworksCoreTests:TextViewTest FrameworksCoreTests:TypefaceTest
    CtsGraphicsTestCases:TypefaceTest CtsWidgetTestCases:TextViewTest
    CtsTextTestCases FrameworksCoreTests:android.text
    CtsWidgetTestCases:TextViewPrecomputedTextTest

Change-Id: Ie98c75d8b4ba962eaf0a544357b2ff1ade891118
diff --git a/core/java/android/text/MeasuredParagraph.java b/core/java/android/text/MeasuredParagraph.java
index 980f4704..a107cab 100644
--- a/core/java/android/text/MeasuredParagraph.java
+++ b/core/java/android/text/MeasuredParagraph.java
@@ -21,6 +21,7 @@
 import android.annotation.NonNull;
 import android.annotation.Nullable;
 import android.graphics.Paint;
+import android.graphics.Rect;
 import android.text.AutoGrowArray.ByteArray;
 import android.text.AutoGrowArray.FloatArray;
 import android.text.AutoGrowArray.IntArray;
@@ -297,6 +298,18 @@
     }
 
     /**
+     * Retrieves the bounding rectangle that encloses all of the characters, with an implied origin
+     * at (0, 0).
+     *
+     * This is available only if the MeasuredParagraph is computed with buildForStaticLayout.
+     */
+    public void getBounds(@NonNull Paint paint, @IntRange(from = 0) int start,
+            @IntRange(from = 0) int end, @NonNull Rect bounds) {
+        nGetBounds(mNativePtr, mCopiedBuffer, paint.getNativeInstance(), start, end,
+                paint.getBidiFlags(), bounds);
+    }
+
+    /**
      * Generates new MeasuredParagraph for Bidi computation.
      *
      * If recycle is null, this returns new instance. If recycle is not null, this fills computed
@@ -728,4 +741,7 @@
 
     @CriticalNative
     private static native int nGetMemoryUsage(/* Non Zero */ long nativePtr);
+
+    private static native void nGetBounds(long nativePtr, char[] buf, long paintPtr, int start,
+            int end, int bidiFlag, Rect rect);
 }