It is possible the existing text is changed that triggers a new
translation. We cache the translation response when onShowTransltion
is called. We should keep the translation response is updated if this
is a new translation result.
Bug: 200232741
Test: atest CtsTranslationTestCases
Test: manual. The issue app works fine.
Change-Id: Iaf7423cd35d4484e33de84e478256b77a000f390
Instead of iterate all ellipsized characters, only iterate the necessary
ranges for copying.
Bug: 188913943
Test: atest CtsTextTestCases CtsGraphicsTestCases CtsWidgetTestCases
Change-Id: I3d03b1e3897e427c23fbe51315f412c57a4ce9e9
(cherry picked from commit 2c6121f3e3)
Some apps operate on the view text based on layout calculations made on
the transformed text. This can cause issues (even crashes) if the
transformed text is longer than the original, as is often the case with
Translate. A previous temporary fix,
I685ae4a9752c817db81f0d736f1d746b2e4a9839, ellipsized the translated
text. This change fixes it properly by instead padding the original
text.
A followup change will make this controllable by API instead of padding
every TextView.
The en space character, U+2002, is used for the padding here. It seems
to work well in practice for multiple languages. We don't make this
configurable through API as it could make debugging harder (issues
triggered by server-side changes).
Bug: 179693024
Test: atest CtsTranslationTestCases
Test: manual - toggling between original and translated, scrolling, new
views appearing, multiple apps
Change-Id: I9d7db5d2bc200e4042baf3267796f00cfc298f19
Ellipsizes the translated text if it's longer than the view text. This
fixes a crash in apps that operate on the view text based on layout
calculations made on the transformed text.
A proper fix will follow to modify the UiTranslationManger API to make
this compat behavior happen only on request, and probably change the
behavior to instead add padding to the view text to make it match the
translated text length.
Bug: 179693024
Test: atest CtsTranslationTestCases
Change-Id: I685ae4a9752c817db81f0d736f1d746b2e4a9839
It already uses the transformed text characters, but uses the length of
the base text. This does not account for TransformationMethod2, which
can change length, including AllCapsTransformationMethod ("ß" becomes
"SS") and TranslationTransformationMethod (arbitrary length changes).
This change does not fix updates that happens through
DynamicLayout.ChangeWatcher; those will be fixed in separate change(s).
Bug: 178650596
Test: atest DynamicLayoutBlocksTest DynamicLayoutTest TextLayoutTest \
TextViewTest
Test: manually on a sample app with AllCaps
Test: manually with Translate on a real app
Change-Id: Iec4699c8d9967cb4622fe59ba91849642d72b52e
DynamicLayout uses a static StaticLayout instance internally to avoid
allocations. For the specific case of multiline, TruncateAt.START, and
no ellipsization needed (may also be triggered by slightly different
params), the ellipsis results for a reused static instance are not
modified. If the instance was previously ellipsized, the new result
keeps that ellipsization result even though it shouldn't be ellipsized
(at least for some lines).
Bug: 179524847
Test: atest DynamicLayoutBlocksTest DynamicLayoutTest TextLayoutTest \
TextViewTest
Change-Id: I1b4142648ec1b6b3fc2ece0ec55aac9539497134
FontManager is an interface of communicating with FontManaserService.
With this CL, system apps can know the primitive information about
what font files are installed and how it is configured.
This CL also adds shell command of dumping font configuration.
Example usages are:
# dump primitive font configuration.
adb shell dumpsys font
# dump fallback font list
adb shell cmd font dump serif
Bug: 173619554
Test: atest FontManagerTest
Test: Manually confirmed above commands works.
Change-Id: I5cb855308e199ac38bd7b56b60821346247bdce3
The initial APIs for auto translation flow. The implementation of
sending request and dealing spans will on the follow up changes.
Bug: 172969740
Test: manual build pass. Use a sample app to call api get expected
result.
Change-Id: Ief45190026e6205ff18366c1aaba8f424a4df00c
This CL breaks system font initialization step into three sub-steps
to be able to expose font configuration as SystemApi. The font
initialization step is now following three steps:
1. Parse XML files. This is SystemFonts#getSystemFontConfig and
SystemFonts#getSystemPreinstalledFontConfig. The first API gives
you the current FontConfig and the second API gives you plain
vanilla FontConfig without any updates.
2. Build font family fallback list from FontConfig. The font family
fallback is a intermediate state that can be used for custom
Typeface. This state is kept for dumping in shell command later.
This is useful for checking what font will be used by the fallback
since family fallback is still printable.
3. Build typeface mapping. The typeface mapping is the final state to
be used by application. This is no longer printable.
Bug: 173619554
Test: atest TypefaceTest TypefaceSystemFallbackTest StaticLayoutTest
Test: atest CtsGraphicsTestCases CtsTextTestCases
Change-Id: I4e21fc7c41f2fb7975d03c1d5f5536a23e8abb09
Use the Inet4AddressUtils common utility instead.
NetworkUtils is moving to the connectivity module, so its hidden symbols
are not accessible from the framework. Use the Inet4AddressUtils utility
instead.
NetworkUtils.intToInetAddress is also deprecated.
Bug: 174436414
Test: m
Change-Id: Ia4f4de2f23b2e2be056f78cc30259814f9a4dc91
We can only safely use TextUtils.formatSimple() when formatting
strings that don't appear in UI, since locales can use different
glyphs for representing numerals.
Bug: 174576537
Test: manual
Exempt-From-Owner-Approval: revert
Change-Id: Iafba1ccde239e3053b2a462c3d0c248795fbf5fc
Use @EnabledSince instead of @EnabledAfter for DISALLOW_DUPLICATE_FIELD_IN_SKELETON
Test: m
Bug: 172238506
Change-Id: I041e1e2694f310d638e31b475f29d0d214711dd5
These are APIs that have @UnsupportedAppUsage but for which we don't
have any evidence of them currently being used, so should be safe to
remove from the unsupported list.
Bug: 170729553
Test: Treehugger
Merged-In: I626caf7c1fe46c5ab1f39c2895b42a34319f771a
Change-Id: I54e5ecd11e76ca1de3c5893e3a98b0108e735413
These are APIs that have @UnsupportedAppUsage but for which we don't
have any evidence of them currently being used, so should be safe to
remove from the unsupported list.
Bug: 170729553
Test: Treehugger
Merged-In: I8285daa8530260251ecad6f3f38f98e263629ca7
Change-Id: I626caf7c1fe46c5ab1f39c2895b42a34319f771a
These are APIs that have @UnsupportedAppUsage but for which we don't
have any evidence of them currently being used, so should be safe to
remove from the unsupported list.
This is a resubmit of ag/12929664 with some APIs excluded that caused
test failures; see bugs 171886397, 171888296, 171864568.
APIs excluded:
Landroid/bluetooth/le/ScanRecord;->parseFromBytes([B)Landroid/bluetooth/le/ScanRecord;
Landroid/os/Process;->myPpid()I
Landroid/os/SharedMemory;->getFd()I
Landroid/hardware/input/InputManager;->INJECT_INPUT_EVENT_MODE_WAIT_FOR_FINISH:I
Bug: 170729553
Test: Treehugger
Change-Id: I8285daa8530260251ecad6f3f38f98e263629ca7
These are APIs that have @UnsupportedAppUsage but for which we don't
have any evidence of them currently being used, so should be safe to
remove from the unsupported list.
Bug: 170729553
Test: Treehugger
Change-Id: I4c8fd0006f950de9955242e93968fb0996ceb372
The recently added TextUtils.formatSimple() can efficiently format
simple strings, roughly 6.5x faster than using String.format().
This change starts using this new method in hot codepaths identified
from pprof traces, and this CL alone should reduce system_process CPU
usage by 0.24%. Linked bug has detailed pprof screenshots.
Bug: 170978902
Test: atest FrameworksCoreTests:android.text.TextUtilsTest
Exempt-From-Owner-Approval: trivial refactoring
Change-Id: Ie5a21a24be6dfcdb29768fe235e20f050fc111c7
The recently-built Error Prone checker has found many instances where
we're always paying the cost of StringBuilder concatenation, even in
the typical cases where preconditions are successfully met.
Benchmarks have shown that even when replacing these with varargs
formatter strings, the default case is 20x faster.
Bug: 170978902
Test: none
Exempt-From-Owner-Approval: trivial refactoring
Change-Id: If8c00bc73467bfb91ec16c162969c9d26ca53646