Commit graph

559 commits

Author SHA1 Message Date
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
Steven Moreland
3c22033c72 Merge "String8: operator<<" 2020-02-27 23:18:49 +00:00
Steven Moreland
8ef1e1b535 Merge "String*: remove 'StaticLinkage' constructor" 2020-02-26 17:57:07 +00:00
Steven Moreland
b1d3161b7b String8: operator<<
For parity with String16.

Bug: N/A
Test: N/A
Change-Id: I2d7d207138c96146814da31cf27a49cc310e5362
2020-02-25 17:59:54 -08:00
Steven Moreland
bdbd0dde26 Merge "libutils: introduce sp<T>::make" 2020-02-24 17:03:19 +00: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
Steven Moreland
401d69aa94 libutils: introduce sp<T>::make
This is in preparation of doing what we did for SharedRefBase (hiding
operator new) so that clients can't accidentally construct
shared_ptr/unique_ptr or any other alternative memory management scheme
which would conflict with RefBase. You can see what ultimately happened
to SharedRefBase in frameworks/native CL
10d9ddf2e3da3ba3a425fb8396aaaec728e5fbdb.

The goal for this:
- promote use of 'sp<T>::make' over 'sp<T> .. = new T'
- make 'operator new' a private member of RefBase

Bug: 138956784
Test: libutils_test
Change-Id: I47f4d28edbf7534730c7b6fb1de748dd60f34e11
2020-02-20 17:21:27 -08:00
Jeffrey Huang
ab19b995be Merge "Add apex available to libutils" 2020-02-13 06:06:02 +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
824418c370 Merge "String16: operator<<" 2020-02-11 22:43:26 +00:00
Treehugger Robot
6075b1fa9a Merge "Refine set_sched_policy behavior" 2020-02-11 03:25:33 +00:00
Steven Moreland
7a57b8a3cf String16: operator<<
Before, this was printing the pointer to the char16_t* because of an
automatic conversion. However, this is almost never intended.

Bug: N/A
Test: dumpsys_test
Change-Id: Iaafcb2145cf93028cf3271813c56b8b74948f943
2020-02-10 14:18:45 -08:00
Steven Moreland
727a6dd5f5 String*: remove 'StaticLinkage' constructor
Unneeded.

Bug: N/A
Test: N/A
Change-Id: I3ff473d1e2fec98e47abd8abb45dd36e0a808170
2020-02-10 13:56:44 -08:00
Steven Moreland
e90f7f0fb3 Remove String16 header cruft.
-= forward declaration of imported class
-= empty extern decl

Bug: N/A
Test: N/A
Change-Id: I4eba90870f6d2e8d06fb49872cad51ca95da5ad9
2020-02-10 13:26:18 -08:00
Rick Yiu
f7f4442176 Refine set_sched_policy behavior
If a thread priority is greater than or equal to
ANDROID_PRIORITY_BACKGROUND, and the new priority is less than
ANDROID_PRIORITY_BACKGROUND, set the sched policy to its parent process.

Bug: 139521784
Test: functionality verified
Change-Id: Ie6fe33e08e4fda0a119b9869e8dd1733c164d79e
2020-02-07 02:54:57 +00:00
Steven Moreland
306f8b5713 libutils: sp lh comparison w/ pointer
Perhaps the better question is, why have I 100s of times, typed
"ASSERT_NE(nullptr, foo)" for sp<> foo, and got a compiler error and
then change it to "foo.get()". This CL so we can stop wasting cycles
with that error.

Fixes: 147842528
Test: libutils_test
Change-Id: Id63b29d2a1ff3077201a62b69d864c5a826c47e0
2020-01-17 22:50:30 +00:00
Xin Li
b091f4d40b DO NOT MERGE - Merge QQ1A.200105.003 into stage-aosp-master
Change-Id: I307003cb8d6311ed3662535a54ac8586b8a25bd0
2020-01-02 13:29:54 -08:00
Steven Moreland
243f57bb82 libutils: sp/wp: undef #defines
Seems these undefs are slightly out of sync/out of date.

Bug: N/A
Test: libutils_test
Change-Id: I884ae1ca97754a6459a2c7844264f513eecddaba
2019-12-19 16:17:33 -08:00
Steven Moreland
1e8e49cc2c statusToString: parenthesize strerror
For clarity, when printint w/o delination, noticed in b/145776393.

Test: view output of statusToString from a dumpsys change
Change-Id: I5ea9f052c223f167dd58923e2470c852907c97b8
2019-12-10 18:43:53 +00:00
Hans Boehm
5341172587 Add check to sp<> raw pointer constructor
For the raw pointer constructor, check that the argument is not on the
stack. Passing a stack pointer as an sp<> parameter is dangerous,
since we will attempt to deallocate the object once the sp<> is no
longer needed. We approximate ste stack ccheck by testing whether it
is on the same page as the frame pointer.

Do the same for raw pointer assignment.

Bug: 138956784
Test: Boot AOSP
Change-Id: I2c2405be443389af7e6a713aadcb3ee1f372a85e
2019-11-26 15:32:40 -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
Steven Moreland
b5d3e902ff FlattenableUtils::align memsets
Bug: 141890807
Test: boot, check data is zero'd
Change-Id: I45aaeac369f4c5cf3eb44f61c233e00f870a5c79
(cherry picked from commit bf824f8fa5)
(cherry picked from commit e62a9d7669)
2019-11-15 06:15:49 +00:00
Steven Moreland
5f46923634 Trace.h: explicitly use global namespace
Imagine an AIDL file:
  package android.foo;
  interface IFoo {}

The AIDL C++ backend will generate classes like "::android::foo::IFoo".
In order to avoid ODR conflict, the NDK (Stable C) backend linking
against libbinder_ndk puts everything under the "::aidl" namespace. So,
we have "::aidl::android::foo::IFoo". When using ScopedTrace in a class
implementing a class from this backend, there is this problem.

Bug: 141828236
Test: works
Change-Id: Iafadea11788d4c011229657b4f53063bcf65f8d8
2019-11-05 17:59:46 -08:00
Steven Moreland
ae9749a29a libutils: flattenable deprecation comment
This class isn't used very much and it isn't supported by AIDL. In order
to recommend new users against this and recommend an alternative, added
a comment here.

Bug: 142282873
Test: N/A

Change-Id: If7c6c9fac6c868ed6a515e658de752092d25d5f9
2019-10-07 18:14:14 -07:00
Vic Yang
5a141424e6 Fix memory leak in String16
Newly allocated SharedBuffer already has reference count 1, so we
should not call acquire().

Bug: 141764153
Test: Run String16Test.* with ASan that was able to detect the leak
      without this change.
Change-Id: Ib8b1b707b028386d717414d8c5ec5ea7b4b59464
2019-09-27 21:07:00 -07:00
Steven Moreland
1cb99ea59b libutils: Trace.h for everything but windows
libcutils has trace implemented for host. In order to increase code
portability, opening that up for libutils Trace.h usage as well.

Bug: 124524556
Test: use Trace.h on host glinux
Change-Id: Ia873f88e7436a18f6c0f761000bf697c68ffea17
2019-09-20 11:28:00 -07:00
Brett Chabot
1af6acc4d3 Use Android systemTime implementation for host linux.
The Android framework, notably android.view.Choreographer, assumes
that System.nanoTime and SystemClock.uptimeMills return consistent
values. This was true on device, but not on host.

This commit makes those values consistent on host linux. The necessary
support should be in place in kernels 2.6.39 and newer, which have been
available since 2012.

Test: m -j libutils
Change-Id: I833a89a810ae9fb3e8c01f6095ee2aca893c284f
2019-09-19 15:32:33 -07:00
Elliott Hughes
c21c0ac740 Merge "Remove unused big-endian cruft." 2019-09-19 21:26:11 +00:00
Steven Moreland
c1e04d8ac5 libutils: increase test TIMING_TOLERANCE_MS
25 -> 100, because we are seeing larger values sometimes on cuttlefish.

Fixes: 141212746
Test: libutils_test
Change-Id: I371416473b97f46891104ff9d893ec38c25728aa
2019-09-18 20:35:49 +00:00
Elliott Hughes
b6e7de2221 Remove unused big-endian cruft.
Test: builds
Change-Id: I19fef65d311923e4e6dac7307914f5fbb92b7bde
2019-09-18 08:02:10 -07: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
Treehugger Robot
d7546f1d57 Merge "Remove two more unused utf32 functions." 2019-08-02 19:29:45 +00:00
Steven Moreland
18daa7b5f0 libutils: RefBase remove 'basetype' typedefs
useless/unused

Bug: N/A
Test: N/A
Change-Id: I72462a64411a58d22e071f20e2c950bd99fdffb1
2019-07-16 21:06:28 +00:00
Elliott Hughes
9658fc0823 Remove two more unused utf32 functions.
Test: builds
Change-Id: I6ab2104fc6836e9edb772e8368199e6171e9d87a
2019-07-16 07:56:23 -07:00
Steven Moreland
c0927e64b1 libutils: remove references to unimplemented func
printWeakPointer isn't implemented anywhere. This also allows us to
remove a forward declaration of TextOutput.

Bug: N/A
Test: N/A
Change-Id: Ie2debdfda17b7cc1d599c431eaf4c362a591e482
2019-07-11 17:50:52 -07:00
Steven Moreland
0e19f3b4cc Remove utf32 functions.
These don't appear to be used by anything.

Bug: N/A
Test: binary inspection + code inspection
Change-Id: I6c12db26c320a66bcf6e28618c6e9f61b40d985e
2019-07-02 18:15:03 -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
Alessio Balsini
1406207e67 Looper: missing cinttypes when debugging poll/callbacks
When enabling DEBUG_POLL_AND_WAKE or DEBUG_CALLBACKS, compiler complains
for the undefined PRI* fprintf format constants.
Fix by including the missing cinttypes.

Test: m
Bug: none
Change-Id: I0a7b5b45bd274eefa9644cba491a8dc28f1992ff
2019-05-11 20:53:47 +01:00
Treehugger Robot
ee4cc04429 Merge "libutils: more detailed logging." 2019-04-02 02:45:41 +00: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
Elliott Hughes
fd12160087 libutils: more detailed logging.
The question arose on the bug of whether this is a legit errno or just
a stale value.

Bug: http://b/129139241
Test: ran tests
Change-Id: I486176496028f04d4fcccdd0b29a3df6b13849c9
2019-04-01 12:24:19 -07:00
Steven Moreland
43f29072a9 Merge "libutils/libcutils: make host more like device" 2019-03-29 23:05:20 +00:00
Mikhail Naganov
e1a285ddc1 libutils: Fix thread safety annotations in Mutex
The annotations for Mutex::tryLock and timedLock were
incorrectly specifying the return value for the successful
acquisition.

Test: make libutils_test
Change-Id: I9729b6555ede5cb1d6db046e33c35bf5926c7755
2019-03-29 12:21:57 -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