Commit Graph

743 Commits

Author SHA1 Message Date
Jagadeesh Pakaravoor
87fce10ae7 Merge "Add madvising of .odex, .vdex and .art files" am: fcf61e805a am: 876927e795 am: 252a7a0f4f
Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/1611231

MUST ONLY BE SUBMITTED BY AUTOMERGER

Change-Id: I9d95090140d41f11fc996622c3787a2950194205
2021-03-12 21:32:04 +00:00
Nate Myren
d63065cb6f Merge "Add attributionTag to audio-recordings" into sc-dev 2021-03-11 23:48:44 +00:00
Philip P. Moltmann
fece2436d4 Add attributionTag to audio-recordings
... by switching from packageName/uid/pid to the Identity class.

This allows up to track which parts of the app trigger audio-recordings.

Test: atest CtsAppOpsTestCases
            CtsNativeMediaAAudioTestCases
Fixes: 160150145
Change-Id: I0913a336a862e4a1cb38b9d967cfbdc490513ab0
2021-03-11 08:40:40 -08:00
Jagadeesh Pakaravoor
28a5a1d51b Add madvising of .odex, .vdex and .art files
1. When mmaping {.art, .odex, .vdex} files madvise them to
MADV_WILLNEED
2. Add system properties to limit the madvise size/range

Test: presubmit
Bug: 178853586
Change-Id: I7bd882e3e1021d48f00f297c4dd1d5a8098c087d
2021-03-10 15:39:57 -08:00
Victor Hsieh
f4305279e5 Merge "Move VerityUtils from services.jar to core.jar" into sc-dev 2021-03-10 23:10:25 +00:00
Hans Boehm
1d550ecd10 Merge "Add zygote native fork loop" am: 43a9a8089f am: dd81ed70c7 am: 925ecc3f80
Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/1540230

MUST ONLY BE SUBMITTED BY AUTOMERGER

Change-Id: I3afb617aab80b073b56fa0c61398ae6d42800a75
2021-02-26 17:20:42 +00:00
Alec Mouri
1a621e8eff Merge "JNI wrapper for FpsListener." into sc-dev 2021-02-24 22:41:10 +00:00
Hans Boehm
69d44b0bfd Add zygote native fork loop
Do not return to Java mode between consecutive fork operations.
This greatly reduces the Zygote overhead, since we no longer need to
stop and restart Java daemons.

By not switching back to Java mode, and being careful about what memory
we touch between forks, we also keep the Zygote heaps much more stable,
facilitating page sharing between the zygote and all its children.
Under normal operation we should no longer allocate any memory in the
zygote between forks. That applies to both the Java and C++ heap.
This makes the zygote behave much more like the mental model many
of us had assumed: It has nearly constant memory contents, which are
copy-on-right cloned at each fork. This does not apply to the initial
system server and webzygote forks, that are currently still handled
differently.

This includes

1. Add ZygoteCommandBuffer, and switch the argument parsing code to use it.
This slightly reduces allocation and enables (3).

2. Support process specialization in the child, even when the arguments
are already know, Leverages existing Usap code.

3. Add support for forking multiple child processes directly to the
ZygoteCommandBuffer data structure. This directly uses the buffer
internals, and avoids returning to Java so long as it can handle the
zygote commands it sees.

FUNCTIONALITY CHANGE:

We now limit the total size of the zygote command, rather than the
number of arguments.

Initial performance observations:

[ These are not perfect, since I'm comparing to numbers before I
started. There may have been other moving parts, but they should be
minor. ]

System-server-observed launch latency:

[Not the best metric, but easy to measure. In particular, this
does not represent a significant reduction in application launch
time.]

Based on measuring the last 10 launches in a lightly used cf AOSP
instance, the system server latency from requesting an app launch to
response with the pid (which does not require the child to execute
anything) went from an average of about 10.7(25) msecs to 6.8(9) and
7.9(16) in two tries with the CL. (The parenthetical numbers are
maxima from among the 10; the variance appears to have decreased
appreciably.)

Dirty pages:

The number of private dirty pages in the zygote itself appears to have
decreased from about 4000 to about 2200. The number of dalvik-main
private dirty pages went from about 1500 to nearly zero.

Initially ART benchmarking service claim -1.88% in PSS. But this is not
consistently repeatable.

Drive-by fix:

Call setAllowNetworkingForProcess on usap / native loop path.

Bug: 159631815
Bug: 174211442
Test: Boots AOSP
Change-Id: I90d2e381bada1b6c9857666d5e87372b6a4c1a70
2021-02-23 15:03:40 -08:00
TreeHugger Robot
360c3626e9 Merge "Camera2: Add jpeg encoding support for all camera extensions" into sc-dev 2021-02-23 21:48:35 +00:00
Victor Hsieh
c778551aea Move VerityUtils from services.jar to core.jar
There is a demand to use VerityUtils outside of services from core. This
allows the class to be used from both places.

Bug: 180414192
Test: m

Change-Id: I8da2e3df218547208799a238eab2d54545194d00
2021-02-22 11:00:46 -08:00
Emilian Peev
ab80824153 Camera2: Add jpeg encoding support for all camera extensions
Enable consistent Jpeg output support for all present camera
extensions. Extensions with exclusive YUV_420 support will
include an extra SW encoding pass before the processed results
can be queued back to the client surface.

Bug: 179818844
Test: Camera CTS

Change-Id: I461e54024f150925ca1a5a57ff7b327712ce0e96
2021-02-17 17:37:44 -08:00
Alec Mouri
644553d06f JNI wrapper for FpsListener.
Hidden api for exposing the fps counter to WM Shell, so that the fps for
a task can be reported.

Bug: 174956756
Test: E2E integration with SurfaceFlinger for angry birds
Change-Id: I9818aded2755ad07fd3abf3f616e8e6940bad268
2021-02-12 20:54:05 -08:00
Rafal Slawik
4574305a4a Check CPU time_in_state from one place
Move the check whether CPU eBPF tracking is supported to one place to
avoid repeating it in every reader.

Bug: 179485697
Test: existing tests pass
Change-Id: Id6d23614c3d1dde86b66de14bc09f5976f183625
2021-02-11 15:21:13 +00:00
Rafal Slawik
f278e21a61 Measure total time in state
Total CPU time in state added in https://r.android.com/1538886.

Bug: 174245730
Test: cmd stats pull-source 10095
Change-Id: I6cd27ac172e36d2e889429808bd4bd583795d7c9
2021-01-12 13:45:33 +00:00
Remi NGUYEN VAN
23f93322c2 Merge "Split NetworkUtils and NetworkUtilsInternal" am: 3ed4fd3a89 am: 635d60201d am: edc6b0fb67
Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/1513140

MUST ONLY BE SUBMITTED BY AUTOMERGER

Change-Id: Ief9d6a1fae360dbe1c43d5d6bac4dad5850c004b
2020-12-23 02:22:35 +00:00
Remi NGUYEN VAN
684a7409e6 Split NetworkUtils and NetworkUtilsInternal
NetworkUtils is planned to move to a dedicated JAR for connectivity
classes, while NetworkUtilsInternal would stay in the
frameworks-minus-apex JAR, in the com.android.internal.net package.

Bug: 171540887
Test: m, boots, wifi working
      atest FrameworksNetTests
Change-Id: I3d38d72ad23a4bf84af823c7baeb6fed25c0665f
2020-12-07 19:41:49 +09:00
Jeff Sharkey
7a38dcc938 CharsetUtils alternatives that avoid allocations.
Internally String.getBytes() calls libcore.util.CharsetUtils methods
for a handful of common charsets, but that path requires new memory
allocations for every call.

This change introduces alternative versions of those methods which
attempt to encode data directly into an already-allocated memory
region.  If the destination is to small, callers can detect and pivot
back to calling String.getBytes().

The included benchmarks reveal these raw performance improvements,
in addition to the reduced GC load which is harder to measure:

    timeLocal_LargeBuffer[simple]_mean: 424
    timeLocal_SmallBuffer[simple]_mean: 511
    timeUpstream[simple]_mean: 800

    timeLocal_LargeBuffer[complex]_mean: 977
    timeLocal_SmallBuffer[complex]_mean: 1266
    timeUpstream[complex]_mean: 1468

Bug: 171832118
Test: atest CorePerfTests:android.util.CharsetUtilsPerfTest
Test: atest FrameworksCoreTests:android.util.CharsetUtilsTest
Change-Id: Iac1151e7cb8e88bf82339cada64b0936e1a7578b
2020-11-09 17:22:03 -07:00
Dmitri Plotnikov
313d4a43d1 Rewrite KernelSingleProcessCpuThreadReader to native
For now, the native implementation is identical to the
Java implementation.  The performance improvement is ~20%
in a microbenchmarks.

Bug: 169279846
Test: atest FrameworksCoreTests:com.android.internal.os.KernelSingleProcessCpuThreadReaderTest
Change-Id: I8685a7f0adf9476209e29bb3ee3e89e99f66fa95
2020-10-09 23:50:55 +00:00
Eino-Ville Talvala
7208d0af87 Camera: Remove all camera HALv1 code
- Remove legacy wrapper implementing camera2 API on HALv1
  - Move JNI utility code into SurfaceUtils
- Remove openLegacy path, which allowed HALv1 behavior on HALv3 devices
- Remove relevant tests

Test: atest CtsCameraTestCases
Bug: 136024295
Change-Id: I49ad89bee5c4fdc09e288597821163c81494476f
2020-07-10 11:42:59 -07:00
Florian Mayer
044e2806e5 Merge "Pass -XX:PerfettoHprof=true to ART." am: ec5055f307 am: a37238fde7
Change-Id: I00d60a78092a07f9284590f267f76f01124032a4
2020-05-18 21:15:52 +00:00
Florian Mayer
7dc66b31c1 Pass -XX:PerfettoHprof=true to ART.
Bug: 147667830
Change-Id: Ibc26afc5e9e8744839dce7e863d0635788ad9507
2020-05-18 19:52:48 +02:00
Alec Mouri
cf3ad873dd Dispatch refresh rate callbacks from DMS
AChoreographer will consume these callbacks in lieu of going through SF
for the callbacks. This is so that DMS can update its view of display
configs before apps receive the refresh rate callback so that apps can
get consistent information.

Bug: 154874011
Test: ChoreographerNativeTest
Test: Manually verify that HWUI is receiving callbacks
Change-Id: I992c247fd16ef414f94a259bbd300bea3e4c9467
2020-05-07 19:19:23 -07:00
Robin Lee
9e1181302a Use waitForDeclaredService to get Lights HAL
We cache the reference to the HAL and use a DeathRecipient to keep track
of whether it's still good.

Adds waitForService and waitForDeclaredService to the ServiceManager
Java implementation because they were missing.

Test: atest LightsManagerTest
Test: atest LightsServiceTest
Bug: 152509747
Bug: 154631113
Bug: 154627432
Bug: 154629168
Change-Id: Ife8471f3a7e47b48bb31015ddf40f1d7fef6240f
2020-04-24 16:12:27 +02:00
Elliott Hughes
94cc1b3972 Tell bionic when we overwrite argv[0].
Otherwise bionic might still have a pointer into the old content.

(Cherrypick of 07ce3ccc80c26105f2ccfc8c255353274d8b5861.)

Bug: https://issuetracker.google.com/152893281
Test: treehugger
Merged-In: I25e31c5da33e529c750ef6f2e3f36ca62cf4d231
Change-Id: I25e31c5da33e529c750ef6f2e3f36ca62cf4d231
2020-04-21 16:22:44 -07:00
Elliott Hughes
07ce3ccc80 Tell bionic when we overwrite argv[0].
Otherwise bionic might still have a pointer into the old content.

Bug: https://issuetracker.google.com/152893281
Test: treehugger
Change-Id: I25e31c5da33e529c750ef6f2e3f36ca62cf4d231
2020-04-17 16:15:39 -07:00
Hans Boehm
8242eab297 Don't call exit() with threads running
Otherwise running threads race with destructors.

Bug: 150176543
Test: Build and boot AOSP
Change-Id: I159164a36d9808ae86c2928271b14736178e127b
(cherry picked from commit 0fcf4a605d)
2020-04-14 16:58:42 -07:00
Hans Boehm
0fcf4a605d Don't call exit() with threads running
Otherwise running threads race with destructors.

Bug: 150176543
Test: Build and boot AOSP
Change-Id: I159164a36d9808ae86c2928271b14736178e127b
2020-04-10 18:02:42 -07:00
Muhammad Qureshi
4ef3c3bd26 Delete unused code in stats-log-api-gen
Bug: 145100015
Test: m
Change-Id: Idbbe35fbce0d751a5973128406596678e1ead5d3
2020-03-05 10:21:36 -08:00
Connor O'Brien
140049bce8 Merge changes Ie5fa2605,Ia092e896
* changes:
  Use bpf data when available for single-UID cpu stats
  Use bpf data when available for per-UID cpu stats
2020-02-20 22:45:53 +00:00
Derek Sollenberger
83ccff716f Move android.graphics JNI & APEX files into HWUI
The graphics JNI code is now separate from libandroid_runtime
and it along with HWUI headers are no longer visible to targets
outside the boundary of what is to become the UI mainline module

The exposed headers to targets outside the module are now restriced
to C APIs contained in the apex header directory.

Bug: 137655431
Test: CtsUiRenderingTestCases
Change-Id: I30d34055b6870dc1039f190a88f4a747cee17300
2020-02-19 21:13:34 -05:00
Jean-Michel Trivi
1c4cb8be3b Merge "Rename AudioDevice to AudioDeviceAttributes" 2020-02-19 05:51:11 +00:00
Ryan Mitchell
f2392c6f56 Merge changes from topic "rro_config"
* changes:
  Make overlay config work with immutable non-android overlays
  Add xml configuration of RROs
  Extract system partitions into standalone class
2020-02-19 04:37:26 +00:00
Connor O'Brien
cd834de67c Use bpf data when available for single-UID cpu stats
Update KernelSingleUidTimeReader to read BPF data rather than per-UID
proc files when the BPF data is available. This is implemented by
calling libtimeinstate functions via JNI.
Extend KernelSingleUidTimeReaderTest to exercise both the BPF and proc
file code paths.

Bug: 138317993
Test: KernelSingleUidTimerTest passes
Test: no regression in BatteryStatsTests
Change-Id: Ie5fa2605007e8c5f70a0383bf8adbd81d479abfe
Merged-In: Ie962ddd9e30d96aa0fab6104a4164af9ad02f55e
Signed-off-by: Connor O'Brien <connoro@google.com>
2020-02-19 00:22:14 +00:00
Connor O'Brien
57635c976b Use bpf data when available for per-UID cpu stats
Update KernelCpuUidTimeReader and its subclasses to support reading
frequency, active & cluster times from BPF maps rather than proc files
on devices that support this approach. BPF-based accounting offers
improved accuracy as it can detect every context switch, whereas the
proc files attribute a full tick period to whatever happens to be
running when the tick occurs.
Add a KernelCpuUidBpfMapReader class modeled on
KernelCpuProcStringReader, with singletons for reading each distinct
set of data. These follow the locking approach used by
KernelCpuProcStringReader to ensure thread safety, but they collect
data by calling libtimeinstate functions via JNI rather than reading
text from proc files. They also provide a getDataDimensions() function
to retrieve information currently provided by the header rows of the
proc files, such as the list of available freqs or the number of cores
on each cluster.
Extend the KernelCpu*TimeReaderTest classes to exercise the BPF path
for each reader class, and add a KernelCpuUidBpfMapReaderTest modeled
on KernelProcStringReaderTest.

Bug: 138317993
Test: KernelCpu*TimeReaderTests and KernelCpuUidBpfMapReaderTest pass
Test: no regressions in BatteryStatsTests
Change-Id: Ia092e896028e5f647f6c182de05fa76c7e2e3180
Merged-In: Ie7c0b11a47289e16f72fd6868de4185e858c7e4f
Signed-off-by: Connor O'Brien <connoro@google.com>
2020-02-19 00:20:52 +00:00
Ryan Mitchell
9b93942a80 Add xml configuration of RROs
This change adds the ability to configure the priority, default enable
state, and mutability (previously know as staticness) of an overlay.
Rather than overlays configuring themselves, the system can configure
overlays relative to each other.

An example configuration file looks like:
<config>
    <merge path="auto-generated.xml" />
    <overlay package="com.example.one" mutable="false"
             enabled="true"/>
    <overlay package="com.example.two" mutable="false"
             enabled="true"/>
    <overlay package="com.example.three" enabled="true"/>
</config>

The <overlay> tag configures the overlay while the <merge> tag allows
additional configuration files to be included at a position within
the configuration file.

If the configuration file is not present for a partition, the legacy
android:isStatic and android:priority will continue to configure the
overlays in the partition. Once at least one configuration file has
been defined in any partition, strict partition precedence will be
enforced and overlays on separate partitions will no longer be able
to use android:priority to reorder themselves conversely from the
overlay partition precedence.

The order of the system partitions from least to greatest precedence
is system, vendor, odm, oem, product, system_ext.

Bug: 135048762
Test: atest OverlayConfigTest
Change-Id: If57e8caa9b881f9d424ef48bba80b18cc8b7b943
2020-02-18 16:13:22 -08:00
Connor O'Brien
1746a6df24 Merge changes Ie962ddd9,Ie7c0b11a
* changes:
  Use bpf data when available for single-UID cpu stats
  Use bpf data when available for per-UID cpu stats
2020-02-19 00:06:33 +00:00
Jean-Michel Trivi
0e87bcaf5c Rename AudioDevice to AudioDeviceAttributes
Once AudioDeviceAddress, then AudioDevice, now AudioDeviceAttributes.

Bug: 148565943
Test: atest AudioServiceHostTest#testAudioDeviceAttributes AudioServiceHostTest#testPreferredDeviceRouting
Change-Id: I17b2b8fc6a5eda6ee1176d6aa27ada3cdd820acc
2020-02-18 23:10:46 +00:00
Connor O'Brien
103a7bb6e1 Use bpf data when available for single-UID cpu stats
Update KernelSingleUidTimeReader to read BPF data rather than per-UID
proc files when the BPF data is available. This is implemented by
calling libtimeinstate functions via JNI.
Extend KernelSingleUidTimeReaderTest to exercise both the BPF and proc
file code paths.

Bug: 138317993
Test: KernelSingleUidTimerTest passes
Test: no regression in BatteryStatsTests
Change-Id: Ie962ddd9e30d96aa0fab6104a4164af9ad02f55e
Signed-off-by: Connor O'Brien <connoro@google.com>
2020-02-18 12:25:21 -08:00
Connor O'Brien
5065db0572 Use bpf data when available for per-UID cpu stats
Update KernelCpuUidTimeReader and its subclasses to support reading
frequency, active & cluster times from BPF maps rather than proc files
on devices that support this approach. BPF-based accounting offers
improved accuracy as it can detect every context switch, whereas the
proc files attribute a full tick period to whatever happens to be
running when the tick occurs.
Add a KernelCpuUidBpfMapReader class modeled on
KernelCpuProcStringReader, with singletons for reading each distinct
set of data. These follow the locking approach used by
KernelCpuProcStringReader to ensure thread safety, but they collect
data by calling libtimeinstate functions via JNI rather than reading
text from proc files. They also provide a getDataDimensions() function
to retrieve information currently provided by the header rows of the
proc files, such as the list of available freqs or the number of cores
on each cluster.
Extend the KernelCpu*TimeReaderTest classes to exercise the BPF path
for each reader class, and add a KernelCpuUidBpfMapReaderTest modeled
on KernelProcStringReaderTest.

Bug: 138317993
Test: KernelCpu*TimeReaderTests and KernelCpuUidBpfMapReaderTest pass
Test: no regressions in BatteryStatsTests
Change-Id: Ie7c0b11a47289e16f72fd6868de4185e858c7e4f
Signed-off-by: Connor O'Brien <connoro@google.com>
2020-02-14 21:01:45 -08:00
TreeHugger Robot
650c6a454d Remove libstats_jni from the platform
As part of statsd becoming a mainline module in R,
libstats_jni needs to live in the apex.

Bug: 148620413
Test: m
Test: fastboot flashall

Change-Id: I22c2816c863e7a4462a79ac99238b06aca40a2d6
2020-02-14 14:49:33 -08:00
Evgenii Stepanov
fc27d03bef Refactor NativeHeapTagging compat feature.
Move the logic to startProcessLocked so that it can use app info/flags.

Bug: 135754954
Test: NFC
Change-Id: I50cfb8d0ec4ce1f79dec56b8bef09752a1b37490
Merged-In: Ief86185c6866640700e2548259df9ba1fb617e4d
(cherry picked from commit 5750d3b153)
2020-02-14 10:43:18 -08:00
Derek Sollenberger
db8164c0ac Merge "Move RenderNodeAnimator to android.graphics.animation package" 2020-02-14 16:32:50 +00:00
Evgenii Stepanov
45c350c0a8 Merge changes from topic "allowNativeHeapPointerTagging"
* changes:
  Add android:allowNativeHeapPointerTagging.
  Refactor NativeHeapTagging compat feature.
2020-02-14 01:41:37 +00:00
Derek Sollenberger
8c2f6b6e15 Move RenderNodeAnimator to android.graphics.animation package
A wrapper still exists at android.view.RenderNode animator
as it needs access to internals of the view that would violate
the package layering if moved into android.graphics.animation.

This CL also moves the Java and cpp files associated with creating
a native interpolator that can be run directly on the RenderThread.

Bug: 149293249
Test: CtsViewTestCases
Change-Id: I5260331fedbd634cf2f6d6d392941e7284527420
2020-02-13 16:14:06 -05:00
Siarhei Vishniakou
b01c6135ea Cache VerifiedInputEvent class references
Currently, the variables 'clazz' and 'constructor' are not stored properly.
Cache them to make it consistent with all of the other jni code.

This would also prevent a crash in checkjni for using deleted local
reference (it's never made global in the current code).

Bug: 134977432
Test: atest VerifyInputEventTest (run several times)
Change-Id: Icef5271d915fce49b24d987923942fbdc4b6898b
2020-02-12 17:36:44 -08:00
Evgenii Stepanov
5750d3b153 Refactor NativeHeapTagging compat feature.
Move the logic to startProcessLocked so that it can use app info/flags.

Bug: 135754954
Test: NFC
Change-Id: Ief86185c6866640700e2548259df9ba1fb617e4d
2020-02-12 17:07:34 -08:00
Nicolas Geoffray
ada87ea525 Merge "Use new image location for JIT Zygote." 2020-02-10 14:09:57 +00:00
Nicolas Geoffray
6097439672 Use new image location for JIT Zygote.
Bug:119800099
Test: boots, correct image is being picked up, correct files are being
pinned

(cherry picked from commit 9ac03a0504)

Change-Id: I0fd94e27ec2e8ecd814576efed8363b0e6b6d438
Merged-In: I7add3006b0d72b005daabb6609d954b466985304
2020-02-09 23:02:05 +00:00
Nicolas Geoffray
97f02a4f26 Merge "Use new image location for JIT Zygote." 2020-02-09 22:47:09 +00:00
Nicolas Geoffray
9ac03a0504 Use new image location for JIT Zygote.
Bug:119800099
Test: boots, correct image is being picked up, correct files are being
pinned

Change-Id: I7add3006b0d72b005daabb6609d954b466985304
2020-02-07 22:40:22 +00:00