Commit Graph

1388 Commits

Author SHA1 Message Date
Abodunrinwa Toki
adcd10f10f RESTRICT AUTOMERGE Do not linkify text with RLO/LRO characters.
am: a69950ce18

Change-Id: I0830e1c1a1cea2fd93f0b1ed8a1a792260201bb2
2019-01-07 17:10:30 -08:00
Abodunrinwa Toki
a69950ce18 RESTRICT AUTOMERGE Do not linkify text with RLO/LRO characters.
Also don't show smart actions for selections in text with unsupported
characters.

Bug: 116321860
Test: atest android.view.textclassifier.TextClassificationManagerTest \
            android.text.util.cts.LinkifyTest \
	    android.text.util.LinkifyTest \
	    android.widget.TextViewActivityTest

Change-Id: I01b5e936aa4dfc937a98f50e9fc8171666861a61
2019-01-03 14:20:30 +00:00
Mathew Inwood
8501ae1763 Merge "Limit access to suspected false positives." am: aeda49d185
am: 152d5a5dcd

Change-Id: I8e10322e69d2d479079df5cf8fec0287c7c117f1
2019-01-02 05:00:54 -08:00
Mathew Inwood
55418eada5 Limit access to suspected false positives.
Members modified herein are suspected to be false positives: i.e. things
that were added to the greylist in P, but subsequent data analysis
suggests that they are not, in fact, used after all.

Add a maxTargetSdk=P to these APIs. This is lower-risk that simply
removing these things from the greylist, as none of out data sources are
perfect nor complete.

For APIs that are not supported yet by annotations, move them to
hiddenapi-greylist-max-p.txt instead which has the same effect.

Exempted-From-Owner-Approval: Automatic changes to the codebase
affecting only @UnsupportedAppUsage annotations, themselves added
without requiring owners approval earlier.

Bug: 115609023
Test: m
Change-Id: Ia937d8c41512e7f1b6e7f67b9104c1878b5cc3a0
Merged-In: I020a9c09672ebcae64c5357abc4993e07e744687
2018-12-28 14:26:35 +00:00
Andrew Solovay
ad7477b192 docs: Fixing malformed javadoc
am: 6eaf48ea57

Change-Id: Idf8415ee4fb85e52d74e1f8bec8d0e2f8d1f58f1
2018-12-14 10:50:44 -08:00
Andrew Solovay
6eaf48ea57 docs: Fixing malformed javadoc
Several @link & @see javadoc directives were malformed, resulting in the
Javadoc code being output to the HTML.

Staged to:

http://go/dac-stage/reference/android/app/slice/Slice.Builder
http://go/dac-stage/reference/android/app/slice/SliceProvider
http://go/dac-stage/reference/android/text/style/ImageSpan
http://go/dac-stage/reference/android/content/ContentProvider

Bug: 120743732
Test: make ds-docs
Change-Id: I589644f8d266a116441409fbdaf7a0c533e0e356
Merged-In: I589644f8d266a116441409fbdaf7a0c533e0e356
Exempt-From-Owner-Approval: Doc-only change
2018-12-14 00:11:19 +00:00
Neil Fuller
402dc485d0 Merge "Track move of timezone classes to libcore.timezone" am: d48dbc9a34
am: f79ecf7c82

Change-Id: I1551e5d4330ea290ba3e3054349f79ee28f919c6
2018-11-28 08:10:04 -08:00
Neil Fuller
b8383a10b9 Track move of timezone classes to libcore.timezone
Some time zone related libcore classes are moving from
libcore.util to libcore.timezone.

Bug: 119026403
Test: build only
Change-Id: Ic807977a85276b888362295d1d305effe33076fc
2018-11-27 14:44:59 +00:00
Nathan Harold
41e2d7494f Merge "Move some members to the "Q blacklist"." am: f5cf9f24ed
am: 13c9e7e2f3

Change-Id: Ia2419cce28d26d9464da2a5172cb332b629e943e
2018-10-24 16:14:06 -07:00
Bill Yi
8b634e9191 Merge pie-platform-release to aosp-master - DO NOT MERGE
Change-Id: I695db52f5e22509401258e8b083e7650d401d993
2018-10-24 14:48:44 -07:00
Mathew Inwood
45d2c252b1 Move some members to the "Q blacklist".
Based on some analysis, these fields/methods are likely false positives.
Set maxTargetSdk=P so that any apps using them are required to migrate off
them in future. See the bug for more details.

Exempted-From-Owner-Approval: Automatic changes to the codebase
affecting only @UnsupportedAppUsage annotations, themselves added
without requiring owners approval earlier.

Bug: 115609023
Test: m
Merged-In: I719b5c94e5b1f4fa562dd5d655953422958ad37e
Change-Id: I719b5c94e5b1f4fa562dd5d655953422958ad37e
(cherry picked from commit 8c854f86a4)
2018-10-22 17:28:24 -07:00
kopriva
d366837e05 Merge "docs: fixed five typos" into pi-dev
am: 82b413428e

Change-Id: I4af571d6bcfa151235223b51cb8135fbacb62c82
2018-09-18 12:00:24 -07:00
kopriva
7ecfe31427 docs: fixed five typos
Test: make ds-docs

Bug: 37095452
Bug: 37001217
Bug: 37004068
Bug: 37015340
Bug: 37044652

Change-Id: Ib305df88b63286810d7722e73321ddb238b45e8e
Exempt-From-Owner-Approval: Docs-only change
2018-09-17 15:17:50 -07:00
Seigo Nonaka
821e9bd5cc Fix crash during cursor moving on BiDi text
The crash was introduced by Ib66ef392c19c937718e7101f6d48fac3abe51ad0
The root cause of the crashing is requesting out-of-line access for the
horizontal width. This invalid access is silently ignored by
TextLine#measure() method but new implementation end up with out of
bounds access.

To makes behavior as old implementation, calling getHorizontal instead
of accessing measured result array.

Bug: 78464361, 111580019
Test: Manually done
Change-Id: I5c5778718f6b397adbb1e4f2cf95e9f635f6e5c8
(cherry picked from commit 960647d582)
Merged-In: I5c5778718f6b397adbb1e4f2cf95e9f635f6e5c8
(cherry picked from commit a1076fdaa5)
2018-08-16 16:40:09 +00:00
Mathew Inwood
e0f11e8ce6 Merge "Add @UnsupportedAppUsage annotations" am: 348a7e7315
am: 58b0d33e36

Change-Id: I47fd8beb33a06344cbacb1776d5cc3fb03089903
2018-08-16 03:25:16 -07:00
Mihai Popa
8caff9fd7a Merge "Fix crash during cursor moving on BiDi text" into pi-dev
am: f052c26a7d

Change-Id: I18123e7e08220b1483df6fd32ec0eecd68bb38de
2018-08-15 12:30:09 -07:00
Seigo Nonaka
a1076fdaa5 Fix crash during cursor moving on BiDi text
The crash was introduced by Ib66ef392c19c937718e7101f6d48fac3abe51ad0
The root cause of the crashing is requesting out-of-line access for the
horizontal width. This invalid access is silently ignored by
TextLine#measure() method but new implementation end up with out of
bounds access.

To makes behavior as old implementation, calling getHorizontal instead
of accessing measured result array.

Bug: 78464361, 111580019
Test: Manually done
Change-Id: I5c5778718f6b397adbb1e4f2cf95e9f635f6e5c8
(cherry picked from commit 960647d582)
Merged-In: I5c5778718f6b397adbb1e4f2cf95e9f635f6e5c8
2018-08-15 19:11:50 +00:00
Mathew Inwood
9cf99fd91f Add @UnsupportedAppUsage annotations
For packages:
  android.text.util
  android.text.style
  android.text.method
  android.text.format
  android.text

This is an automatically generated CL. See go/UnsupportedAppUsage
for more details.

Exempted-From-Owner-Approval: Mechanical changes to the codebase
which have been approved by Android API council and announced on
android-eng@

Bug: 110868826
Test: m
Change-Id: I5be178ad05f2ff98bcf31e24cd4eb33961887c38
Merged-In: I9afbd4ca8826c37cb70db43252e39b9a674e5ae0
2018-08-15 12:49:00 +01:00
Tobias Thierer
5442964205 Merge "TextUtils: track behavior change of Pattern.split() when targeting > 28."
am: b5f35aeaf3

Change-Id: I55ba23bfae8f578eb75a4cbfeb2ed4ad1492867d
2018-06-27 08:14:58 -07:00
Tobias Thierer
3e76c04c96 TextUtils: track behavior change of Pattern.split() when targeting > 28.
Another CL in this topic changes the behavior of String.split() and
Pattern.split() to omit a "" generated by a leading zero-width match.
TextUtils.split() is implemented on top of these methods and therefore
adopts the behavior change by default.

The behavior change only affects apps targeting API versions > 28.

Test: cts-tradefed run singleCommand cts-dev -m CtsTextTestCases \
      -t android.text.cts.TextUtilsTest
Test: cts-tradefed run singleCommand cts-dev -m CtsLibcoreTestCases
Bug: 109659282

Change-Id: I8abe251353f8eacf1429ac9a8e272d50a0944c29
2018-06-26 14:48:47 +01:00
Mihai Popa
138b106402 Optimise the hit test algorithm
Layout#getOffsetForHorizontal was running in O(n^2) time, where n is the
length of the current line. The method is used when a touch event
happens on a text line, to compute the cursor offset (and the character)
where it happened. Although this is not an issue in common usecases,
where the number of characters on a line is relatively small, this can
be very inefficient as a consequence of Unicode containing 0-width
(invisible) characters. Specifically, there are characters defining the
text direction (LTR or RTL), which cause our algorithm to touch the
worst case quadratic runtime. For example, a person is able to send a
message containing a few visible characters, and also a lot of these
direction changing invisible ones. When the receiver touches the message
(causing the Layout#getOffsetForHorizontal method to be called), the
receiver's application would become not responsive.

This CL optimizes the method to run in O(n) worst case. This is achieved
by computing the measurements of all line prefixes at first, which can
be done in a single pass. Then, all the prefix measurement queries will
be answered in O(1), rather than O(n) as it was happening before.

Bug: 79215201
Test: manual testing
Change-Id: Ib66ef392c19c937718e7101f6d48fac3abe51ad0
Merged-In: Ib66ef392c19c937718e7101f6d48fac3abe51ad0
2018-05-31 19:14:17 +01:00
Siyamed Sinir
5ee0f5c1d7 Merge "Update Emoji.java for emoji 11" into pi-dev 2018-04-23 18:19:22 +00:00
TreeHugger Robot
686fab1464 Merge "SmartLinkify - handle keyboard clicks" into pi-dev 2018-04-20 18:44:02 +00:00
Abodunrinwa Toki
33fa382b8f SmartLinkify - handle keyboard clicks
Bug: 77998709
Test: bit FrameworksCoreTests:android.widget.TextViewActivityTest
Test: bit CtsWidgetTestCases:android.widget.cts.TextViewTest
Change-Id: Ibb95a736248643949a7b521368374084f9f133ca
2018-04-20 14:37:23 +01:00
Siyamed Sinir
adcb6cac12 Update Emoji.java for emoji 11
This CL removes the Emoji 5.0 info from Emoji.java since they are
supported by ICU. It adds emoji added in Emoji 11.

Test: atest android.text.EmojiTest
Test: Verified that ICU handles Emoji 5.0 emoji
Test: Verified hardware keyboard backspace with hair color emoji
Test: Visually verified cursor moves with hardware keyboard

Bug: 77148691
Change-Id: I40b290fcea201cf5e35ad4c461f8d8056b8c3739
(cherry picked from commit 213388d254)
2018-04-19 19:19:39 +00:00
Jeff Sharkey
aa1a911d9a Fix broken target SDK checks.
Consider an app targeting the final API 28, but running on an older
build where "P" is still API 10000.  Those apps need to be treated as
legacy apps.

In general, the logical pattern that should be used when enforcing
target SDK behaviors is below.

For applying behavior to legacy apps:
    // BROKEN
    if (targetSdkVersion <= Build.VERSION_CODES.N_MR1) {
    // CORRECT
    if (targetSdkVersion < Build.VERSION_CODES.O) {

For applying behavior to new apps:
    // BROKEN
    if (targetSdkVersion > Build.VERSION_CODES.N_MR1) {
    // CORRECT
    if (targetSdkVersion >= Build.VERSION_CODES.O) {

Bug: 77865751
Test: builds, boots
Change-Id: Ia83bd446a940751d51a6542c7a5b9cca174c5296
2018-04-10 15:18:15 -06:00
TreeHugger Robot
42c686861c Merge "Update JNI interface of GetBounds in PrecomputedText" into pi-dev 2018-04-10 19:06:51 +00:00
Jeff Sharkey
415716915e Offer to format data sizes in either IEC or SI.
Add flags to let callers specify if they want IEC (power-of-two) or
SI (power-of-ten) units when formatting bytes.

Continue using SI units by default, since certain folks seem to have
strong opinions about that.

Bug: 76159924
Test: atest android.text.format.FormatterTest
Exempt-From-Owner-Approval: previous PS approved
Change-Id: I0074bb2578c2230e938b3f39c2564b1083feb825
2018-04-09 20:23:54 -06:00
TreeHugger Robot
1f2c6dea41 Merge "Fix crash when modifying Selection" into pi-dev 2018-04-09 09:26:42 +00:00
Clara Bayarri
4e51877f5c Fix crash when modifying Selection
The root of this bug was in the fact that Selection.removeSelection
removes two spans, the start index and end index of the selection.
Each span removal triggers Editor#onSpanRemoved, which in turn tries
to set a selection. This meant that if we started with selection
(100, 120), then removeSpan(start) was called, so we had (-1, 120),
then the onSpanRemoved code tried to set a selection so set it to
(120, 120), then removeSpan(end) was called, ending up in (120, -1).

There are two stages to this fix
1. A lot of our code assumes that when either start or end selection
are larger than -1, both are valid. Therefore when we have one of them
out of sync, we crash. Fixed this assumption in all the places I found

2. We didn't have a mechanism to use FLAG_INTERMEDIATE when removing
spans, only when adding them, so this CL adds a remove with flags. This
allows us to not trigger onSpanRemoved when only one of the selection
indexes is removed.
Because this is an added method to an interface, the default just
calls the existing method. The new method is implemented in
SpannableStringInternal and SpannableStringBuilder to read
FLAG_INTERMEDIATE and avoid sending a spans changed event.
Selection.removeSelection then uses FLAG_INTERMEDIATE when removing
the first of the two selection spans.

Note that 2. would be enough to fix the current bug, but we want to
avoid other implementations of Spannable from crashing in the wild.
In general, it seems like a good idea to verify both selection indexes
are valid whenever they are used.

Bug: 72101848
Test: atest FrameworksCoreTests:SpannableStringBuilderTest
Test: atest FrameworksCoreTests:SpannableStringTest
Test: atest CtsWidgetTestCases:TextViewTest
Test: atest CtsWidgetTestCases:EditTextTest
Test: atest android.text.cts.SelectionTest (note new test as well)
Test: atest android.view.inputmethod.cts.BaseInputConnectionTest
Test: atest android.text.DynamicLayoutTest
Change-Id: I0d647fad152d0bef0f2115a46c3d17ebd8642281
2018-04-06 16:51:53 +01:00
Jan Althaus
003889a275 Add deprecation notice to Linkify MAP_ADDRESSES
Bug: 22362008
Test: N/A
Change-Id: Ib70e0cbdd8c454a96e5e75b906ace7b6f1e21cba
2018-04-05 19:04:26 +02:00
Seigo Nonaka
fb0abe1feb Update JNI interface of GetBounds in PrecomputedText
Bug: 77495049
Test: atest CtsWidgetTestCases:EditTextTest
    CtsWidgetTestCases:TextViewFadingEdgeTest
    FrameworksCoreTests:TextViewFallbackLineSpacingTest
    FrameworksCoreTests:TextViewTest FrameworksCoreTests:TypefaceTest
    CtsGraphicsTestCases:TypefaceTest CtsWidgetTestCases:TextViewTest
    CtsTextTestCases FrameworksCoreTests:android.text
    CtsWidgetTestCases:TextViewPrecomputedTextTest

Change-Id: I54a70a91f6fba90720b702b52ed6ad430e17c87d
2018-04-04 18:25:12 +00:00
Seigo Nonaka
3a2d4143ee Merge "Make getText hidden and getWidth/getBounds public" into pi-dev 2018-04-03 15:54:49 +00:00
Seigo Nonaka
151108a2c6 Make getText hidden and getWidth/getBounds public
This is from advice from API review.
- make getText() hidden
- make getWidth()/getBounds() public.

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

Change-Id: Ic22a266a932cda60de6d8b37b8bbf5704291b953
2018-04-02 09:58:47 -07:00
TreeHugger Robot
bf9dfb16be Merge "TextClassifier API updates." into pi-dev 2018-04-02 09:08:52 +00:00
Abodunrinwa Toki
080c8542b6 TextClassifier API updates.
1. Wraps TC queries in Request objects
2. Adds create/destroyTextClassificationSession system APIs
3. Adds the session Ids to system API calls
4. Change setSignature() to setId() on result objects
5. Plumbing to make the API updates work as things currently work
6. Hide Linkify.addLinksAsync APIs

Bug: 74461129

Test: bit FrameworksCoreTests:android.view.textclassifier.TextClassificationManagerTest
Test: bit CtsViewTestCases:android.view.textclassifier.cts.TextClassificationManagerTest
Test: bit CtsWidgetTestCases:android.widget.cts.TextViewTest
Test: bit FrameworksCoreTests:android.widget.TextViewActivityTest
Test: bit FrameworksCoreTests:android.view.textclassifier.TextClassificationTest
Test: bit FrameworksCoreTests:android.view.textclassifier.TextSelectionTest
Test: bit FrameworksCoreTests:android.view.textclassifier.TextLinksTest

Change-Id: I933ada8b37ef9893331a265e3b4fc08e043f1029
2018-04-01 20:04:47 +01:00
Seigo Nonaka
0903665f97 Fills font metrics before passing to ReplacementSpan
Bug: 74518333
Test: atest CtsWidgetTestCases:EditTextTest
    CtsWidgetTestCases:TextViewFadingEdgeTest
    FrameworksCoreTests:TextViewFallbackLineSpacingTest
    FrameworksCoreTests:TextViewTest FrameworksCoreTests:TypefaceTest
    CtsGraphicsTestCases:TypefaceTest CtsWidgetTestCases:TextViewTest
    CtsTextTestCases FrameworksCoreTests:android.text
    CtsWidgetTestCases:TextViewPrecomputedTextTest
    Change-Id: Ifbc8625882919e6498a2758433e80f059a797fd4

Change-Id: I6181fd712aae38e0bba702374e01a40ee3b522dd
2018-03-30 12:30:56 -07:00
Joshua Baxter
2ae75ba1ab docs: fixed typo
am: eb5d2d96ad

Change-Id: I60e1befd90c14fe0ef6b3b8813bb2a791f8a7399
2018-03-28 00:33:50 +00:00
Joshua Baxter
eb5d2d96ad docs: fixed typo
Test: make ds-docs

Bug: 36944055
Change-Id: I52c6d6404340ada5a18b99fd37a2f1d75af00677
2018-03-27 10:28:05 -07:00
TreeHugger Robot
d982f561cc Merge "Fix random SmartLinkify-related TextView bugs." into pi-dev 2018-03-26 23:21:37 +00:00
Abodunrinwa Toki
520969191b Fix random SmartLinkify-related TextView bugs.
1. Preserve selection when the TC times out. (See: SelectionActionModeHelper)

2. Fix highlight/toolbar flicker when tapping on a smart link.
   - Highlight flicker happening because we reset the selection while in
     the process of starting a link action mode.
     i.e. onLinkDown: show highlight
          onLinkUp: start the link action mode asynchronously
	  onLinkUp: reset the selection to an insertion cursor*
	  onLinkActionModeStarted: reset the highlight
	  *Fix: Don't reset selection while starting a link action mode.
   - Toolbar flicker happening because the toolbar positions itself over
     the current selection. The way link highlights have traditionally
     been done is to set the selection to the links bounds*
     *Fix: Hide the toolbar for a few milliseconds when changing
     selection for smoother transition.

3. Fix Paste menu overriding link action mode toolbar after a recent
   "Copy" action. The Paste menu appearing is a feature. Whenever the
   user inserts a cursor after just copying some text, we show the Paste
   menu as a way to make it easy for the user to select the text.
   Because of the problem described in (2) above, changing the selection
   to an insertion triggers the Paste menu feature. Fixing (2) fixes
   this.

4. Fix IME popping up on non-selectable + focusable TextViews.
   See: imm.showSoftInput(...) in Editor. And see comment in the code
   around that. We should only pop up the IME for editable text.

Fixes: 73872461
Fixes: 75985239
Fixes: 76011461

Test: bit CtsWidgetTestCases:android.widget.cts.TextViewTest
Test: bit FrameworksCoreTests:android.widget.TextViewActivityTest
Change-Id: If9ddb7f4e6d4db480ba4a495a22f7f2924ab937e
2018-03-26 18:11:03 +01:00
Seigo Nonaka
53145635e4 Fix BoringLayout with PrecomputedText
The special logic for PrecomputedText in BoringLayout has problem.
The special logic is no longer necessary since TextLine is now aware of
PrecomputedText. So, just removing special logic from BoringLayout.

On the other hand, the metrics parameters check in TextLine has removed
Ie73bce52c6c673cda58973ddad04627a7cf2e5e9, but that was wrong. TextLine
can be used by BoringLayout too. Thus, need to reject PrecomputedText
if the given TextPaint is not compatible with given param.

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

Change-Id: I172b5f655402e797b53b9667b49cb4ab89ec0dc0
2018-03-23 18:19:06 -07:00
TreeHugger Robot
02c8d1b07f Merge "Make PrecomputedText Spannable for supporting selection" into pi-dev 2018-03-22 23:21:54 +00:00
TreeHugger Robot
e9a7cb8158 Merge "Fix smart_linkify_enabled flag." into pi-dev 2018-03-22 22:56:58 +00:00
Abodunrinwa Toki
6563833cf3 Fix smart_linkify_enabled flag.
The flag should only ensure that smart linkify calls behave in the
legacy way instead of totally disabling linkify.
Also, to keep the flag consistent with smart_selection_enabled and
smart_text_share_enabled flags, the flag should only disable the
SmartLinkify (i.e. Linkify.addLinksAsync) feature not TextClassifier
APIs (i.e. TextClassifier.generateLinks).

Also fixes issue with non-focusable TextViews by firing the primary
action instead of showing the floating toolbar. (b/73156794)

Bug: 75967597
Bug: 73156794
Test: bit FrameworksCoreTests:android.text.util.LinkifyTest
Test: bit CtsTextTestCases:android.text.util.cts.LinkifyTest
Test: bit FrameworksCoreTests:android.view.textclassifier.TextClassificationManagerTest
Test: bit CtsWidgetTestCases:android.widget.cts.TextViewTest
Test: bit FrameworksCoreTests:android.widget.TextViewActivityTest
Test: manual - checked behaviour turning flag on/off
Test: manual - checked behaviour with TextView.setFocusableInTouchMode(true/false)
Change-Id: I541f60161b9cd63ce7e57235607500f2fb0841e7
2018-03-22 19:25:14 +00:00
Seigo Nonaka
a553477ddf 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
2018-03-20 22:22:30 -07:00
Seigo Nonaka
c3328d648e Stop creating PrecomputedText in StaticLayout
No performance regressions are expected

android.text.PrecomputedTextPerfTest:
  create NoStyled Hyphenation                  : 17,849,966 -> 17,858,570: (+0.0%)
  create NoStyled Hyphenation WidthOnly        : 17,814,338 -> 17,801,205: (-0.1%)
  create NoStyled NoHyphenation                :  7,123,449 ->  7,068,308: (-0.8%)
  create NoStyled NoHyphenation WidthOnly      :  7,108,169 ->  7,074,908: (-0.5%)
  create Styled Hyphenation                    : 12,179,203 -> 12,131,020: (-0.4%)
  create Styled Hyphenation WidthOnly          : 12,112,347 -> 12,241,311: (+1.1%)
  create Styled NoHyphenation                  : 11,870,126 -> 11,880,442: (+0.1%)
  create Styled NoHyphenation WidthOnly        : 11,836,742 -> 11,860,292: (+0.2%)

android.text.StaticLayoutPerfTest:
  create PrecomputedText Balanced Hyphenation  :    697,713 ->    691,148: (-0.9%)
  create PrecomputedText Balanced NoHyphenation:    517,113 ->    498,106: (-3.7%)
  create PrecomputedText Greedy Hyphenation    :    468,243 ->    455,015: (-2.8%)
  create PrecomputedText Greedy NoHyphenation  :    479,514 ->    461,617: (-3.7%)
  create RandomText Balanced Hyphenation       : 17,183,044 -> 17,049,811: (-0.8%)
  create RandomText Balanced NoHyphenation     :  7,183,745 ->  7,025,070: (-2.2%)
  create RandomText Greedy Hyphenation         :  7,130,841 ->  6,995,785: (-1.9%)
  create RandomText Greedy NoHyphenation       :  7,122,398 ->  7,037,074: (-1.2%)

  draw PrecomputedText NoStyled                :    520,306 ->    551,465: (+6.0%)
  draw PrecomputedText NoStyled WithoutCache   :    545,773 ->    566,956: (+3.9%)
  draw PrecomputedText Styled                  :    826,044 ->    838,979: (+1.6%)
  draw PrecomputedText Styled WithoutCache     :    829,958 ->    841,749: (+1.4%)
  draw RandomText NoStyled                     :    537,079 ->    545,428: (+1.6%)
  draw RandomText NoStyled WithoutCache        :  6,473,166 ->  6,445,194: (-0.4%)
  draw RandomText Styled                       :    995,033 ->  1,015,913: (+2.1%)
  draw RandomText Styled WithoutCache          :  2,725,313 ->  2,770,604: (+1.7%)

android.widget.TextViewPrecomputedTextPerfTest:
  newLayout PrecomputedText                    :    754,311 ->    718,130: (-4.8%)
  newLayout PrecomputedText Selectable         : 17,716,239 -> 17,484,046: (-1.3%)
  newLayout RandomText                         : 16,657,952 -> 16,511,625: (-0.9%)
  newLayout RandomText Selectable              : 17,675,222 -> 17,520,653: (-0.9%)
  onDraw PrecomputedText                       :  1,307,123 ->  1,280,009: (-2.1%)
  onDraw PrecomputedText Selectable            : 17,613,031 -> 17,404,379: (-1.2%)
  onDraw RandomText                            : 17,369,256 -> 17,295,363: (-0.4%)
  onDraw RandomText Selectable                 : 18,207,392 -> 18,077,660: (-0.7%)
  onMeasure PrecomputedText                    :    748,537 ->    739,128: (-1.3%)
  onMeasure PrecomputedText Selectable         : 17,842,953 -> 17,784,459: (-0.3%)
  onMeasure RandomText                         : 16,633,454 -> 16,549,182: (-0.5%)
  onMeasure RandomText Selectable              : 18,022,286 -> 17,873,919: (-0.8%)
  setText PrecomputedText                      :    120,769 ->    119,496: (-1.1%)
  setText PrecomputedText Selectable           :    162,411 ->    150,809: (-7.1%)
  setText RandomText                           :     11,096 ->     10,956: (-1.3%)
  setText RandomText Selectable                :     48,852 ->     48,593: (-0.5%)

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: I3af758ecc5a15975c4e59c6378faf7c14c3bd65b
2018-03-20 18:57:38 -07:00
Seigo Nonaka
3483bc7d64 Introduce new constructor for not copying NoCopySpan
To hold the original text in PrecomputedText, need to create
SpannableString, but copying NoCopySpan causes some side effect.
This CL introduces a way of copying SpannableString/SpannedString
with all spans other than NoCopySpan.

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

Change-Id: I20dea2114ccaa54b16ff679c97682a5003f9a4c1
2018-03-20 14:33:35 -07:00
Seigo Nonaka
e887f4d2c1 Revert "Make PrecomputedText Spannable for supporting selection"
Crash on Sheets APp
This reverts commit 80ed5a35a9.

Bug: 75652829
Change-Id: I40ddd1b9754e74fbd90d7a029cce9c6a7ede0777
Test: Manual
2018-03-19 17:04:30 +00:00
Seigo Nonaka
80ed5a35a9 Make PrecomputedText Spannable for supporting selection
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%)

Verified no effects for other performance metrics:
android.widget.TextViewPrecomputedTextPerfTest:
  newLayout_RandomText                                  : 16,495,200 -> 16,450,483: (-0.3%)
  newLayout_RandomText_Selectable                       : 17,482,439 -> 17,534,207: (+0.3%)
  onDraw_RandomText                                     : 17,224,949 -> 17,228,072: (+0.0%)
  onDraw_RandomText_Selectable                          : 18,067,397 -> 17,958,235: (-0.6%)
  onMeasure_RandomText                                  : 16,435,649 -> 16,516,352: (+0.5%)
  onMeasure_RandomText_Selectable                       : 17,724,819 -> 17,879,508: (+0.9%)
  setText_RandomText                                    :     11,130 ->     11,259: (+1.2%)
  setText_RandomText_Selectable                         :     48,900 ->     48,607: (-0.6%)

android.text.PrecomputedTextPerfTest:
  create_NoStyled_Hyphenation                           : 17,695,377 -> 17,660,233: (-0.2%)
  create_NoStyled_Hyphenation_WidthOnly                 : 17,677,423 -> 17,541,823: (-0.8%)
  create_NoStyled_NoHyphenation                         :  7,021,486 ->  7,030,069: (+0.1%)
  create_NoStyled_NoHyphenation_WidthOnly               :  7,045,453 ->  7,067,021: (+0.3%)
  create_Styled_Hyphenation                             : 12,090,933 -> 12,267,730: (+1.5%)
  create_Styled_Hyphenation_WidthOnly                   : 12,105,491 -> 12,277,272: (+1.4%)
  create_Styled_NoHyphenation                           : 11,835,249 -> 11,960,278: (+1.1%)
  create_Styled_NoHyphenation_WidthOnly                 : 11,871,765 -> 11,912,444: (+0.3%)

android.text.StaticLayoutPerfTest:
  create_PrecomputedText_NoStyled_Balanced_Hyphenation  :    709,839 ->    697,134: (-1.8%)
  create_PrecomputedText_NoStyled_Balanced_NoHyphenation:    527,671 ->    528,928: (+0.2%)
  create_PrecomputedText_NoStyled_Greedy_Hyphenation    :    477,259 ->    481,966: (+1.0%)
  create_PrecomputedText_NoStyled_Greedy_NoHyphenation  :    479,772 ->    482,278: (+0.5%)
  create_PrecomputedText_Styled_Greedy_NoHyphenation    :    639,322 ->    637,790: (-0.2%)
  create_RandomText_NoStyled_Balanced_Hyphenation       : 17,123,681 -> 16,989,227: (-0.8%)
  create_RandomText_NoStyled_Balanced_NoHyphenation     :  7,040,572 ->  7,064,175: (+0.3%)
  create_RandomText_NoStyled_Greedy_Hyphenation         :  7,000,681 ->  7,002,322: (+0.0%)
  create_RandomText_NoStyled_Greedy_NoHyphenation       :  6,997,115 ->  6,996,953: (-0.0%)
  create_RandomText_Styled_Greedy_NoHyphenation         : 11,948,744 -> 12,052,791: (+0.9%)
  draw_PrecomputedText_NoStyled                         :    543,623 ->    513,741: (-5.5%)
  draw_PrecomputedText_NoStyled_WithoutCache            :    564,742 ->    541,795: (-4.1%)
  draw_PrecomputedText_Styled                           :    838,581 ->    837,438: (-0.1%)
  draw_PrecomputedText_Styled_WithoutCache              :    826,775 ->    850,586: (+2.9%)
  draw_RandomText_NoStyled                              :    538,162 ->    533,603: (-0.8%)
  draw_RandomText_NoStyled_WithoutCache                 :  6,401,486 ->  6,424,604: (+0.4%)
  draw_RandomText_Styled                                :  1,024,683 ->  1,011,575: (-1.3%)
  draw_RandomText_Styled_WithoutCache                   :  2,733,204 ->  2,722,828: (-0.4%)

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: I072dfd70b9a687d9c47e310d8cdb34f988fbb32e
2018-03-15 14:09:08 -07:00