Commit graph

84 commits

Author SHA1 Message Date
Yifan Hong
55015ffb82 libcutils: make vendor_ramdisk_available.
Test: builds
Bug: 156098440
Change-Id: I663a3839e402a83ebf31b8a680c61f1e269548f6
2020-10-28 10:57:51 -07:00
Christopher Ferris
0e69160ebc Remove include/backtrace symlink.
This requires a few other changes to support building libutils
properly. It does appear the windows versions of libutils is
referencing CallStack code, but it doesn't seem to cause any problems.
However, I removed those references completely for the windows build.

Also removed a few extra spaces that seem to have accumulated in the
RefBase.cpp.

Bug: 170465278

Test: Builds and libutils unit tests pass.
Change-Id: Ibeee7791b13636b34bdd592c5420fd91620f752a
2020-10-20 12:46:14 -07:00
Dylan Katz
806b3d8619 Removed RWLock fuzzer
The class being fuzzed here was too simple for a fuzzer to be effective at finding crashes that were not working as intended.
To resolve the issue noted in 163775285 would require the fuzzer to simply use RWLock exactly as intended, defeating the point of fuzzing it.
Because of this, we have made the decision to remove this class. It should have a fairly small impact on coverage. In the future,
perhaps a better approach would be fuzzing pthread's rwlock methods directly.
Test: Made sure the project still builds without RWLock_fuzz.

Signed-off-by: Dylan Katz <dylan.katz@leviathansecurity.com>
Change-Id: Id5e77d053dc800a982176802dc506d26b54d810f
2020-09-11 11:03:02 -07:00
Siarhei Vishniakou
1329696700 Move PropertyMap from libutils to libinput
The input code is the only customer of PropertyMap. For easier
maintenance and eventual removal of it, move it to libinput.

Currently, the caller is responsible for managing the lifecycle of the
returned outMap when calling PropertyMap::load. However, the fact that
the function call allocates new memory is not obvious from the function
signature.

In a separate commit, I will refactor the function to return
Result<unique_ptr<>> to make it less errorprone.
In this commit, only move the files around to make code reviews easier.

Bug: 163171599
Test: atest inputflinger_tests
Change-Id: I316084886c3f09a1776fdb449d2f03d0563b66c1
2020-09-02 20:54:38 -07:00
Elliott Hughes
2cfea97ba3 Merge "Add second batch of fuzzers for libutils" 2020-08-10 15:40:44 +00:00
Dylan Katz
7168f2726e Add second batch of fuzzers for libutils
This adds fuzzers for:
- CallStack
- Looper
- LruCache
- Printer
- ProcessCallStack
- PropertyMap
- RWLock
- RefBase
- StopWatch.
Test: Ran each fuzzer for 10 minutes. Rough coverage est. (likely far below actual value): 10.97%

Signed-off-by: Dylan Katz <dylan.katz@leviathansecurity.com>
Change-Id: I2f9f35c18b13338c282fb7f9c3ea4099ecb2c56f
2020-08-07 15:36:39 -07:00
Yo Chiang
5b028bab2a Move SingletonTest back to libutils_test
Use the new "data_libs:" to specify test library dependency. This is
like "data:" and it treats compiled libraries as test data files.
The result is libutils_test_singleton{1,2} is picked up by libutils_test
and installed next to the test binary.

Mark the test libs libutils_test_singleton{1,2} as uninstallable. This
prevents installing libutils_test_singleton{1,2} directly and only
permits installing via "data_libs:".

```
$ m libutils_test
testcases
└── libutils_test
    ├── arm
    │   ├── libutils_test
    │   ├── libutils_test_singleton1.so
    │   └── libutils_test_singleton2.so
    ├── arm64
    │   ├── libutils_test
    │   ├── libutils_test_singleton1.so
    │   └── libutils_test_singleton2.so
    └── libutils_test.config
```

Bug: 124838889
Test: atest libutils_test
Change-Id: I432135e128fc9eedb1b8c18a331957e271d8b0f0
2020-07-10 19:34:53 +08:00
Steven Moreland
9c832028c1 libutils: integer sanitization
For sanity.

Fixes: 160342252
Test: manually introduce overflow for "ubsan: mul-overflow"
Change-Id: I292039eaef24582f05dd9f0fef011f0ece8364ed
2020-07-07 22:37:07 +00:00
Victor Khimenko
7428c52ef2 Make libbacktrace buildable for native_bridge
Bug: http://b/153609531

Test: m -j64 libbacktrace.native_bridge

Change-Id: I2b8a881b4e952f3b68dbcaeb14f147a6d955b406
2020-06-18 22:02:46 +02:00
Elliott Hughes
842e1cc17e Make systemTime() abort on bad input.
There's no CHECK in libutils, sadly.

Bug: http://b/157167405
Test: treehugger
Change-Id: I1532bf80ba7fdafad016610be3c782b547417126
2020-05-27 15:31:55 -07:00
Dylan Katz
9d5845bb5e Add fuzzers for libutils classes
Adds fuzzers for BitSet, FileMap, String8, String16, and Vector.
Test: Ran fuzzers on Android Pixel 3a. Aggregate coverage was 1.2% (this is far lower than true coverage due to shared libraries being counted)

Change-Id: I739216fe88afa51dc2f73b857da91116853382f0

Removed unneeded cflags, moved libbase to defaults

Test: Built Android.bp successfully

Signed-off-by: Dylan Katz <dylan.katz@leviathansecurity.com>
Change-Id: I739216fe88afa51dc2f73b857da91116853382f0
2020-05-15 10:30:16 -07:00
Jooyung Han
7ea0d74bc8 Set min_sdk_version to be part of mainline modules
Modules contributing mainline modules (APK/APEX) should set
min_sdk_version as well as apex_available.

For now setting min_sdk_version doesn't change build outputs.
But build-time checks will be added soon.

Bug: 152655956
Test: m
Change-Id: Ida890adfe6dfac79267fc0e18b63d2330266438c
2020-05-13 08:18:06 +09:00
Jiyong Park
8bf9b1632e Set apex_available property
The marked library(ies) were available to the APEXes via the hand-written
whitelist in build/soong/apex/apex.go. Trying to remove the whitelist
by adding apex_available property to the Android.bp of the libraries.

In this change, following libs were made available to all apexes because
their usage is quite common and there is no reason to restrict them
to some APEXes.

* libbase_headers
* libcutils, libcutils_headers
* libutils_headers, libsystem_headers
* liblog_headers
* libbacktrace, libbacktrace_headers
* libcrypto_utils

Bug: 150999716
Test: m
Change-Id: If3d3652e6604ed4f6d7694fe7ac61ae496621026
2020-03-09 16:38:02 +09:00
Elliott Hughes
f77f6f003c Remove various bits of dead code and unused workarounds.
Test: treehugger
Change-Id: I68fcd5da304d04ff4da3c3f3712fb79ce6b5791e
Merged-In: I68fcd5da304d04ff4da3c3f3712fb79ce6b5791e
2020-02-22 16:53:24 +00:00
Jeffrey Huang
18986cb220 Add apex available to libutils
Bug: 145922701
Test: m -j
Change-Id: I32a15359bc2f97675f8b5e7e112978667f43bf4f
2020-02-12 17:57:04 -08:00
Steven Moreland
591cab8cee Add statusToString function.
For libbinder, not having these statuses printed out causes never ending
problems for developers.

Bug: 144534032
Test: libhidl_test tests this, which is on TH here
Change-Id: I02f37fb1e5b743131598ddc95ef89ebdfbdff615
2019-11-18 17:38:22 +00:00
Treehugger Robot
f613b4a9a6 Merge "Reland "libutils: Introduce StaticString16""" 2019-09-06 02:29:23 +00:00
Vic Yang
9fb93edd5b Reland "libutils: Introduce StaticString16""
This reverts commit 1270e4fbf1.

Bug: 138856262
Test: Run unit tests.
Change-Id: I37be01d7d4f98a83078870cb0917275336fa2bbd
Merged-In: I8da93f2c9b95183e32d4a2ea895f90c449abbe4d
2019-09-05 13:19:14 -07:00
Steven Moreland
c732c03482 compare android::Vector and std::vector
Have been wondering for a while.

Test: libutils_benchmark
--------------------------------------------------------------------
Benchmark                          Time             CPU   Iterations
--------------------------------------------------------------------
BM_fill_android_vector          24.6 ns         24.5 ns     28207074
BM_fill_std_vector              5.24 ns         5.21 ns    130675479
BM_prepend_android_vector       5783 ns         5770 ns       100000
BM_prepend_std_vector           5731 ns         5717 ns       100000

Change-Id: Ie296ce2c4395121b6a456d57421f820909418afe
2019-09-03 18:11:43 -07:00
Kevin Han
1270e4fbf1 Revert "Reland "libutils: Introduce StaticString16"""
This reverts commit c55ac92bd6.

Reason for revert: Breaks down-stream branches. See b/140315617

Change-Id: I4937fdf4bdcc7a44d5f10700ecf2d5e96aef7d27
Merged-In: I8da93f2c9b95183e32d4a2ea895f90c449abbe4d
2019-08-30 23:50:38 +00:00
Vic Yang
c55ac92bd6 Reland "libutils: Introduce StaticString16""
This time with old branches excluded.

Bug: 138856262
Test: Run unit tests.
Change-Id: Id0bb1d54b71e38244d64f1b684db1fda81de854c
Merged-In: I8da93f2c9b95183e32d4a2ea895f90c449abbe4d
2019-08-30 11:01:27 -07:00
Vic Yang
86eaa8de78 Revert "libutils: Introduce StaticString16"
This reverts commit d4cb489434.

Reason for revert: Breaking aosp_bonito-userdebug

Change-Id: Iea72f39d40f476002ce0ad6b5ce3b4e1ca570de7
2019-08-29 22:47:07 +00:00
Vic Yang
d4cb489434 libutils: Introduce StaticString16
This is a backward compatible implementation of compile time
constructed String16 support.

As much as we'd like a regular constexpr constructor for String16, we
want to make sure the regular non-static String16 does not regress.
We also need to make sure prebuilts built with previous version of
String16 still works with new libutils.  This means we cannot change
the size of String16 objects and we cannot make anything virtual.

To add a flag to indicate whether a String16 is static without
increasing the size of non-static String16 objects, we repurpose a
reserved field in SharedBuffer as "for client use".  With this, we can
tag every String16 and perform memory operation differently based on
how the underlying buffers are allocated.

By using StaticString16, we are able to eliminate the runtime
construction of a String16 and move it out of .bss section.

Bug: 138856262
Test: Run newly added unit tests.
Change-Id: I72bb8dc27a59b9ef34e0d934bc1e00b0f675855a
2019-08-09 11:01:37 -07:00
dimitry
454ba7ec88 Enable native_bridge_support for libutils
Android build system added support for building translated binaries
used on natively bridged targets (arm on x86 for example).

However in order to avoid building unnecessary binaries and libraries
for such architectures most modules do not support native bridge by default.

All needed modules have to explicitly indicate if they may be used as part
of translated binary build.

This change enabled native bridge support for libutils which is a
greylisted library (available for apps targeting Android version < N).

Bug: http://b/77159578
Test: make
Change-Id: I58667558d2a673fc0d882cf623b7a1b6f6f305ec
2019-05-16 13:48:17 +02:00
Steven Moreland
d33a2ee172 libutilscallstack: removed from darwin
libbacktrace only includes its Backtrace.cpp on the linux targets
but not windows or darwin targets. So, both should be disabled.

Previously, libutilscallstack was only ever a static library on
these platforms. Since nothing provided the symbols, these targets
couldn't have been used.

Fixes: 129636352
Test: m

Change-Id: I3f0b09e1d67c485b3ea57f58d1220d9516b326f2
2019-04-01 15:16:13 -07:00
Steven Moreland
e6132be529 libutils/libcutils: make host more like device
Having shared host libraries allows libraries depending on these to use
'shared_libs' for these. This simplifies configurations since these
libraries don't have to specify 'shared_libs' on all non-host targets.

Bug: 124524556
Test: build only

Change-Id: I09fb4a4fb66ea0a87cb76b1e6f400c537a11f082
2019-03-28 18:44:32 -07:00
Elliott Hughes
cb65c354a0 Add test_suites to libutils_test.
Also move the singleton test out because our infrastructure can't cope
with tests that have their own test libraries.

Bug: http://b/124838889
Test: atest
Change-Id: Iddce3325a56d44a4288ace2a29921a3e02367413
2019-02-25 12:26:00 -08:00
Elliott Hughes
01705e4f1d Clean up libcutils/libutils tests.
Move tests in the same directory as the corresponding code, so it's
easier to see what is/isn't tested.

Fix naming of libcutils_tests (plural) to match the singular that's more
common (even though the plural makes more sense to me).

Add these two to system/core/'s TEST_MAPPING.

Remove obsolete AndroidTest.xml.

Fix a flaky (timing-dependent) libcutils test.

Test: ran tests
Change-Id: I7e0a31ff45c8a152562bf66fc97161594249366e
2019-02-11 13:15:56 -08:00
Suren Baghdasaryan
9491078300 DO NOT MERGE: Revert "Revert "Add dependencies on libprocessgroup for sched_policy users""
This reverts commit 1bef8c550c.

Reason for revert: AOSP is fixed with new vendor image

Change-Id: Ib341ac80e2f88c13a7815a490ea2d9422ebdf55f
Signed-off-by: Suren Baghdasaryan <surenb@google.com>
2019-01-25 16:49:18 +00:00
Suren Baghdasaryan
1bef8c550c DO NOT MERGE: Revert "Add dependencies on libprocessgroup for sched_policy users"
This reverts commit 02843339f9.

Reason for revert: Broke AOSP

Change-Id: I62f91c0adf440b5da0a145862b04dd27a7016faf
Signed-off-by: Suren Baghdasaryan <surenb@google.com>
2019-01-23 20:43:28 -08:00
Suren Baghdasaryan
02843339f9 Add dependencies on libprocessgroup for sched_policy users
After moving sched_policy functions into libprocessgroup its users require
additional dependency and inclusion of sched_policy_ctrl.h header.

Exempt-From-Owner-Approval: janitorial

Bug: 111307099
Test: builds, boots

Merged-In: Icc052080e1bce46ce06f7264446950cab0490a95
Change-Id: Icc052080e1bce46ce06f7264446950cab0490a95
Signed-off-by: Suren Baghdasaryan <surenb@google.com>
2019-01-22 18:19:45 +00:00
Josh Gao
f0ea1e6e5d libutils: use libbase_headers instead of libbase.
Bug: http://b/121391019
Test: treehugger
Change-Id: I0e5d218b9afe6f832cc6bd0ef78bc1a5581f3e2f
2019-01-02 14:31:26 -08:00
Chih-Hung Hsieh
502f4864d6 Suppress implicit-fallthrough warnings.
Add FALLTHROUGH_INTENDED for clang compiler.

Bug: 112564944
Test: build with global -Wimplicit-fallthrough.
Change-Id: I40f8bbf94e207c9dd90921e9b762ba51abab5777
2018-09-17 16:50:11 +00:00
Elliott Hughes
85528e8a75 Move off safe-iop.
Bug: http://b/25224572
Test: ran tests
Change-Id: I6687015eedb28c69d1f57c9d3cd7324d4995e47a
2018-08-28 13:40:04 -07:00
Josh Gao
2d08ae57d4 libutils: switch Looper's fds to unique_fd.
Switch Looper to using unique_fd for its owned file descriptors, to
benefit from fdsan.

Bug: http://b/111560345
Test: treehugger
Change-Id: I8efff7741ed19fd71f82f7e604b4f1c66fc5ea2b
2018-07-18 18:12:12 -07:00
Jiyong Park
011ee12b1d Shared libs are supported in recovery mode
adbd has been built as a static executable since the same binary was
copied to the recovery partition where shared library is not supported.
However, since we now support shared library in the recovery partition,
adbd is built as a dynamic executable.

In addition, the dependency from adbd to libdebuggerd_handler is removed
as debuggerd is handled by the dynamic linker.

A few more modules in /system/core are marked as recovery_available:
true as they are transitive dependencies of the dynamic linker.

This change also includes ld.config.recovery.txt which is the linker
config file for the recovery mode. It is installed to /etc/ld.config.txt
and contains linker namespace config for the dynamic binaries under
/sbin.

Bug: 63673171
Test: `adb reboot recovery; adb devices` shows the device ID
Test: Select 'mount /system' in the recovery mode, then `adb shell`.
$ lsof -p `pidof adbd` shows that libm.so, libc.so, etc. are loaded from
the /lib directory.

Change-Id: I363d5a787863f1677ee40afb5d5841321ddaae77
2018-06-10 08:32:24 +09:00
Jiyong Park
612210c75b Mark as recovery_available: true
Libraries that are direct or indirect dependencies of modules installed
to recovery partition (e.g. toybox) are marked as recovery_available:
true. This allows a recovery variant of the lib is created when it is
depended by other recovery or recovery_available modules.

Bug: 67916654
Bug: 64960723
Test: m -j
Change-Id: Ie59155c08890e96ce1893fa3687afcf763d7aea3
2018-05-15 09:47:04 +09:00
Jiyong Park
130fea3478 Revert "libutilscallstack is private VNDK-SP"
CallStack.cpp was part of libutils, but has been separated into a new
library libutilscallstack [1] and then made invisible to vendors [2].
However, this is causing problem to the vendors who have been using
the CallStack class from libutils, because the class is no longer
available to them.

In order to support them, marking libutilscallstack as
'vendor_available: true'.

This reverts commit a32678df55.

[1] https://android-review.googlesource.com/c/platform/system/core/+/591954
[2] https://android-review.googlesource.com/c/platform/system/core/+/599754
Bug: 74600214
Test: m -j
Test: 2016/2017 pixel devices boots to the UI and Photo Editing works

Change-Id: Iaa232ed978378b566a4710e2320ee6ed04572e14
2018-03-14 16:21:00 +09:00
Steven Moreland
241b93cfd3 libutils: Remove Static.cpp and darwin hacks.
Bug: N/A
Test: in internal master, the only libraries that reference this
  symbol are:
./prebuilts/sdk/tools/linux/bin/split-select android::gDarwinIsReallyAnnoying
./prebuilts/sdk/tools/linux/bin/aapt android::gDarwinIsReallyAnnoying
./prebuilts/sdk/tools/linux/bin/aapt2 android::gDarwinIsReallyAnnoying
./prebuilts/sdk/tools/linux/lib64/libaapt2_jni.so android::gDarwinIsReallyAnnoying
./prebuilts/sdk/tools/linux/lib64/libaapt2_jni.so android::gDarwinIsReallyAnnoying
+ VNDK libraries
Test: libutils_test

Change-Id: Id39e5ef6438e48fa225ba06dbb59902ca5b60f70
2018-03-06 17:44:08 +00:00
Steven Moreland
9571234e22 libutils: remove subdirs
no longer used in Android

Test/Bug: none

Change-Id: I155d5ade02527bf47893a8bf8bcbb07b0aae53d8
2018-02-23 14:44:22 -08:00
Elliott Hughes
dc699a269f bpfmt.
Bug: N/A
Test: builds
Change-Id: I89ad00e1c4c7e0767bc80a7ac7935a4d55e090ac
2018-02-16 17:58:14 -08:00
Jiyong Park
a32678df55 libutilscallstack is private VNDK-SP
The library isn't intented to be exposed to vendors. It is a platform
private library.

Bug: 72471487
Test: Pixel 2016/2017 boots to the UI. Photo editing works.
Change-Id: Ib0479a43d66d988c2f882688240746bed3213dad
2018-01-25 14:02:08 +09:00
David Sehr
abfb9f3b99 Remove libziparchive dependency on libutils
Prevent future cyclic dependency from libunwind changes.

Bug: 66919073
Test: make -j 50
Change-Id: I2a4fa5b7c2c3a82db2073d0fa51940da6603be1f
2018-01-18 09:23:53 -08:00
Dan Willemsen
528f144e77 Fix / suppress new unused warnings for mingw+clang
Bug: 69933068
Test: mmma system/core
Change-Id: I089166a979d3d8c5ada38a7745d507b555048499
2017-11-29 21:37:28 -08:00
Chih-Hung Hsieh
122352d983 Use -Werror in system/core
* Move -Wall -Werror from cppflags to cflags.
* Fix/suppress warning on unused variables.

Bug: 66996870
Test: build with WITH_TIDY=1
Change-Id: I1e05e96a1d0bcb2ccef1ce456504b3af57167cc5
2017-11-01 11:32:55 -07:00
Dan Willemsen
f973417005 Merge "Use target.linux for all linux kernel based targets"
am: ab62265fa1

Change-Id: I11e4bd0dae56c350a9839f95b1e85bf30490701d
2017-10-18 22:50:48 +00:00
Dan Willemsen
bdddcab3bd Use target.linux for all linux kernel based targets
Now in Android.bp files, target.linux applies to all targets running a
linux kernel (android, linux_glibc, linux_bionic). So common
flags/sources/etc can be combined instead of copying them to each
target.

Test: m
Change-Id: If7ad138ea1c540c160731f86b6ccc0daa5c69b83
2017-10-16 20:55:39 -07:00
Steven Moreland
95d7cbb77a Add vendor_available to liblog_headers.
Renamed NDK headers to "liblog_ndk_headers"
(these names aren't used anywhere).

libutils_headers now properly export liblog_headers.

Test: with BOARD_VNDK_VERSION=current
Merged-In: I3a85385f588b84393c57fd6d1bcac620f708f0f1
Change-Id: I3a85385f588b84393c57fd6d1bcac620f708f0f1
(cherry picked from commit 42b485cc53)
2017-10-17 12:09:50 +09:00
Steven Moreland
1f64241e2d libutils: liblog export headers
- make liblog dependency for all library builds (this is required
    for files like String8.cpp)
- export liblog headers (because they are used in many header files).

Test: less libraries fail with BOARD_VNDK_VERSION := current
Merged-In: Iecb9cd00deb3a9056ea63c4a087afdb80a51a2b8
Change-Id: Iecb9cd00deb3a9056ea63c4a087afdb80a51a2b8
(cherry picked from commit 43e20cac7b)
2017-10-17 12:08:33 +09:00
Dan Willemsen
348a082469 Merge changes from topic "linux_glibc"
am: 7b3d4da91a

Change-Id: I1cb69992882db5a265234ac808d408f1f136f0e5
2017-10-03 03:03:52 +00:00