Commit Graph

1681 Commits

Author SHA1 Message Date
vichang
e838a48fd8 Merge "Change the API signature of DateTimePatternGenerator.getBestPattern" am: 19fd56d767 am: a1335e23ac am: c080e7f7f9
Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/1662460

Change-Id: I506cc100dfb0e394948b210ba7cb0a734a0a4c26
2021-04-21 16:14:21 +00:00
Ahaan Ugale
1281143a36 Merge "AutoTranslate: Pad view text for compatibility reasons." into sc-dev 2021-04-19 05:19:53 +00:00
Seigo Nonaka
5681124abb Add FontConfig.Font.getPostScriptName API
Bug: 184003133
Bug: 185508395
Test: atest FontManagerTest#fontManager_PostScriptName
Change-Id: Ie44e0d500c61b37035a0b39039891da13cd6a5ce
2021-04-17 00:46:04 -07:00
Ahaan Ugale
7110641881 AutoTranslate: Pad view text for compatibility reasons.
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
2021-04-16 19:38:28 -07:00
Ahaan Ugale
8c48915e42 UiTranslation: Temporary fix for crash due to length increases.
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
2021-04-05 11:30:01 -07:00
Victor Chang
c8828ee59b Change the API signature of DateTimePatternGenerator.getBestPattern
It's a feedback from the API council.

Bug: 184018008
Test: m droid
Change-Id: I58ced6e0bc174d58008cb1874227bdc39de2d6af
2021-04-01 17:44:52 +01:00
Adam He
59716789f4 Full refactor of Translation APIs.
* Added ViewTranslationRequest/Response
* Added TranslationRequest/ResponseValue
* Removed single TranslationData.
* Moved service.TRequest -> view.TRequest.

Bug: 176208267
Bug: 177371091
Test: atst CtsTranslationTestCases
Change-Id: I25d4bce385d64a8eb9c2a316bd6b5a23e14fb14e
2021-03-05 17:51:03 -08:00
Seigo Nonaka
ecd9b0280b Add @CurrentTimeMillisLong annotation to getLastModifiedTimeMillis
Bug: 180395483
Test: N/A
Change-Id: I7e069f9d193dfbfb07501dc73ad675eb25158e21
2021-02-24 17:48:11 -08:00
Kohsuke Yatoh
5d2f4fc3b3 Merge "Add FontListParser#writeFamily()." into sc-dev 2021-02-09 07:54:43 +00:00
Kohsuke Yatoh
f91ea1b201 Add FontListParser#writeFamily().
Bug: 179103383
Test: atest FrameworksCoreTests:FontListParserTest
Change-Id: I992acd13dc5dc084a00ee9f3832c4d7111ecd4e4
2021-02-08 16:16:56 -08:00
Ahaan Ugale
dba0fb5580 Merge "Fix ellipsis reinitialization for static cached StaticLayout." into sc-dev 2021-02-08 18:08:59 +00:00
Ahaan Ugale
ed6a3111cb Fix DynamicLayout init to use transformed text length.
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
2021-02-05 16:38:52 -08:00
Ahaan Ugale
5b873f1366 Fix ellipsis reinitialization for static cached StaticLayout.
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
2021-02-05 16:35:17 -08:00
Seigo Nonaka
ff85b932d7 Add FontManager#updateFont API
Bug: 173619554
Test: atest FontManagerTest
Change-Id: I261e55783978d9840b06c586389e2126bc6eb2ca
2021-01-29 14:28:46 -08:00
Seigo Nonaka
9387e7f4cd Add more shell command for font
Bug: 173619554
Test: atest UpdatableFontDirTest PersistentSystemFontConfigTest FontManagerTest
Change-Id: I25917fa9e8c42742f74222f25c5ba68d96a2c2fd
2021-01-27 22:59:06 +00:00
Ahaan Ugale
70f17d9f8e Merge "Add initial View's APIs for auto translation" 2021-01-25 21:08:43 +00:00
Seigo Nonaka
46d6a3f9ce Add FontManager API and font manager shell commands
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
2021-01-25 08:51:41 -08:00
Joanne Chung
a5fa9bc0f7 Add initial View's APIs for auto translation
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
2021-01-25 18:57:14 +08:00
TreeHugger Robot
903dc9269f Merge "Refactor font parser for making SystemApi." 2021-01-20 04:18:20 +00:00
Seigo Nonaka
f5859819cd Refactor font parser for making SystemApi.
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
2021-01-19 15:55:41 -08:00
Treehugger Robot
af052be27c Merge "Remove usage of hidden NetworkUtils from Formatter" am: ea47f9ee6c am: 4d36fe858c am: 7e54a837d2
Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/1552501

MUST ONLY BE SUBMITTED BY AUTOMERGER

Change-Id: If7d87e3254064bfb2ceea1317c577b3e910d0452
2021-01-18 13:19:42 +00:00
Remi NGUYEN VAN
d3d76d8063 Remove usage of hidden NetworkUtils from Formatter
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
2021-01-18 17:01:56 +09:00
Kohsuke Yatoh
e5f12abfec Add RESULT_ATTR_DONT_SHOW_UI_FOR_SUGGESTIONS.
Bug: 166304720
Test: atest CtsInputMethodTestCases:SpellCheckerTest
Change-Id: I2f5796d899c79ea1cd6795c16f2011389ae7afea
2020-12-17 00:16:36 +00:00
Jeff Sharkey
c9a074da58 Move DateFormat.zeroPad() back to upstream.
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
2020-12-03 02:40:36 +00:00
Andrei-Valentin Onea
a0fe86bf15 Merge "Update DISALLOW_DUPLICATE_FIELD_IN_SKELETON" am: 5bba56e147 am: 81eb255fa2 am: 0e6d9772c2 am: e945dc22c0
Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/1490737

Change-Id: I276d4f6a2d46042e1342cd4f5801e2fd107cde41
2020-11-09 16:33:13 +00:00
Andrei-Valentin Onea
5bba56e147 Merge "Update DISALLOW_DUPLICATE_FIELD_IN_SKELETON" 2020-11-09 14:58:38 +00:00
Mathew Inwood
f8abe13db4 Merge "Add maxTargetSdk restriction to unused APIs." 2020-11-09 14:41:20 +00:00
vichang
657b17c775 Merge "Move WallTime out of ZoneInfoData" am: 65d1fda8f6 am: 5dbeacab6b am: 829e31941d am: 44e7984238
Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/1490736

Change-Id: I9e82e9cc1091be0fb9378ce61cc76b23c3781830
2020-11-06 19:40:50 +00:00
vichang
44e7984238 Merge "Move WallTime out of ZoneInfoData" am: 65d1fda8f6 am: 5dbeacab6b am: 829e31941d
Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/1490736

Change-Id: Iee0bcc3e378b6d6a802e884f9a69b1d9ae68d19f
2020-11-06 19:20:17 +00:00
vichang
65d1fda8f6 Merge "Move WallTime out of ZoneInfoData" 2020-11-06 18:01:08 +00:00
Andrei Onea
4299e79da7 Update DISALLOW_DUPLICATE_FIELD_IN_SKELETON
Use @EnabledSince instead of @EnabledAfter for DISALLOW_DUPLICATE_FIELD_IN_SKELETON

Test: m
Bug: 172238506
Change-Id: I041e1e2694f310d638e31b475f29d0d214711dd5
2020-11-06 14:55:06 +00:00
Victor Chang
1925c89f8f Move WallTime out of ZoneInfoData
Bug: 139480281
Test: m droid
Change-Id: I4a81bb45e874480c7d1dd5f7736b529344d8d9fa
2020-11-06 11:36:13 +00:00
Mathew Inwood
5d123b6775 Add maxTargetSdk restriction to unused APIs.
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
2020-11-04 09:45:53 +00:00
Mathew Inwood
5f0edaaaf5 Add maxTargetSdk restriction to unused APIs.
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
2020-11-02 10:30:09 +00:00
Mathew Inwood
8e742f928e Add maxTargetSdk restriction to unused APIs.
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
2020-10-29 11:51:12 +00:00
Hongwei Wang
286c33a5c5 Merge "Revert "Add maxTargetSdk restriction to unused APIs."" 2020-10-28 23:58:21 +00:00
Hongwei Wang
050275cd83 Revert "Add maxTargetSdk restriction to unused APIs."
This reverts commit 72f07d6a8a.

Reason for revert: Droidcop-triggered revert due to breakage https://android-build.googleplex.com/builds/quarterdeck?testMethod=testAppZygotePreload&testClass=android.app.cts.ServiceTest&atpConfigName=suite%2Ftest-mapping-presubmit-retry_cloud-tf&testModule=CtsAppTestCases&fkbb=6936597&lkbb=6936969&lkgb=6936551&testResults=true&branch=git_master&target=cf_x86_phone-userdebug>, bug b/171886397

Bug: 171886397
Change-Id: Ibe0f0430a3451477c1ee8ef56a596e91ea1e7672
2020-10-28 20:16:22 +00:00
Mathew Inwood
ee5d369323 Merge "Add maxTargetSdk restriction to unused APIs." 2020-10-28 09:39:20 +00:00
Kohsuke Yatoh
1fa0e0852b Merge "Fix typo in documentation." am: dcaacee8af am: 1d04ebf79b am: fad0f95f46 am: 16e63704ec
Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/1469677

Change-Id: I3570dfa252795302b901ef024084318b20cd1441
2020-10-28 00:39:11 +00:00
Mathew Inwood
72f07d6a8a Add maxTargetSdk restriction to unused APIs.
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
2020-10-27 15:46:07 +00:00
Jeff Sharkey
a0cdb4ca3f Merge "Migrate hot codepaths to formatSimple()." 2020-10-22 20:31:28 +00:00
Jeff Sharkey
305ef9e1cf Migrate hot codepaths to formatSimple().
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
2020-10-22 12:48:13 -06:00
Kohsuke Yatoh
5a6e2cf4ce Fix typo in documentation.
There's no such a thing as SpannedStringBuilder.

Change-Id: I41e1f257bb21807e4fc4943798887519ed5b40a9
2020-10-22 18:44:03 +00:00
TreeHugger Robot
5746484a09 Merge "Fix wrong offset of BiDi text by TextShaper" 2020-10-21 20:05:28 +00:00
Jeff Sharkey
1c08f48253 Apply fixes for EfficientStringsChecker.
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
2020-10-20 22:00:16 -06:00
Jeff Sharkey
caf66d02fd Expand formatSimple() to support widths.
One of the highest-traffic users of String.format() is in the
notification code, which uses argument widths.  To support these
use-cases, this change adds argument width support, with tests.

Bug: 170978902
Test: atest error_prone_android_framework_test
Exempt-From-Owner-Approval: trivial additions
Change-Id: I8e36d4725a6d0cc896dedc5c457eb5f38486d7b6
2020-10-20 21:54:26 -06:00
Seigo Nonaka
170e0949f3 Fix wrong offset of BiDi text by TextShaper
This CL includes:
- Fix relative offset of BidiRun by reviving width calculation in TextLine.
- Fix bidi level buffer offset. It shuold be relative to the substring, but
  the absolute offset was passed.
- Removed paint argument from PositionedGlyph which is not used.

Bug: 171275519
Test: atest android.graphics.text.cts.TextRunShaperTest
Test: atest android.text.cts.TextShaperTest

Change-Id: I36949089d744bdfae61995210b2051866a7510ac
2020-10-19 23:31:35 -07:00
TreeHugger Robot
eac0321ff3 Merge changes from topic "oct16b"
* changes:
  Recommend efficient String operations.
  Simple alternative to String.format().
2020-10-16 22:27:50 +00:00
Jeff Sharkey
af7c5f95cb Simple alternative to String.format().
This purposefully supports only a small handful of substitutions to
improve execution speed.  Benchmarking reveals this optimized
alternative performs 6.5x faster for a typical format string.

Add Preconditions overloads that accept varargs to avoid string
formatting overhead in successful case.

Bug: 170978902
Test: atest FrameworksCoreTests:android.text.TextUtilsTest
Test: ./frameworks/base/libs/hwui/tests/scripts/prep_generic.sh little && atest CorePerfTests:android.text.TextUtilsPerfTest
Change-Id: I3fae4dc95cfc98a61c4a7f07ca0781c4a2ee3be9
2020-10-16 13:44:16 -06:00
Roman Kalukiewicz
34573d564a Merge "Add @Nullable annotation to the parameter of Object.equals() methods." 2020-10-16 01:25:15 +00:00