Commit Graph

15144 Commits

Author SHA1 Message Date
Ytai Ben-tsvi
93f4464b76 Merge "Clean up on client death in SoundTriggerService" 2020-11-11 21:31:39 +00:00
Ytai Ben-Tsvi
3559e8693e Clean up on client death in SoundTriggerService
This change adds tracking of SoundTriggerService client death
and frees up resources whenever that happens.

Test: Kill Now Playing process and observer recovery.
Bug: 171026874
Change-Id: Ie31d0a3ed392b1513b4e81ec3c344f4e79adcf52
2020-11-11 10:12:59 -08:00
Adam Bookatz
b89db6c170 Merge "Remove some unused methods in BSI" 2020-11-11 17:46:17 +00:00
Jeff Sharkey
af7d02531c Merge changes from topic "nov7"
* changes:
  Custom binary XML wire protocol.
  Progress towards efficient XML serialization.
  More efficient alternatives to ByteBuffer.
  CharsetUtils alternatives that avoid allocations.
2020-11-10 23:35:51 +00:00
Kweku Adams
ff6fcd7bcd Check app querying permissions.
We no longer let apps query the existence of other apps (with some
exceptions). Make sure we honor that by always returning false for the
power-allowlist if the calling app doesn't have the required
permissions.

Bug: 166668654
Test: atest DeviceIdleTest
Test: atest CtsSecurityTestCases:DeviceIdleControllerTest
Test: atest FrameworksMockingServicesTests:DeviceIdleControllerTest
Change-Id: I895f1d666a213e141d9fbf08600c611f04f3a7fd
2020-11-10 11:02:27 -08:00
Jeff Sharkey
4ccea87969 Custom binary XML wire protocol.
We've identified that XML writing and reading uses roughly 1.5% of
all system_server CPU, and can generate many temporary objects.

Building on the recent TypedXmlSerializer/PullParser interfaces, this
change introduces new BinaryXmlSerializer/PullParser implementations
that store data using a custom binary wire protocol.  Benchmarking of
a typical packages.xml has shown this new binary approach can write
4.3x faster and read 8.5x faster, while using 2.4x less disk space:

    timeWrite_Fast_mean: 27946635
    timeWrite_Binary_mean: 6519341

    timeRead_Fast_mean: 59562531
    timeRead_Binary_mean: 7020185

A major factor in choosing to invest in this new wire protocol is
that it enables the long-tail of over 100 unique XML schemas used
across the OS internals to be transparently upgraded to gain these
benefits with only minimal changes, reducing the risks associated
with rewriting those schemas.

Finally, since the wire protocol is essentially a serialized event
stream, it's trivial to transparently convert this new protocol
into human-readable XML and vice-versa.  The tests in this change
demonstrate this translation working correctly, and future changes
will introduce new shell tools to aid development work.

Bug: 171832118
Test: atest FrameworksCoreTests:android.util.XmlTest
Test: atest FrameworksCoreTests:android.util.BinaryXmlTest
Test: atest CorePerfTests:android.util.XmlPerfTest
Change-Id: Ib9390701f09562dca952b3786622675b9c68a462
2020-11-10 11:58:03 -07:00
Jeff Sharkey
b5856365b4 Progress towards efficient XML serialization.
We've identified that XML writing and reading uses roughly 1.5% of
all system_server CPU, and can generate many temporary objects.

To set the stage for some long-term improvements, this change
introduces new TypedXmlSerializer and TypedXmlPullParser interfaces
which offer efficient access to primitive attributes and text.

This change also updates XmlUtils to redirect primitive operations
through these new interfaces.

Bug: 171832118
Test: atest FrameworksCoreTests:android.util.XmlTest
Change-Id: I5ba3ad87cf79ca10705a96b98855164a27fee021
2020-11-10 11:56:11 -07:00
Jeff Sharkey
162f86ddce More efficient alternatives to ByteBuffer.
Some upcoming binary XML work needs to efficiently read and write
raw bytes, and we initially started using ByteBuffer.  However, that
design had additional overhead since we were performing bounds checks
twice (once to fill/drain buffers, then again to parse data).  In
addition, the upstream ByteBuffer makes per-byte method invocations
internally, instead of going directly the the buffer.

This change introduces FastDataInput/Output as local implementations
of DataInput/Output which are focused on performance.  They also
handle fill/drain from an underlying Input/OutputStream, and the
included benchmarks show reading 3x faster and writing 2x faster:

    timeRead_Upstream_mean: 5543730
    timeRead_Local_mean: 1698602

    timeWrite_Upstream_mean: 3731119
    timeWrite_Local_mean: 1885983

We also use the new CharsetUtils methods to write UTF-8 values
directly without additional allocations whenever possible.  This
requires using a non-movable buffer to avoid JNI overhead to gain
the 30% benchmarked performance wins.

Bug: 171832118
Test: atest CorePerfTests:com.android.internal.util.FastDataPerfTest
Test: atest FrameworksCoreTests:com.android.internal.util.FastDataTest
Change-Id: If28ee381adb528d03cc9851d78236d985b6ede16
2020-11-10 11:56:06 -07:00
Fiona Campbell
d7bfe1f310 Clean up BrightnessSynchronizer
Create a startSynchronizing() method rather than having this code in the
constructor. This makes it cleaner and its actions more explicit.

Bug: none
Test: manual
Change-Id: I6b84274639ad719ed877f1d04e6621717f860677
2020-11-10 11:21:33 +00:00
Adam Bookatz
db71cc02a2 Remove some unused methods in BSI
BatteryStatsImpl has some recently added methods where formerly we used
A()
now we use
A(int elapsedTime)

Often those old A() calls are now unused and can be removed.

Test: compiles
Test: FrameworksCoreTests
Test: FrameworksServicesTests
Change-Id: I4cac7879db47811ed92455470a660a675db6a4c7
2020-11-09 16:03:49 -08:00
Alison Cichowlas
4f4d34cce6 Merge "Revert "Flip off use of old Chooser targets by default."" 2020-11-09 14:09:05 +00:00
Michael Sun
dfe0fe8583 Merge "Update to use new android.system.suspend.control AIDL interface" am: e40aa2d118 am: b726bcfd65 am: a9b465c8d8 am: f9fd07e735
Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/1480304

Change-Id: I45693209b358a1b1f9691d3729743688b3229172
2020-11-06 19:40:26 +00:00
Michael Sun
f9fd07e735 Merge "Update to use new android.system.suspend.control AIDL interface" am: e40aa2d118 am: b726bcfd65 am: a9b465c8d8
Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/1480304

Change-Id: I1aea5a7ddd2b6b30854683f5133906fa33aab78d
2020-11-06 19:20:04 +00:00
TreeHugger Robot
bf94c12f9d Merge "Reduce the latency between the selection span is adjusted and the toolbar is shown" 2020-11-06 16:56:51 +00:00
Tony Mak
af501bcaf9 Reduce the latency between the selection span is adjusted and the toolbar is shown
Results:
We measure the latency between Editor.startActionModeInternal is called
and FloatingToolbar.show() is called.

When there is only smart action (url)
Before: ~150ms
After ~30ms

When there are 5 smart actions (phone number)
Before: ~400ms
After: ~100ms

Before and after videos:
https://recall.googleplex.com/projects/ea8c4705-96bd-46f0-9f37-786708050727

Fixed a few issues:
1. updateAssistMenuItems() gets the Icons from TextClassification
   object, calls loadDrawable on them and creates the MenuItem
   objects loadDrawable() is slow, especially if we have a lot of
   smart action icons to load. Even worse, we are calling this
   function 4 times in a row when selecting something! 1 time from
   onCreateActionMode and 3 times from onPrepareActionMode.
   The fix here is to avoid reloading the drawable if it is the same
   text classification object.

2. From SelectionActionModeHelper, we call startActionModeInternal
before SelectionModifierCursorController.show()
Internally, SelectionModifierCursorController.show()
show the two selection handles  by calling startHandle.show() and
endHandle.show(). Apparently, each handle.show() call invalidates the
action model right after it is just created! This explains two of the
unnecessary onPrepareActionModel calls.

The fix is to call SelectionModifierCursorController.show()
before startActionModeInternal() is called.

3. Editor.startActionModeInternal() does not invoke
FloatingToolbar.show() right away.
There are two issues here.
a) Editor.startActionModeInternal() ends up calling
FloatingActionModel.repositionToolbar() which hopefully calls
FloatingToolbar.show(). Sadly, it is not the case
because mViewRectOnScreen is not set at that time. mViewRectOnScreen
is set in next onPreDrawCall() call.

b) When mViewRectOnScreen is finally set and calls repositionToolbar()
again , it still won't call FloatingToolbar.show() immediately
because we think that the toolbar is moving by comparing the previous
content rect and the current content rect. They are different because
the previous one is empty(it wasn't shown before). Becoz we think it is
moving, we schedule the FloatingToolbar.show() call after 50ms.

To fix a, we now update mViewRectOnScreen() right away wihout waiting
for the next onPreDraw call().
To fix b, when the previous content rect is moving, we don't consider
the toolbar as moving anymore.

Bug: 169043706

Test: atest android.widget.TextViewActivityTest
Test: atest
cts/tests/tests/textclassifier/src/android/view/textclassifier/cts/TextViewIntegrationTest.java
Test: atest
cts/tests/tests/widget/src/android/widget/cts/TextViewTest.java
Test: Smart select a phone number and then smart select a link.
      Make sure the smart actions menuitems are updated.
Test: Click on a smart linkify link. Then dismiss it by tapping outside.

Change-Id: I634b21ac7ed66a14883dc17e03ef006df5b3f223
2020-11-06 14:36:12 +00:00
Michael Sun
d523796ec5 Update to use new android.system.suspend.control AIDL interface
The suspend_control_aidl_interface is updated, renamed, and splitted
into android.system.suspend.control and
android.system.suspend.control.internal. Update to use the correct
interfaces.

Test: atest FrameworksCoreTests:KernelWakelockReaderTest
Bug: 171598743
Change-Id: I32aa339b27f3d9680a61b7338b1bdb531a1a43f7
2020-11-06 03:44:01 +00:00
Alison Cichowlas
94c73953e4 Revert "Flip off use of old Chooser targets by default."
This reverts commit fb4a768c97.

Reason for revert: PM request

Change-Id: I9f367e2de44618d9e4d5f1787403b2d1e653cb14
2020-11-05 20:18:43 +00:00
Lucas Dupin
377d1337a3 Support tinting blur drawable
In order to achieve the look and feel of colored surfaces, the blur
drawable should be able to receive a color and draw it on top of the
blur region.

Test: manual
Fixes: 172372852
Change-Id: I4cab21e337ca18f617780531368ba70154027b72
2020-11-05 02:29:43 +00:00
Tony Huang
ae7e2fb0bb Merge "Migrate Bubbles to wm-shell (5/n)" 2020-11-04 07:31:30 +00:00
TreeHugger Robot
35615f9bc3 Merge "Instrument CUJ for HUN and App launch from notification" 2020-11-04 06:00:04 +00:00
Tony Huang
eb01a25c87 Migrate Bubbles to wm-shell (5/n)
Move bubbles package and related resources to shell package,
also copied some used codes and resources.

Bug: 161980186
Test: atest SystemUITests
Test: atest WMShellUnitTests
Change-Id: Ia108bd4149b3c3bf86631ba1a7a6bce0e76af78f
2020-11-04 11:01:56 +08:00
TreeHugger Robot
143108846a Merge "Use different perfetto trigger names for each CUJ" 2020-11-03 19:33:58 +00:00
TreeHugger Robot
0824c257af Merge "Flip off use of old Chooser targets by default." 2020-11-03 01:27:08 +00:00
Maryam Karimzadehgan
4611a1ae7d Merge "Add flag to get the name of the Model file from the flag in case we want to try out different models. In addition, we should not log touches in the middle of the screen for logging so moving the block at the very beginning." 2020-11-03 00:28:42 +00:00
TreeHugger Robot
9da1385292 Merge "Remove preRender input" 2020-11-02 22:35:24 +00:00
Sean Stout
5aa2c79d89 Merge "Implement Phase 3 of per-display power states" 2020-11-02 22:22:15 +00:00
Maryam Karimzadehgan
3c2f51c994 Add flag to get the name of the Model file from the flag in case we want
to try out different models. In addition, we should not log touches in
the middle of the screen for logging so moving the block at the very
beginning.

Test: unittest, manual test
Bug: 150170384
Change-Id: I6ecb556fea01f26323248b999d17c7b1d1b7eeb7
2020-11-02 22:05:47 +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
Lucas Dupin
690a360fad Create cross window blur drawable
This introduces BackgroundBlurDrawable that does cross-window blurs
The drawable should not be created manually, it should be retrieved
from the ViewRootImpl

Test: manual
Bug: 159712515
Bug: 171916625
Change-Id: I697e93fc95ba3d0a7211b235b1c5d48a1968b939
2020-11-02 04:26:13 +00:00
Sean Stout
efa2acc6e9 Implement Phase 3 of per-display power states
In this phase a DisplayPowerController is created per-display. However
each display is still controlled by the default display's
DisplayPowerController.

Bug: 138328918
Test: manual - Boot device and toggle display power
Change-Id: I4c608d1e18476a87d2da4bc1c120d62c39db25eb
2020-10-30 17:38:41 -07:00
Alison Cichowlas
fb4a768c97 Flip off use of old Chooser targets by default.
Test: ChooserActivityTest
Bug: 170144291
Change-Id: Ie4e27f0e4506da7ebb97efc3840a64e0c39729b9
2020-10-30 16:43:33 -04:00
Marcin Oczeretko
5d4de563a7 Use different perfetto trigger names for each CUJ
Test: verified build
Bug: 167170986
Change-Id: I87f32358dd06f23da02b7efd8833958646fcc54c
2020-10-30 16:37:03 +00:00
Ahan Wu
1360612760 Instrument CUJ for HUN and App launch from notification
Use InteractionJankMonitor to instrument CUJs, including:
- HUN appear / disappear
- Notification add / remove
- App launch from notification

Bug: 169220845
Bug: 169740111
Test: Manually
Change-Id: I88002f086b49cac15613e754985ab9a8be6bbd52
2020-10-30 15:53:53 +00:00
Alison Cichowlas
0b379c9098 Merge "Always reset viewpager in RTL layouts, whether or not it's tabbed." 2020-10-30 13:35:36 +00:00
Lan Wei
a401308ab7 Merge "Avoid bad InputConnection call crashing the app" 2020-10-29 23:02:32 +00:00
Alison Cichowlas
702cf39534 Always reset viewpager in RTL layouts, whether or not it's tabbed.
Test: Repro instructions in bug
Fixes: 169138573
Change-Id: I889c13150979ae4bf7410f53e3dc0bad798402c1
2020-10-29 16:53:35 -04:00
Winson Chung
e69fdd7ac0 Merge "Allow disabling protolog exceptions" 2020-10-29 16:17:25 +00:00
TreeHugger Robot
7b6e78f975 Merge "Fix the wrong package name to return the wrong resources." 2020-10-29 16:01:03 +00:00
Mathew Inwood
bb05958365 Merge "Add maxTargetSdk restriction to unused APIs." 2020-10-29 15:23:24 +00:00
Taran Singh
72de8ead9e Remove preRender input
Cleanup unused pre-render input. We've no plans to enable it.
It adds unnecessary complexity.

Bug: 159201509
Bug: 167948123
Bug: 118599175

Test: atest CtsInputMethodTestCases

Change-Id: I32fe3759b9aeb56c868f9abf42bab124b9b83374
2020-10-29 07:57:00 -07: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
Chalard Jean
434b1ccbb4 Merge changes I623e2983,I8b95e020 am: ec1966e372 am: bf84b9239b am: 441c5bc2e8 am: d27c16ab39
Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/1479476

Change-Id: Ief538b4dca6dca36686327042beacdb113e323e5
2020-10-29 11:17:30 +00:00
Galia Peycheva
20f62e9098 Merge "Create a window style attribute for background blur" 2020-10-29 11:07:20 +00:00
Chalard Jean
d27c16ab39 Merge changes I623e2983,I8b95e020 am: ec1966e372 am: bf84b9239b am: 441c5bc2e8
Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/1479476

Change-Id: Iacf53dd5c4747e7d394d8aa1f6de2d66bfd80cca
2020-10-29 10:52:05 +00:00
Lan Wei
1e72ef2893 Avoid bad InputConnection call crashing the app
Update InputConnection#getTextBeforeCursor(int, int) and
InputConnection#getTextAfterCursor(int, int) API to
specify that the paramter {@code n} must be non-negative.
If the IME using the API incorrectly, throw
IllegalArgumentException.

Also update these two APIs that return nullable result (no
behaivor change). For editor App, return null for bad case.

Test: atest BaseInputConnectionTest#testInvalidGetTextBeforeOrAfterCursorRequest
Test: atest InputConnectionWrapperTest#testInvalidGetTextBeforeOrAfterCursorRequest

BUG: 169114026

Change-Id: I95169735198f8363c981a61e20234dfebfd645b1
2020-10-29 16:51:49 +08:00
Felka Chang
d168885c07 Fix the wrong package name to return the wrong resources.
It should pass mSuspendingPackage instead of mSuspendedPackage as the
parameter of the getResourcesForApplication.

Root cause: The intellij is very smart to provide the autocomplete
    options and the developer choose the wrong option.
Solution:
    * Add file_pattern in TEST_MAPPING to trigger the CTS tests.
    * The developer should take the autocomplete option very
      carefully especially the options are very alike.

Fixes: 171835218
Fixes: 171779738
Test: atest CtsSuspendAppsTestCases
Test: atest -p frameworks/base/core/java/com/android/internal/app
Change-Id: I0a213e5fcbf207b89f203e25cf1ace1b8406a879
2020-10-29 15:44:27 +08:00
Chalard Jean
1f832406ca Manage VPN legacy state separately from NetworkInfo
This is mainly a cleanup, but is also necessary for the
network selection project.

This is for network selection ultimately because NetworkSelection
needs NetworkAgents to use the newer API introduced in R rather
than the legacy internal API. Using that API forbids communicating
to ConnectivityService through NetworkInfo, and does not support
the FAILED state because there is no usage in connectivity.
In VPN, FAILED is used only to communicate a state to Settings
and it does this through IConnectivityManager.getLegacyVpnInfo,
which already is using an int to communicate this information.

Splitting the legacy state from NetworkInfo not only is simpler
ultimately because it's the format in which it's consumed, but
also will allow removing NetworkInfo completely.

Test: FrameworksNetTests NetworkStackTests
Bug: 167544279
Change-Id: I8b95e020919e38a5166892221096db6271985574
2020-10-29 11:43:20 +09:00
Winson Chung
4fff058e9f Allow disabling protolog exceptions
Bug: 171417169
Test: Build and make sure protologs still works and sysui gradle
      project can build as well
Change-Id: I29684d8b3b5fc49e8179dc15eac9c37cf706322b
2020-10-28 19:27:09 -07: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