Commit graph

937 commits

Author SHA1 Message Date
Steven Moreland
6c509ca3c3 Mark libutilscallstack min sdk version.
Mark this as 29 for easy inclusion in APEXes when debugging. Make
sure we don't introduce calls to things here which would prevent
this from being used on old platforms.

Fixes: 228561718
Test: build
Change-Id: I2574455dbfe681117e4afcf6eef3546be51393fa
2022-04-11 22:30:07 +00:00
Florian Mayer
2b393f3664 Merge "Make callback outlive LruCache." am: 6948bbf62c am: 9e67f9302c am: 877cd36104
Original change: https://android-review.googlesource.com/c/platform/system/core/+/2052189

Change-Id: Ibe676c9758cb914098ea775e05d8f468c0a564e2
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2022-04-01 01:20:50 +00:00
Florian Mayer
e0240d3f61 Make callback outlive LruCache.
The callback can be called by the destructor of LruCache, so it needs to be destructed last.

Bug: 227635615
Change-Id: I7d965a2000c1ec32d9c9e88d25ab0c1ba3e9c739
2022-03-31 20:21:28 +00:00
Treehugger Robot
68876679ff Merge "Tweak linux_glibc properties for musl builds in system/core" am: ec8519e953 am: e06b7e163e am: cd92c351b5
Original change: https://android-review.googlesource.com/c/platform/system/core/+/2044103

Change-Id: I2165ce47c46d4d32a34b9b56f01ff415b09fe08b
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2022-03-30 00:52:07 +00:00
Treehugger Robot
ec8519e953 Merge "Tweak linux_glibc properties for musl builds in system/core" 2022-03-30 00:09:01 +00:00
Treehugger Robot
916624491d Merge "Fix build error from signed/unsigned comparison" am: 98c7076202 am: 9f63827322 am: dd79fa2c8d
Original change: https://android-review.googlesource.com/c/platform/system/core/+/2046028

Change-Id: Ia99c768ecfa04dffc1804f4eb37c5328980f5de7
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2022-03-30 00:05:56 +00:00
Andrei Homescu
1a867dcb6e Fix build error from signed/unsigned comparison
Bug: 224644083
Test: m
Change-Id: I9adbe1ea53193d8c59f9022754cd3e23533e54ad
2022-03-29 00:30:34 +00:00
Colin Cross
10bbb01823 Tweak linux_glibc properties for musl builds in system/core
For convenience, builds against musl libc currently use the
linux_glibc properties because they are almost always linux-specific
and not glibc-specific.  In preparation for removing this hack,
tweak the linux_glibc properties by either moving them to host_linux,
which will apply to linux_glibc, linux_musl and linux_bionic, or
by setting appropriate musl or linux_musl properties.  Properties
that must not be repeated while musl uses linux_musl and also still
uses the linux_glibc properties are moved to glibc properties, which
don't apply to musl.  Whether these stay as glibc properties or get
moved back to linux_glibc later once the musl hack is removed is TBD.

Bug: 223257095
Test: m checkbuild
Test: m USE_HOST_MUSL=true host-native
Change-Id: I076fa026d7dddfccfa5cc395dd06bdc979eee1d8
2022-03-24 15:59:08 -07:00
Treehugger Robot
8da2dbe534 Merge "Fix TEMP_FAILURE_RETRY on non-GNU C++ dialects" am: addba34668 am: aae9c4ec53 am: 5c3f7bd328
Original change: https://android-review.googlesource.com/c/platform/system/core/+/2025446

Change-Id: I73dae25afe75e8e26f365898685a6a17d6ff635d
2022-03-17 06:31:05 +00:00
Treehugger Robot
1727c0c622 Merge changes Iee0932b5,I0d77c490 am: f8cd69af8b am: e8c3bd931b am: 4db635bb0a
Original change: https://android-review.googlesource.com/c/platform/system/core/+/2025448

Change-Id: Ic6452433dc944a8d53dc78c70815e18492f9f61b
2022-03-16 23:22:07 +00:00
Andrei Homescu
fcbc96191c Fix TEMP_FAILURE_RETRY on non-GNU C++ dialects
TEMP_FAILURE_RETRY uses typeof which is only allowed by gcc and clang
for GNU dialects. This switches to __typeof__ which is always supported.

Bug: 224644083
Test: m
Change-Id: I96d48d2f0dc5cd9ab903755d93c71c4eb80f7529
2022-03-16 20:54:31 +00:00
Andrei Homescu
aa4ebf2ce1 Fix Errors.h on systems that define NO_ERROR
Some systems (originally only Windows) define their own
NO_ERROR macro that overlaps with the enumerator from Errors.h.
The enumerator is only defined if the macro was not.

Bug: 224644083
Test: m
Change-Id: Iee0932b5259b3bfcf6494656b27e6e7488319f5c
2022-03-16 02:15:04 +00:00
Andrei Homescu
5c15de21da Disable call stacks on every OS except Linux/Android
To keep libutils (and consequently libbinder) as compact
and portable as possible, this disables call stacks on all
operating systems except Linux and Android.

Bug: 224644083
Test: m
Change-Id: I0d77c49022e852c2b8607f555174c4f9d54ed3df
2022-03-16 01:35:19 +00:00
Steven Moreland
91de6f1de6 Merge "libutils: ~RefBase more logs" am: 83785021f7 am: 976ee88aac am: 522182dff3
Original change: https://android-review.googlesource.com/c/platform/system/core/+/2021996

Change-Id: Ia8aa98d8fa07b4994f767ce78e1d50e7f2130eba
2022-03-14 18:10:54 +00:00
Steven Moreland
f164de8935 libutils: ~RefBase more logs
This code was a bit confusing because Android runs with an old debug
mode on. The flag around this is removed to make it more clear what
is going on, and the log is promoted D -> W.

Bug: N/A
Test: boot, check logs
Change-Id: I4645b1a7b8e252336a6f9482ce6b57e1b907619d
2022-03-11 02:46:31 +00:00
Treehugger Robot
4c58cef88a Merge "Adding libutils owner smoreland@ as fuzz targets owner for alerts" am: 5520cb3309 am: bb9525cb67 am: 84fd9f8e99
Original change: https://android-review.googlesource.com/c/platform/system/core/+/2016715

Change-Id: Ib21a3e63ac6bde2f2fd6a581050eedd0b0165c8b
2022-03-08 22:50:19 +00:00
Anis Assi
e75dd9a1c1 Adding libutils owner smoreland@ as fuzz targets owner for alerts
Bug: 221891733
Change-Id: I85ff5c754fb2eb85331e84b3dbacd24844d54efc
2022-03-08 19:48:21 +00:00
Treehugger Robot
e76d8254bf Merge "Fix OkOrFail<status_t> conversion ambiguities" am: 5a1f51b070 am: fb78f6f5e4 am: 7826f9a738
Original change: https://android-review.googlesource.com/c/platform/system/core/+/2000911

Change-Id: Ia5c6fc34fe562a143d18acd89688b88e125442b2
2022-02-25 22:34:41 +00:00
Atneya Nair
dde6034eac Fix OkOrFail<status_t> conversion ambiguities
OkOrFail<status_t> has specialized conversions for Result<int, StatusT>
to avoid ambiguous implicit conversion sequences. Since user conversion
operators sequences can be followed by integral promotion, specializing
for integral types is necessary.

Specialize ResultError<StatusT> so calling code() returns a status_t
instead of a StatusT and message() is implemented even when not carrying
a string.
Eventually, these classes should be combined.

Add equality operators for ResultError<StatusT>.

Bug: 219580167
Test: atest Errors_test.cpp
Merged-In: I14acecfd2aef33c40e79ddb091e2f4af9291d837
Change-Id: Ifb5ed3c2d3452b10901e4aeb19368d873225d9ce
2022-02-25 14:27:41 -05:00
Treehugger Robot
81f6c2ec75 Merge "libutils: Remove a little dead code" am: 4a39ba316f am: 0a8e5126ef am: 9637277417 am: 74402be9d1
Original change: https://android-review.googlesource.com/c/platform/system/core/+/1977026

Change-Id: I5fba0be1400bf89bd35692d68f2a518d486a20cb
2022-02-09 00:00:07 +00:00
Steven Moreland
7726d3dd4d Merge "libutils -= libprocessgroup dep" am: a0542fb15f am: 55975b7e0a am: 16149a30a3 am: caa74a6549
Original change: https://android-review.googlesource.com/c/platform/system/core/+/1975707

Change-Id: I88506b52d099fdd120aec12dc517bd8e22b95f2e
2022-02-08 23:59:23 +00:00
Treehugger Robot
4a39ba316f Merge "libutils: Remove a little dead code" 2022-02-08 23:12:39 +00:00
Greg Kaiser
044be6bceb libutils: Remove a little dead code
With our recent change 0455a2c39c,
there's some logic that can be simplified to make this slightly
easier to read.

This CL does not change the behavior of this code.

Bug: 208895940
Test: TreeHugger
Change-Id: I4de2dbaf4406cbb7785df8839bb3ae453186ea69
2022-02-08 07:37:13 -08:00
Treehugger Robot
55eb96b366 Merge "libutils: don't call SetTaskProfiles around priority" am: 82b74d6f15 am: 5d078b5903 am: 15af4f4bf8 am: 14f3fb79e2
Original change: https://android-review.googlesource.com/c/platform/system/core/+/1975808

Change-Id: Id430b68f2e21c9aa28f1e3cdc127ef61d53fae2f
2022-02-08 06:52:45 +00:00
Steven Moreland
39fc18b0cd libutils -= libprocessgroup dep
:)

This pulls in quite a few things into a lot of processes. Removing it
separately, in case the use of SetTaskProfiles needs to be reverted,
removing this as well might cause that revert to have linker errors
if new static users of libutils are introduced in the meantime.

Bug: 208895940
Test: build
Change-Id: Iaf5b5d41328c1b1f50bb32be8a6a1bd3a0c3f22f
2022-02-08 01:56:45 +00:00
Tim Murray
0455a2c39c libutils: don't call SetTaskProfiles around priority
Threads should always be in the same state as their parents. This also
implies that the additional SetTaskProfiles is unnecessary when
creating a new thread.

Test: boots, TH
Bug: 208895940
Change-Id: Id971c6e87d342a695bea106cdd258bc0ef6f7ecb
2022-02-08 01:54:09 +00:00
Colin Cross
bbca067d4b Merge "Use 0 instead of NULL for comparison to char16_t" am: 6a79e8113a am: dc4af935d5 am: 1901114704 am: 41ad47e55a
Original change: https://android-review.googlesource.com/c/platform/system/core/+/1949458

Change-Id: If3a58bde6277971e7289eecef25b7f015d75b0bc
2022-01-14 00:26:18 +00:00
Colin Cross
02a3f958db Use 0 instead of NULL for comparison to char16_t
musl libc defines NULL as nullptr, which is explicitly allowed by
C++11.  nullptr_t cannot be implicitly cast to an integral type.
Use 0 instead.

Bug: 190084016
Test: m USE_HOST_MUSL=true host-native
Change-Id: I0c3b6c94cd69262f574414bf52494333f2f2645a
2022-01-13 13:41:59 -08:00
Jiyong Park
fea77d9a32 Merge changes from topic "or_return" am: e060580c31 am: d1e6b85f7b am: 8a038ec1b0 am: b22a816013
Original change: https://android-review.googlesource.com/c/platform/system/core/+/1945135

Change-Id: Ifd5f0f6b37efad12731c0de0fdc5cb49ee3599d3
2022-01-12 08:37:14 +00:00
Jiyong Park
549a4a638b OR_RETURN supports status_t am: 705abe2d30 am: e1bd3f4b34 am: 29f45b2f1f am: 96413ff019
Original change: https://android-review.googlesource.com/c/platform/system/core/+/1922318

Change-Id: I4c1dc92f6bcb231c6d3578454b1bb3959f8e2faf
2022-01-12 08:37:12 +00:00
Jiyong Park
e1bd3f4b34 OR_RETURN supports status_t am: 705abe2d30
Original change: https://android-review.googlesource.com/c/platform/system/core/+/1922318

Change-Id: I2b4dc2d0a305e95b80fe06a22d2bd69a5d238053
2022-01-12 07:44:37 +00:00
Jiyong Park
e060580c31 Merge changes from topic "or_return"
* changes:
  Sort exported headers of libutils
  OR_RETURN supports status_t
2022-01-12 07:27:41 +00:00
Jiyong Park
8b196a7336 Sort exported headers of libutils
Bug: N/A
Test: build

Change-Id: I658155371ca32a7e9ba7e82f8e43780c515df77b
2022-01-12 09:23:46 +09:00
Jiyong Park
705abe2d30 OR_RETURN supports status_t
This change provide a specialization of android::base::OkOrFail for
status_t. As a result, a statement whose type is status_t can be used
with OR_RETURN.

The specialization also provides conversion operators to Result<T,
StatusT> where StatusT is a wrapper type for status_t. This allows
OR_RETURN macro to be used in newer functions that returns Result<T,
StatusT>.

Example usage:

\#include <utils/ErrorsMacros.h>

status_t legacy_inner();

status_t legacy_outer() {
  OR_RETURN(legacy_inner());
  return OK;
}

Result<T, StatusT> new_outer() {
  OR_RETURN(legacy_inner()); // the same macro
  return T{...};
}

Bug: 209929099
Test: atest libutils_test
Change-Id: I0def0e84ce3f0c4ff6d508c202bd51902dfc9618
2022-01-12 09:20:27 +09:00
Yi Kong
f435470449 Merge "Enable afdo for libutils" am: fe9b4ed7b8 am: 47707fb6fc am: 53b3b69bda am: f0b2856126
Original change: https://android-review.googlesource.com/c/platform/system/core/+/1932625

Change-Id: Iee227087225bb778c67f9798293ee2d196e673b0
2022-01-05 19:48:50 +00:00
Yi Kong
6ee028f165 Enable afdo for libutils
Enable PGO (profile guided optimisation) for better performance.

Test: presubmit
Bug: 195134194
Change-Id: If9abecd830573946fc52b28afd7599800367aa09
2021-12-23 15:57:40 +08:00
Wei Wang
04090da4e5 Merge "libutils: do not follow process's group" into sc-v2-dev am: a2c0b86ad0 am: 0c54932e9e
Original change: https://googleplex-android-review.googlesource.com/c/platform/system/core/+/16434460

Change-Id: I77333110d1a9ff52d7e3f812a1c57caec109ab86
2021-12-13 18:40:44 +00:00
Wei Wang
0c54932e9e Merge "libutils: do not follow process's group" into sc-v2-dev am: a2c0b86ad0
Original change: https://googleplex-android-review.googlesource.com/c/platform/system/core/+/16434460

Change-Id: I06888702e43f9f6fe9e27c1e46cbd86a38db8d23
2021-12-13 18:23:56 +00:00
Wei Wang
e73180f8f5 libutils: do not follow process's group
1) App doesn't have cgroup access and there is no purpose of reading cgroup
for app. For system_server it should be known in foreground group. So
there is no benefit of reading group.

2) Reading cgroup in apps can also cause contention for other cgroup
operations.

3) vendor can change cgroup setting and get_sched_policy may return
incorrect information for get_sched_policy_profile_name.

Test: Boot
Bug: 210011562
Signed-off-by: Wei Wang <wvw@google.com>
Merged-In: I8e8c8b346984781c56ec93c0616121f7d5c99fe5
Change-Id: I8e8c8b346984781c56ec93c0616121f7d5c99fe5
(cherry picked from commit defb7773121545130fff80928ebcd7d6015be1d1)
2021-12-13 10:05:05 -08:00
Wei Wang
d2b270c063 libutils: do not follow process's group
1) App doesn't have cgroup access and there is no purpose of reading cgroup
for app. For system_server it should be known in foreground group. So
there is no benefit of reading group.

2) Reading cgroup in apps can also cause contention for other cgroup
operations.

3) vendor can change cgroup setting and get_sched_policy may return
incorrect information for get_sched_policy_profile_name.

Test: Boot
Bug: 210011562
Signed-off-by: Wei Wang <wvw@google.com>
Change-Id: I8e8c8b346984781c56ec93c0616121f7d5c99fe5
2021-12-10 02:53:08 +00:00
Christopher Parsons
416c0209f0 Merge "Remove libdl from shared_libs" am: aa6964861a am: 48c52fc8b8 am: 596ec7e22f am: 9beeb511f0
Original change: https://android-review.googlesource.com/c/platform/system/core/+/1900970

Change-Id: I52f7223f049e9bb7cf156ff4345c21ddd023b3db
2021-11-30 00:05:07 +00:00
Chris Parsons
820da65897 Remove libdl from shared_libs
This entry is redundant, as system_shared_libs by default includes
libdl.

This should be a no-op change for the current build system, but avoids
an issue on the alternative (experimantal) build system, Bazel.

Test: md5sum libutils.so before/after on aosp_flame, verified no changes
Change-Id: I18f6e67c3e23299a0f1e0ef530a0a809b068dc03
2021-11-29 17:43:04 -05:00
Xin Li
6042b45f56 Merge "Merge Android 12" 2021-10-07 23:50:14 +00:00
Wei Wang
aa2599f0ed Merge changes from topic "sysbg_aosp" am: 1132977223 am: d7c942ad46 am: 808464a9d0 am: 04557e2fd7 am: 4497e13f02
Original change: https://android-review.googlesource.com/c/platform/system/core/+/1847154

Change-Id: I3f936b58d68d0931ee403eca9174a601d192b0a0
2021-10-07 20:24:34 +00:00
Wei Wang
d7c942ad46 Merge changes from topic "sysbg_aosp" am: 1132977223
Original change: https://android-review.googlesource.com/c/platform/system/core/+/1847154

Change-Id: Ida42e219f4782812392b213751560ab969b37b8f
2021-10-07 19:28:56 +00:00
Wei Wang
7ee4980dc2 libutils: use system_background for low prio tasks in framework
Bug: 201428466
Test: Build and boot check system_server's sched group
Signed-off-by: Wei Wang <wvw@google.com>
Change-Id: Iffc47fdaf3ef8fba6eb01a12cf534a0393e3e91c
Merged-In: Iffc47fdaf3ef8fba6eb01a12cf534a0393e3e91c
2021-10-07 17:58:44 +00:00
Wei Wang
1132977223 Merge changes from topic "sysbg_aosp"
* changes:
  task_profiles: add ServicePerformance to legacy device policy
  libutils: use system_background for low prio tasks in framework
2021-10-07 17:54:40 +00:00
Wei Wang
c39d60d114 libutils: use system_background for low prio tasks in framework
Bug: 201428466
Test: Build and boot check system_server's sched group
Signed-off-by: Wei Wang <wvw@google.com>
Change-Id: Iffc47fdaf3ef8fba6eb01a12cf534a0393e3e91c
2021-10-06 13:04:22 -07:00
Treehugger Robot
e93c1abe4b Merge "Looper: Use sequence numbers in epoll_event to track requests" am: 663c692a2d am: 7dc38fe273 am: cf90434fe6 am: 6bf0ea23fd am: 32df321051
Original change: https://android-review.googlesource.com/c/platform/system/core/+/1795650

Change-Id: I1c830749b6c6999363c29c11f9cdb34749446b8d
2021-09-13 13:02:07 +00:00
Treehugger Robot
7dc38fe273 Merge "Looper: Use sequence numbers in epoll_event to track requests" am: 663c692a2d
Original change: https://android-review.googlesource.com/c/platform/system/core/+/1795650

Change-Id: Id4072ec03cbd6f0c5eb6a54d8c37d9dd453cf989
2021-09-13 12:11:00 +00:00
Treehugger Robot
663c692a2d Merge "Looper: Use sequence numbers in epoll_event to track requests" 2021-09-13 11:58:45 +00:00
Prabir Pradhan
729057ab8c Looper: Use sequence numbers in epoll_event to track requests
Previously, Looper internally kept track of the requests to add fds
using the fd value itself. It used an internal sequence number
associated with each request to add a callback to avoid a situation
where a callback is unexpectedly called. However, since it used the fd
value rather than the sequence number to register events into epoll,
there was still a way where unintended hangups could occur.

This exact sequence of events caused unintended behavior in Looper:
- An fd (FD) is added to the looper.
- Looper registers FD into epoll using its FD number.
- FD is closed.
- A hangup event arrives from epoll_wait while the Looper is polling.
Looper is waiting for the lock to process the callback for FD, because
it is blocked by:
- A new fd is created and added to the looper. Since the lowest number
fd is reused, this new fd has the same value as FD.
- The poll request for Looper is now unblocked, so it looks up the
callback associated with FD to process the hangup.
- Since FD is already associated with the new callback, the new callback
is called unintentionally.

This CL uses the sequence number to register fds into epoll. That way,
when we get a hangup from epoll that is associated with a sequence
number, there is no way an unexpected callback will called.

This CL also adds a test to verify this behavior. Due to the
nondeterministic nature of this multi-thread scenario, the test verifies
this scenario repeatedly. Without the fix in Looper, the test is flaky,
but should never fail after the fix.

Bug: 195020232
Bug: 189135695
Test: atest libutils_test --rerun-until-failure
Ignore-AOSP-First: Topic CL aosp/1799831 has a merge conflict with
internal master, resolved in ag/15613419.

Change-Id: Ib4edab7f2407adaef6a1708b29bc52634f25dbb6
2021-09-01 14:52:52 +00:00
Steven Moreland
23995a418e Merge "RefBase: Unknown mFlag meaning" am: 53e977339b am: e5eede1551 am: 53ae3f5a76 am: 132fe54ffc am: 70cba1bd17
Original change: https://android-review.googlesource.com/c/platform/system/core/+/1805816

Change-Id: Id7e70dd78d84932ac5a027f761eb2cdee648bf14
2021-08-24 21:38:27 +00:00
Steven Moreland
e5eede1551 Merge "RefBase: Unknown mFlag meaning" am: 53e977339b
Original change: https://android-review.googlesource.com/c/platform/system/core/+/1805816

Change-Id: I3594e5658cc4759c0552aedb394f397be94d81d5
2021-08-24 20:27:09 +00:00
陈冠有
0cbef728f9 RefBase: Unknown mFlag meaning
Change-Id: I3ddd1895c48c682bdb0868e890c62029710bf1c8
2021-08-22 16:36:36 +00:00
Elliott Hughes
31dd92adba Merge "Split up the system/core/ TEST_MAPPING." am: 0589b7eb94 am: 5153cdee39 am: 58498a6e39 am: e0d2ffe2d1 am: 56d7c7314b
Original change: https://android-review.googlesource.com/c/platform/system/core/+/1797132

Change-Id: I908b94ef68ff5f9ce7508f169b8a4de5308ff6b4
2021-08-18 17:45:22 +00:00
Elliott Hughes
5153cdee39 Merge "Split up the system/core/ TEST_MAPPING." am: 0589b7eb94
Original change: https://android-review.googlesource.com/c/platform/system/core/+/1797132

Change-Id: I49316e97d5997bf5a0e5f7932aa3f1016b4566e6
2021-08-18 16:41:35 +00:00
Elliott Hughes
22e082e87a Split up the system/core/ TEST_MAPPING.
A lot of things had moved out of system/core/ without their TEST_MAPPING
entries having gone with them, reducing the amount of presubmit coverage
for those things.

In order to reduce the likelihood of that happening again, I've pushed
all that remained in the system/core/ TEST_MAPPING down into the
individual subdirectories.

Test: treehugger
Change-Id: Ib75d65f9200fa64ae1552471da6fbe5b7023cf94
2021-08-16 16:37:10 -07:00
Treehugger Robot
a00cc29c3f Merge "Revert "Revert "Remove unused String8::setPathName.""" am: f9a9ee048c am: e9a9a4f071 am: f34b2446bb am: ecee0f136a
Original change: https://android-review.googlesource.com/c/platform/system/core/+/1771595

Change-Id: Ib1db7f5227c72c2202584e5b0d9cc4fe5d7f5a00
2021-07-20 20:46:38 +00:00
Treehugger Robot
f34b2446bb Merge "Revert "Revert "Remove unused String8::setPathName.""" am: f9a9ee048c am: e9a9a4f071
Original change: https://android-review.googlesource.com/c/platform/system/core/+/1771595

Change-Id: I815e30f78c4a129de8186bd1b08278024fdf01d6
2021-07-20 20:07:22 +00:00
Greg Kaiser
d03851e549 Revert "Revert "Remove unused String8::setPathName.""
This reverts commit 70d9fb63e6.

Reason for revert: Outstanding usage of this method removed internally

Change-Id: Idcc00ec261aa1d97f11e47abdb08b10a37b5d20f
Test: Local build; treehugger (which I'll manually confirm runs on the appropriate targets)
2021-07-19 20:19:44 +00:00
Greg Kaiser
cacc47d46e Merge "Revert "Remove unused String8::setPathName."" am: 615bf4ef14 am: 01f3306b69 am: 2cca5cc992 am: 6fd9460002
Original change: https://android-review.googlesource.com/c/platform/system/core/+/1768145

Change-Id: Ia8c79e5a81b73b7d785b3bb14d7afe33efc3cdb1
2021-07-15 14:29:36 +00:00
Greg Kaiser
2cca5cc992 Merge "Revert "Remove unused String8::setPathName."" am: 615bf4ef14 am: 01f3306b69
Original change: https://android-review.googlesource.com/c/platform/system/core/+/1768145

Change-Id: I9856b917353e57b048eeec2d3ed6d157165e1148
2021-07-15 13:56:01 +00:00
Greg Kaiser
70d9fb63e6 Revert "Remove unused String8::setPathName."
This reverts commit c214426e0c.

Reason for revert: This is not unused; broke build internally

Change-Id: I18e8b7954256ae015ad32743fa6a75850b00913e
2021-07-15 13:33:10 +00:00
Elliott Hughes
5814506607 Merge "Remove unused String8::setPathName." am: 40a0664b84 am: 5f7d548dc6 am: 941b1a61b0 am: 5c5854a383
Original change: https://android-review.googlesource.com/c/platform/system/core/+/1765465

Change-Id: Ia505c88c596169a47e07c5f8fb869c0de68b42c2
2021-07-14 22:15:41 +00:00
Elliott Hughes
941b1a61b0 Merge "Remove unused String8::setPathName." am: 40a0664b84 am: 5f7d548dc6
Original change: https://android-review.googlesource.com/c/platform/system/core/+/1765465

Change-Id: If7b66e7de22107110fa595827611f1bb1a83a9dc
2021-07-14 21:48:06 +00:00
Elliott Hughes
c214426e0c Remove unused String8::setPathName.
Test: treehugger
Change-Id: Idc8d7e748b0df4ce8a26227dc73a5eef2b04244f
2021-07-13 17:20:53 -07:00
Treehugger Robot
cbd5c0d396 Merge "libutil: no special copy from StaticString16" am: 7d067aee62 am: ece939ecc9 am: b8e683537f am: 73fcfd0c52
Original change: https://android-review.googlesource.com/c/platform/system/core/+/1751786

Change-Id: I5cc9831a8a940cdead57b4a0811e55eec34092ef
2021-06-30 03:17:45 +00:00
Treehugger Robot
b8e683537f Merge "libutil: no special copy from StaticString16" am: 7d067aee62 am: ece939ecc9
Original change: https://android-review.googlesource.com/c/platform/system/core/+/1751786

Change-Id: Ic13c3a84471160c534b0e84ac5d0987f457eef75
2021-06-30 02:51:49 +00:00
Treehugger Robot
1bdcd5fbbf Merge "String16 is moveable (noexcept)" am: 3551e457ca am: 32ceaa1299 am: dcd1cacbbb am: 131315c51c
Original change: https://android-review.googlesource.com/c/platform/system/core/+/1749261

Change-Id: I2ded754cebb3d529f1adc2413cfa8f11f108a556
2021-06-30 02:18:50 +00:00
Treehugger Robot
dcd1cacbbb Merge "String16 is moveable (noexcept)" am: 3551e457ca am: 32ceaa1299
Original change: https://android-review.googlesource.com/c/platform/system/core/+/1749261

Change-Id: Ia658a7b6ad2c21c83ef109230a4c5f0a7d02068a
2021-06-30 01:48:14 +00:00
Jooyung Han
6f92640d45 libutil: no special copy from StaticString16
String16's ctors already handle static strings, so we don't need a
specialized constructor which accepts StaticString16.

Bug: n/a
Test: libutils_test
Change-Id: I93a1ba70d743ff9c73f113d53ffba73cef6adade
2021-06-30 09:04:29 +09:00
Jooyung Han
98b396e785 String16 is moveable (noexcept)
String16 is still in use by AIDL compiler. Because String16 is not
noexcept-move-constructible, the C++ compiler will complain when it is
used with non-copyable types (such as ParcelFileDescriptor).

For example, when vector<Foo> is resized, copy-ctor of Foo is called,
which is not available.

  parcelable Foo {
    String s;
    ParcelFileDescriptor[] pfds;
  }

By providing noexcept move-ctor for String16, vector<Foo> can be resized
with no problem.

Btw, copy from StaticString16 is specialized for efficiency and move
from StaticString16 don't need to be different from copy.

Bug: 192136980
Test: libutils_test
Change-Id: I13744a2ceebf5781c3ef7f3a04237a6750b0db0a
2021-06-29 10:18:23 +09:00
Elliott Hughes
c341dc774f Merge "Check for overflow in String16::append and String16::insert." into sc-dev am: eec890e173 am: 117b7cd3e9
Original change: https://googleplex-android-review.googlesource.com/c/platform/system/core/+/14940186

Change-Id: I6572e3288efc7e3ac203c8688ea2fc08c8260bfc
2021-06-15 22:50:02 +00:00
Elliott Hughes
e227beedde Merge "Check for overflow in String16::append and String16::insert." into sc-dev am: eec890e173
Original change: https://googleplex-android-review.googlesource.com/c/platform/system/core/+/14940186

Change-Id: I2f6c9abc6b2baf587980224698cdeba4d55ed2a8
2021-06-15 22:34:06 +00:00
Elliott Hughes
eec890e173 Merge "Check for overflow in String16::append and String16::insert." into sc-dev 2021-06-15 22:19:15 +00:00
Elliott Hughes
ddc464cd56 Merge "Check for overflow in String8::real_append." into sc-dev am: 20462789dc am: 78c0d1d623
Original change: https://googleplex-android-review.googlesource.com/c/platform/system/core/+/14941314

Change-Id: Iffb6b98e2db53ba153af2e376b2c4bce31e7a69b
2021-06-15 21:29:52 +00:00
Elliott Hughes
1ce243f7a6 Merge "Check for overflow in String8::real_append." into sc-dev am: 20462789dc
Original change: https://googleplex-android-review.googlesource.com/c/platform/system/core/+/14941314

Change-Id: Ib18670bec989f9ec4ec628647718ed97e81468b3
2021-06-15 21:16:47 +00:00
Elliott Hughes
a6be6f0acb Check for overflow in String16::append and String16::insert.
Bug: http://b/178802681
Bug: http://b/178821065
Test: new tests
Change-Id: I2352ea4c65e3f29e44e2ad6cad20ad610ceace1f
2021-06-10 17:06:26 -07:00
Elliott Hughes
59682761fb Check for overflow in String8::real_append.
Bug: http://b/178822418
Test: new tests
Change-Id: I73631a070ade0689441abe5645ba5a5f64a58675
2021-06-10 16:42:20 -07:00
Treehugger Robot
eb245bc746 Merge "Fix implicit cast from ssize_t to size_t in KeyedVector.h" am: a14beb2dbc am: f4d3b9e85f am: 272d5034c2 am: 88f61126e5
Original change: https://android-review.googlesource.com/c/platform/system/core/+/1715473

Change-Id: I4165604813f52d37862f618fae684fed78e9f495
2021-05-22 05:40:49 +00:00
Treehugger Robot
272d5034c2 Merge "Fix implicit cast from ssize_t to size_t in KeyedVector.h" am: a14beb2dbc am: f4d3b9e85f
Original change: https://android-review.googlesource.com/c/platform/system/core/+/1715473

Change-Id: I938079b95fa8cd7a9978a3713564bf34a7dd9536
2021-05-22 05:01:02 +00:00
Treehugger Robot
a14beb2dbc Merge "Fix implicit cast from ssize_t to size_t in KeyedVector.h" 2021-05-22 03:46:09 +00:00
Vishnu Nair
51b958d57c Fix implicit cast from ssize_t to size_t in KeyedVector.h
Fixes a compiler warning for implicit conversion changes from signed
to unsigned which surfaced when refactoring native input libraries.
Add an explicit cast to avoid adding -Wno-sign-conversion compile
flags.

Test: b libsurfaceflinger_unittest
Bug: b/188792659

Change-Id: I1b9309c3530d6063d5cefcaa31af84d9cebc3f5d
Merged-In: I8866aef7f09ca5173604abe18c586b68bbf12ed6
2021-05-21 16:49:07 +00:00
Vishnu Nair
0878f71613 Fix implicit cast from ssize_t to size_t in KeyedVector.h
Fixes a compiler warning for implicit conversion changes from signed
to unsigned which surfaced when refactoring native input libraries.
Add an explicit cast to avoid adding -Wno-sign-conversion compile
flags.

Test: b libsurfaceflinger_unittest
Change-Id: I8866aef7f09ca5173604abe18c586b68bbf12ed6
2021-05-21 16:45:46 +00:00
Elliott Hughes
3b9238cf0f Merge "Increase coverage of Timers to 100%." am: 2dc28bcfc4 am: 1db66002c1 am: b9a7a9886f am: 72e2e0c164
Original change: https://android-review.googlesource.com/c/platform/system/core/+/1710936

Change-Id: Ib4120727615f6b8e9d4ea963cd6e3d71e81d47be
2021-05-20 21:07:05 +00:00
Elliott Hughes
b9a7a9886f Merge "Increase coverage of Timers to 100%." am: 2dc28bcfc4 am: 1db66002c1
Original change: https://android-review.googlesource.com/c/platform/system/core/+/1710936

Change-Id: Iffe5a4df00e9d4daaf0cbde46e1fb9969fbbc9da
2021-05-20 20:22:27 +00:00
Elliott Hughes
4139da606d Increase coverage of Timers to 100%.
Test: treehugger
Change-Id: I3dda9a1a60c88886e5ef42de72bf341ba6cd0361
2021-05-18 13:10:50 -07:00
Elliott Hughes
d64b91a43b Merge "Remove String16::remove." am: e9c7c5c80c am: 50d6fc417e am: 203cdf89fc am: 1056bd564e
Original change: https://android-review.googlesource.com/c/platform/system/core/+/1704013

Change-Id: I0e980e54b13f53f0dfdd58cad21de886bfda3870
2021-05-13 19:53:26 +00:00
Elliott Hughes
1056bd564e Merge "Remove String16::remove." am: e9c7c5c80c am: 50d6fc417e am: 203cdf89fc
Original change: https://android-review.googlesource.com/c/platform/system/core/+/1704013

Change-Id: I5e718c0920791a41ee4a5638b81465a406d783e1
2021-05-13 19:44:55 +00:00
Elliott Hughes
e9c7c5c80c Merge "Remove String16::remove." 2021-05-13 19:04:33 +00:00
Treehugger Robot
db0a816120 Merge "libutils: remove the unused StopWatch lap functionality." am: 0839837fa4 am: 5c28af9897 am: 038077c1c5 am: 70673be9dd
Original change: https://android-review.googlesource.com/c/platform/system/core/+/1703652

Change-Id: I6e5461a9f1f3d3f7aa4ba8af8e65195896cfe671
2021-05-13 04:53:12 +00:00
Elliott Hughes
2cf0411910 Remove String16::remove.
This function, ironically, is being removed.

Even more amusing, it was never "remove" anyway --- it literally did
the opposite, and removed everything *except* the range you passed to
it, and should probably have been called "keep"!

I'm looking at reimplementing much of libutils, but first I'm improving
test coverage, and literally every test I wrote for this failed. And
then when I fixed the "obvious bugs" in the implementation, I found
there actually were a couple of existing unit tests --- that mostly
served to demonstrate just how counter-intuitive this function was.

Bug: http://b/156999009
Test: treehugger
Change-Id: I41fd85f7c0988070f4039f607d2e57523d862ed9
2021-05-12 20:24:26 +00:00
Treehugger Robot
70673be9dd Merge "libutils: remove the unused StopWatch lap functionality." am: 0839837fa4 am: 5c28af9897 am: 038077c1c5
Original change: https://android-review.googlesource.com/c/platform/system/core/+/1703652

Change-Id: If73e10e9321af420ff32b992a6df4f8dd9e5a911
2021-05-12 19:00:08 +00:00
Elliott Hughes
418e0e0c06 Remove String16::remove tests. am: dc334a7c8f
Original change: https://googleplex-android-review.googlesource.com/c/platform/system/core/+/14508384

Change-Id: Ia7b6aa12097e0ce5151f849c7d395bb7f4d12482
2021-05-12 04:27:02 +00:00
Elliott Hughes
dc334a7c8f Remove String16::remove tests.
These tests are only in internal right now, preventing me from removing
this function entirely. So let's get them out of the way...

Test: treehugger
Ignore-AOSP-First: workaround for presubmit merge conflict
Bug: http://b/35267372
Change-Id: Ib5de178ffad833c87e8e93bfd33e85a0ff504ac0
2021-05-12 03:57:26 +00:00
Treehugger Robot
0839837fa4 Merge "libutils: remove the unused StopWatch lap functionality." 2021-05-12 01:38:10 +00:00
Elliott Hughes
afa6e9fc04 libutils: remove the unused StopWatch lap functionality.
It's not tested, and it's not used. Also remove the fuzzer which is just
wasting CPU cycles.

This gets us to 100% function coverage, 100% line coverage, and N/A
branch coverage for StopWatch.

Test: treehugger
Change-Id: Ib5e08510ef1046a6f2af3f0b8a1c317a8bb39fd4
2021-05-11 16:33:47 -07:00
Treehugger Robot
81fe365db8 Merge "libutils: remove obsolete README." am: c85c9ee4e6 am: 542b434331 am: 47f22f9ba7 am: 6801ff60bb
Original change: https://android-review.googlesource.com/c/platform/system/core/+/1703649

Change-Id: I4cea6f36b9f049f68c9c6f44e7721f51a0decc04
2021-05-11 22:05:17 +00:00
Treehugger Robot
6801ff60bb Merge "libutils: remove obsolete README." am: c85c9ee4e6 am: 542b434331 am: 47f22f9ba7
Original change: https://android-review.googlesource.com/c/platform/system/core/+/1703649

Change-Id: I1c3156ddd57102f5ba29c34b2b3b8474ca1aff7f
2021-05-11 21:46:30 +00:00
Elliott Hughes
af021e87a6 libutils: remove obsolete README.
This dates from when libutils was still part of frameworks, and talks
about stuff that *didn't* move out of frameworks.

Test: treehugger
Change-Id: Icf22eebc417bcb37abdbfdc89e9a3f14894e18c2
2021-05-11 12:01:26 -07:00
Steven Moreland
f59fb81121 Merge "libutils: LightRefBase: incStrongRequireStrong" am: 1c65d40154 am: b31a05bb47 am: 77b47c4185 am: 55862852fe
Original change: https://android-review.googlesource.com/c/platform/system/core/+/1696268

Change-Id: Ied8436e131d709a8f5e5b0c9bb34abffdb4cd7c3
2021-05-05 01:08:44 +00:00
Steven Moreland
55862852fe Merge "libutils: LightRefBase: incStrongRequireStrong" am: 1c65d40154 am: b31a05bb47 am: 77b47c4185
Original change: https://android-review.googlesource.com/c/platform/system/core/+/1696268

Change-Id: Ia753aaf062e8d58c60ca1113922165a2946a9a07
2021-05-05 00:44:45 +00:00
Steven Moreland
c2dc7cd31c libutils: LightRefBase: incStrongRequireStrong
Allow LightRefBase to be used with
ANDROID_UTILS_REF_BASE_DISABLE_IMPLICIT_CONSTRUCTION, mainly for
libhwui.

Bug: N/A
Test: libutils_test
Change-Id: I251c874a80f0a069572bc51da45f8f8e74ba6f5b
2021-05-04 21:42:26 +00:00
Steven Moreland
8eafcc0c7d Merge "libutils: sharedbuffer test - expect greatness!" am: 9dd80b6b04 am: 246739cc61 am: 161d760f31 am: 02ede6f998
Original change: https://android-review.googlesource.com/c/platform/system/core/+/1688812

Change-Id: I1923123c1c81d0cfe533df0102da2e1a63d10814
2021-04-28 22:33:26 +00:00
Steven Moreland
02ede6f998 Merge "libutils: sharedbuffer test - expect greatness!" am: 9dd80b6b04 am: 246739cc61 am: 161d760f31
Original change: https://android-review.googlesource.com/c/platform/system/core/+/1688812

Change-Id: Id6ec8ae3f744c1936faebdd66bb2f32b2e6cf814
2021-04-28 22:12:28 +00:00
Steven Moreland
128826ca07 libutils: sharedbuffer test - expect greatness!
This test previously expected failure - a machine which does not have
2GiB of memory. However, while today is becoming the past,
2GiB allocations working is no longer a dream of the future!

Fixes: 186569165
Test: libutils_test
Change-Id: I6a9ed608c0989d415b4e7735b8a451b8928b4083
2021-04-28 17:15:58 +00:00
Steven Moreland
a06e68cb7a Reland^2 "libutils: disable implicit ref base construction"
This reverts commit 2cb7593792.

Reason for revert: reland after fixing b/186468053
Bug: 184190315

Change-Id: I2a46b7a8148db444f9bd4b24746f64217cbba947
2021-04-27 00:09:23 +00:00
Steven Moreland
2cb7593792 Revert "Reland "libutils: disable implicit ref base construction""
This reverts commit 02c47655e7.

Reason for revert: broke another test b/186468053

Change-Id: I0ec82455ad203071e523092ae3cb5f0f1df6aac7
2021-04-27 00:07:55 +00:00
Steven Moreland
02c47655e7 Reland "libutils: disable implicit ref base construction"
This reverts commit 8e11f9e3f3.

Reason for revert: reland after fixing b/186028624
Bug: 184190315

Change-Id: Ia7339a46c3af7dd1a95bc82327cae5304f9f2e16
2021-04-26 17:19:17 +00:00
Steven Moreland
8e11f9e3f3 Revert "libutils: disable implicit ref base construction"
This reverts commit 9a1bf53c4b.

Reason for revert: b/186028624

Change-Id: Icb8b1623df2794222ce3fe34ed5f43506ccf2f68
2021-04-21 23:24:53 +00:00
Steven Moreland
9a1bf53c4b libutils: disable implicit ref base construction
Ignore-AOSP-First: b/184196278

Bug: 184190315
Test: libutils_test
Change-Id: If47f79a8b96ee75706817081950f9ca5c0d12731
2021-04-19 22:01:35 +00:00
Elliott Hughes
6182b330f2 Merge "Remove move dead code." am: acec0918e5 am: 1fc404900c am: 906a03fc49
Original change: https://android-review.googlesource.com/c/platform/system/core/+/1677028

Change-Id: I7fb50216bcf983584f664a691321683dd79ae38d
2021-04-16 17:53:46 +00:00
Elliott Hughes
4b7b4d6d7b Remove move dead code.
Test: treehugger
Change-Id: I6a23b19d078400dfe90329a49ae1abbcb24ef2bf
2021-04-15 15:18:54 -07:00
Elliott Hughes
b996f3f512 Merge "Remove String8::toUpper()." am: 450f66bd8f am: ca3794ea68 am: 334a0b1c10
Original change: https://android-review.googlesource.com/c/platform/system/core/+/1673886

Change-Id: Ica526ca8cb76065e4008a8dbd494beb795ea1390
2021-04-14 19:58:02 +00:00
Elliott Hughes
450f66bd8f Merge "Remove String8::toUpper()." 2021-04-14 17:36:36 +00:00
Steven Moreland
2efd418005 Merge "libutils: group deprecated RefBase functions" am: 4efe03b492 am: 7e2a6bf3b0 am: 20606f64bd
Original change: https://android-review.googlesource.com/c/platform/system/core/+/1673555

Change-Id: I88aad9df554c90358b019200a26c5adfa0b440a3
2021-04-13 18:50:50 +00:00
Steven Moreland
4efe03b492 Merge "libutils: group deprecated RefBase functions" 2021-04-13 16:47:28 +00:00
Steven Moreland
8c8d361981 libutils: group deprecated RefBase functions
Make it easier to see reference to usage documentation, as requested in
review.

Bug: 184190315
Test: libutils_test
Change-Id: If9056e35b1c7a779dd78f2b986ad10d02f25eaf3
2021-04-12 23:56:07 +00:00
Elliott Hughes
9434f59c17 Remove String8::toUpper().
Actually, it looks like it's only toLower() that's used, so let's remove
toUpper() separately, since it's so easy.

Test: treehugger
Change-Id: I8fae9fa513b2a34d5bd6b3f64e9305a1ee3c1ec4
2021-04-12 13:38:31 -07:00
Elliott Hughes
b546cf8c5c Merge "Remove the weird range variants of String8::toLower() and String8::toUpper()." am: 561209ee66 am: 7e7ff3635d am: 685c0c9a7f
Original change: https://android-review.googlesource.com/c/platform/system/core/+/1670567

Change-Id: Iedb8ab438496e0fa3f6697fb18b060e3a1acbc89
2021-04-12 20:35:29 +00:00
Elliott Hughes
561209ee66 Merge "Remove the weird range variants of String8::toLower() and String8::toUpper()." 2021-04-12 18:51:22 +00:00
Elliott Hughes
a858395f91 Remove the weird range variants of String8::toLower() and String8::toUpper().
I want to remove these bad ASCII-only APIs completely, but it might be
easier to remove the range variants first.

Test: treehugger
Change-Id: I4c11f959a7bd8e670708cc03281ea72e9c461ff7
2021-04-09 13:06:20 -07:00
Treehugger Robot
c33f57b7f9 Merge "Remove String16::makeLower()." 2021-04-09 00:35:09 +00:00
TreeHugger Robot
7c4fc3cbdc Merge "Remove String16::makeLower()." into sc-dev 2021-04-08 23:38:34 +00:00
Treehugger Robot
b0d5c56336 Merge changes I66c97386,Id205c88d am: 05a7dfa104 am: 25d87e4419 am: debdf364bd
Original change: https://android-review.googlesource.com/c/platform/system/core/+/1668805

Change-Id: I15f849b229b1e505111d39983ec0a43ba2bf9841
2021-04-08 19:46:01 +00:00
Elliott Hughes
49cb03211f Remove String16::makeLower().
If you need to do a case transformation for a Unicode string, you need
to use icu4c. This only worked for ASCII, which is just silly. Luckily
it doesn't seem to be used anywhere.

Test: treehugger
Change-Id: I4a864823ec35a0b57b50909587cc3efac3f531a7
Merged-In: I4a864823ec35a0b57b50909587cc3efac3f531a7
(cherry picked from commit c74d97c854)
2021-04-08 17:00:39 +00:00
Steven Moreland
dc43fb279f libutils: wp::fromExisting bugfix
This API was tested before, but it wasn't used until it is needed in
libbinder. Previously it passed the tests because wp::operator==
compares weak_ptrs which are never deleted, but it doesn't check the
value of m_ptr as well. This assumes that the RefBase implementation is
self-consistent.

Future considerations:
- add additional CHECK (perf?)
- add an additional optional CHECK?
- update all refbase tests to use an embellished form of this operator

Bug: 184190315
Test: libutils_test, boot and kill process when libbinder is using this
API

Change-Id: I66c97386d769529d5efae48e06775d4b4a344025
2021-04-07 23:06:09 +00:00
Elliott Hughes
016beb8559 Remove String16::makeLower().
If you need to do a case transformation for a Unicode string, you need
to use icu4c. This only worked for ASCII, which is just silly. Luckily
it doesn't seem to be used anywhere.

Test: treehugger
Change-Id: I4a864823ec35a0b57b50909587cc3efac3f531a7
Merged-In: I4a864823ec35a0b57b50909587cc3efac3f531a7
2021-04-07 22:38:20 +00:00
Steven Moreland
1d68548823 libutils: add sp::cast method
Previously, sp::sp(T*) internally had a static cast, and people
frequently wrote code like this:

    sp<A> a = ...;
    sp<B> b(a.get()); // implicit static cast

Luckily, none of the other sp constructors have this implicit cast. So,
for explicit code, rather than making those use static_cast internally,
adding an sp::cast function.

Bug: 184190315
Test: use in libbinder
Change-Id: Id205c88d03e16cf85ccb8f493ce88b4bbc65a688
2021-04-07 20:30:21 +00:00
Steven Moreland
746757a02f Merge "ANDROID_UTILS_REF_BASE_DISABLE_IMPLICIT_CONSTRUCTION" am: 99037347d6 am: d8c4c860ef am: e1a51daf9b
Original change: https://android-review.googlesource.com/c/platform/system/core/+/1660499

Change-Id: I72e661607a70876fa8f63f95318c3805cb26fb4b
2021-04-05 20:53:01 +00:00
Steven Moreland
da75cef983 ANDROID_UTILS_REF_BASE_DISABLE_IMPLICIT_CONSTRUCTION
In form, inspired by ANDROID_BASE_UNIQUE_FD_DISABLE_IMPLICIT_CONVERSION.

We get occasional bugs about sp double-ownership. When this flag is
enabled, we have:
- you must construct RefBase objects using sp<>::make
- you must construct wp<> objects by converting them to sp<>
- if you want to convert a raw pointer to an sp<> object (this is
  possible since the refcount is used internally, and is used commonly
  on this*), then you must use 'assertStrongRefExists' semantics which
  aborts if there is no strong ref held. That is, if a client uses
  std::make_shared and then calls a function which internally used to
  call `sp<T>(this)`, you would now call
  `sp<T>::assertStrongRefExists(this)`, and the double ownership
  problem would become a runtime error.

Bug: 184190315
Test: libutils_test
Change-Id: Ie18d3146420df1808e3733027070ec234dda4e9d
2021-04-05 17:45:18 +00:00
Steven Moreland
d9a8a7c340 Merge "libutils: better docs for sp<>::make" am: 767f264fa4 am: fb91070a83 am: 2eb2b5edbf
Original change: https://android-review.googlesource.com/c/platform/system/core/+/1663182

Change-Id: I8c21003dbac86e0d57a4cf634f0c9b719f703e0a
2021-04-02 23:14:46 +00:00
Steven Moreland
09b0495b47 libutils: better docs for sp<>::make
Bug: 184190315
Test: N/A
Change-Id: I56621058b9d85122b7dca3727e40c8c85595031f
2021-04-02 17:26:16 +00:00
Treehugger Robot
387c02293b Merge "Disallow exit-time destructors in libutils." am: 1c9f84edeb am: c83480e3f9 am: 3fb1a85148
Original change: https://android-review.googlesource.com/c/platform/system/core/+/1619600

MUST ONLY BE SUBMITTED BY AUTOMERGER

Change-Id: Ib6c5f0d5ca8a144e97e6965556378d626b8a8f6c
2021-03-05 22:55:00 +00:00
Elliott Hughes
48a9eb49ee Disallow exit-time destructors in libutils.
There weren't any, but let's keep it that way.

Test: treehugger
Change-Id: I2a64eed47f41413a43c524af23b3070e5c2083a6
2021-03-04 09:46:23 -08:00
Treehugger Robot
cc3a9ee812 Merge "Add docs to SystemClock.h" am: 0d4089cb1c am: 27e2d3d4fd am: ac92eef968
Original change: https://android-review.googlesource.com/c/platform/system/core/+/1603259

MUST ONLY BE SUBMITTED BY AUTOMERGER

Change-Id: I913b74e6af9332ca30d4f94684439a01c4bf5206
2021-02-24 02:49:43 +00:00
Treehugger Robot
0d4089cb1c Merge "Add docs to SystemClock.h" 2021-02-24 00:03:15 +00:00
Zhomart Mukhamejanov
45e0dc1dae Add docs to SystemClock.h
Test: n/a
Change-Id: I16a41e9b98c88270857fe2a1d6b382bfe469bca6
2021-02-23 12:14:57 -08:00
Bob Badour
994fe355d9 Merge "[LSC] Add LOCAL_LICENSE_KINDS to system/core" am: d0bfde2f78 am: b2145c414a am: 4cf31dacb3
Original change: https://android-review.googlesource.com/c/platform/system/core/+/1591651

MUST ONLY BE SUBMITTED BY AUTOMERGER

Change-Id: I3ea2cdf9470b391f3a1067a9f6eb666fd461d92b
2021-02-21 17:31:20 +00:00
Bob Badour
d69ad69a93 [LSC] Add LOCAL_LICENSE_KINDS to system/core
Added SPDX-license-identifier-Apache-2.0 to:
  bootstat/Android.bp
  cli-test/Android.bp
  code_coverage/Android.bp
  cpio/Android.bp
  debuggerd/crasher/Android.bp
  debuggerd/proto/Android.bp
  diagnose_usb/Android.bp
  fs_mgr/libdm/Android.bp
  fs_mgr/libfiemap/Android.bp
  fs_mgr/liblp/Android.bp
  fs_mgr/libsnapshot/Android.bp
  fs_mgr/libstorage_literals/Android.bp
  fs_mgr/libvbmeta/Android.bp
  fs_mgr/tests/Android.bp
  fs_mgr/tools/Android.bp
  gatekeeperd/Android.bp
  healthd/Android.bp
  healthd/testdata/Android.bp
  init/Android.bp
  init/Android.mk
  init/sysprop/Android.bp
  init/test_kill_services/Android.bp
  init/test_service/Android.bp
  libappfuse/Android.bp
  libasyncio/Android.bp
  libbinderwrapper/Android.bp
  libcrypto_utils/Android.bp
  libcrypto_utils/tests/Android.bp
  libdiskconfig/Android.bp
  libgrallocusage/Android.bp
  libkeyutils/mini_keyctl/Android.bp
  libmodprobe/Android.bp
  libnetutils/Android.bp
  libpackagelistparser/Android.bp
  libprocessgroup/Android.bp
  libprocessgroup/cgrouprc/Android.bp
  libprocessgroup/cgrouprc_format/Android.bp
  libprocessgroup/profiles/Android.bp
  libprocessgroup/setup/Android.bp
  libqtaguid/Android.bp
  libsparse/Android.bp
  libstats/push_compat/Android.bp
  libsuspend/Android.bp
  libsync/Android.bp
  libsystem/Android.bp
  libsysutils/Android.bp
  libusbhost/Android.bp
  libutils/Android.bp
  libvndksupport/Android.bp
  libvndksupport/tests/Android.bp
  llkd/Android.bp
  llkd/tests/Android.bp
  property_service/libpropertyinfoparser/Android.bp
  property_service/libpropertyinfoserializer/Android.bp
  property_service/property_info_checker/Android.bp
  qemu_pipe/Android.bp
  reboot/Android.bp
  rootdir/Android.bp
  rootdir/Android.mk
  rootdir/avb/Android.bp
  rootdir/avb/Android.mk
  run-as/Android.bp
  sdcard/Android.bp
  set-verity-state/Android.bp
  shell_and_utilities/Android.bp
  storaged/Android.bp
  toolbox/Android.bp
  trusty/apploader/Android.bp
  trusty/confirmationui/Android.bp
  trusty/confirmationui/fuzz/Android.bp
  trusty/coverage/Android.bp
  trusty/fuzz/Android.bp
  trusty/fuzz/test/Android.bp
  trusty/gatekeeper/Android.bp
  trusty/gatekeeper/fuzz/Android.bp
  trusty/keymaster/Android.bp
  trusty/keymaster/fuzz/Android.bp
  trusty/libtrusty/Android.bp
  trusty/libtrusty/tipc-test/Android.bp
  trusty/secure_dpu/Android.bp
  trusty/storage/interface/Android.bp
  trusty/storage/lib/Android.bp
  trusty/storage/proxy/Android.bp
  trusty/storage/tests/Android.bp
  trusty/utils/spiproxyd/Android.bp
  trusty/utils/trusty-ut-ctrl/Android.bp
  usbd/Android.bp
  watchdogd/Android.bp

Added SPDX-license-identifier-Apache-2.0 SPDX-license-identifier-BSD to:
  debuggerd/Android.bp
  fastboot/Android.bp
  libkeyutils/Android.bp

Added SPDX-license-identifier-Apache-2.0 SPDX-license-identifier-BSD
    SPDX-license-identifier-MIT
to:
  libcutils/Android.bp

Added SPDX-license-identifier-Apache-2.0 SPDX-license-identifier-MIT
to:
  fs_mgr/Android.bp
  fs_mgr/libfs_avb/Android.bp
  trusty/Android.bp
  trusty/utils/rpmb_dev/Android.bp

Added SPDX-license-identifier-BSD
to:
  fastboot/fuzzy_fastboot/Android.bp

Bug: 68860345
Bug: 151177513
Bug: 151953481

Test: m all

Exempt-From-Owner-Approval: janitorial work
Change-Id: Id740a7d2884556081fdb68876584b25eb95e1bef
2021-02-19 12:59:05 -08:00
Treehugger Robot
f5186a5128 Merge "Revert "[LSC] Add LOCAL_LICENSE_KINDS to system/core"" am: ca474f994d am: aea25045ba am: fa48b67e98
Original change: https://android-review.googlesource.com/c/platform/system/core/+/1590280

MUST ONLY BE SUBMITTED BY AUTOMERGER

Change-Id: Ifdbd05d3e1c993bf1b6c92161669555fba108abd
2021-02-17 00:46:03 +00:00
Elliott Hughes
c3a206ccda Revert "[LSC] Add LOCAL_LICENSE_KINDS to system/core"
This reverts commit 187b7d1950.

Reason for revert: system/core is multiple projects, not one.

Change-Id: I790ea41741f8cd9b8b6db2f59a49e71fb0958fd6
2021-02-16 20:01:20 +00:00
Treehugger Robot
34add4fe2c Merge "[LSC] Add LOCAL_LICENSE_KINDS to system/core" am: d0aa350c02 am: 504895aacb am: d856628451
Original change: https://android-review.googlesource.com/c/platform/system/core/+/1589006

MUST ONLY BE SUBMITTED BY AUTOMERGER

Change-Id: I85c87dc31f7599b64202578ed33587eeadb1650f
2021-02-16 19:41:17 +00:00
Bob Badour
187b7d1950 [LSC] Add LOCAL_LICENSE_KINDS to system/core
Added SPDX-license-identifier-Apache-2.0 to:
  bootstat/Android.bp
  cli-test/Android.bp
  code_coverage/Android.bp
  cpio/Android.bp
  debuggerd/crasher/Android.bp
  debuggerd/proto/Android.bp
  diagnose_usb/Android.bp
  fs_mgr/libdm/Android.bp
  fs_mgr/libfiemap/Android.bp
  fs_mgr/liblp/Android.bp
  fs_mgr/libsnapshot/Android.bp
  fs_mgr/libstorage_literals/Android.bp
  fs_mgr/libvbmeta/Android.bp
  fs_mgr/tests/Android.bp
  fs_mgr/tools/Android.bp
  gatekeeperd/Android.bp
  healthd/Android.bp
  healthd/testdata/Android.bp
  init/Android.bp
  init/Android.mk
  init/sysprop/Android.bp
  init/test_kill_services/Android.bp
  init/test_service/Android.bp
  libappfuse/Android.bp
  libasyncio/Android.bp
  libbinderwrapper/Android.bp
  libcrypto_utils/Android.bp
  libcrypto_utils/tests/Android.bp
  libdiskconfig/Android.bp
  libgrallocusage/Android.bp
  libkeyutils/mini_keyctl/Android.bp
  libmodprobe/Android.bp
  libnetutils/Android.bp
  libpackagelistparser/Android.bp
  libprocessgroup/Android.bp
  libprocessgroup/cgrouprc/Android.bp
  libprocessgroup/cgrouprc_format/Android.bp
  libprocessgroup/profiles/Android.bp
  libprocessgroup/setup/Android.bp
  libqtaguid/Android.bp
  libsparse/Android.bp
  libstats/push_compat/Android.bp
  libsuspend/Android.bp
  libsync/Android.bp
  libsystem/Android.bp
  libsysutils/Android.bp
  libusbhost/Android.bp
  libutils/Android.bp
  libvndksupport/Android.bp
  libvndksupport/tests/Android.bp
  llkd/Android.bp
  llkd/tests/Android.bp
  property_service/libpropertyinfoparser/Android.bp
  property_service/libpropertyinfoserializer/Android.bp
  property_service/property_info_checker/Android.bp
  qemu_pipe/Android.bp
  reboot/Android.bp
  rootdir/Android.bp
  rootdir/Android.mk
  rootdir/avb/Android.bp
  rootdir/avb/Android.mk
  run-as/Android.bp
  sdcard/Android.bp
  set-verity-state/Android.bp
  shell_and_utilities/Android.bp
  storaged/Android.bp
  toolbox/Android.bp
  trusty/apploader/Android.bp
  trusty/confirmationui/Android.bp
  trusty/confirmationui/fuzz/Android.bp
  trusty/coverage/Android.bp
  trusty/fuzz/Android.bp
  trusty/fuzz/test/Android.bp
  trusty/gatekeeper/Android.bp
  trusty/gatekeeper/fuzz/Android.bp
  trusty/keymaster/Android.bp
  trusty/keymaster/fuzz/Android.bp
  trusty/libtrusty/Android.bp
  trusty/libtrusty/tipc-test/Android.bp
  trusty/secure_dpu/Android.bp
  trusty/storage/interface/Android.bp
  trusty/storage/lib/Android.bp
  trusty/storage/proxy/Android.bp
  trusty/storage/tests/Android.bp
  trusty/utils/spiproxyd/Android.bp
  trusty/utils/trusty-ut-ctrl/Android.bp
  usbd/Android.bp
  watchdogd/Android.bp

Added SPDX-license-identifier-Apache-2.0 SPDX-license-identifier-BSD to:
  debuggerd/Android.bp
  fastboot/Android.bp
  libkeyutils/Android.bp

Added SPDX-license-identifier-Apache-2.0 SPDX-license-identifier-BSD
    SPDX-license-identifier-MIT
to:
  Android.bp
  libcutils/Android.bp

Added SPDX-license-identifier-Apache-2.0 SPDX-license-identifier-MIT
to:
  fs_mgr/Android.bp
  fs_mgr/libfs_avb/Android.bp
  trusty/utils/rpmb_dev/Android.bp

Added SPDX-license-identifier-BSD
to:
  fastboot/fuzzy_fastboot/Android.bp

Bug: 68860345
Bug: 151177513
Bug: 151953481

Test: m all

Exempt-From-Owner-Approval: janitorial work
Change-Id: I5bd81adb5cdcf2b4dd4141b204eb430ff526af8f
2021-02-16 04:10:03 -08:00
Treehugger Robot
f0e5355a6a Merge "Add product_available to product available modules" am: a9e6057dad am: 9d879b847f am: 721f41f062
Original change: https://android-review.googlesource.com/c/platform/system/core/+/1496003

Change-Id: Ic52a2b2e31685a5af4a09dc0377e0e6f7c033f44
2020-12-04 04:11:30 +00:00
Justin Yun
feef4d390f Add product_available to product available modules
vendor_available modules were available to product modules.
However, not all vendor_available modules are required to be
available to product modules. Some modules want to be available only
to product modules but not vendor modules.

To cover the requirement, we separate product_available from
vendor_available.
vendor_available will not provide product available module.

Rename libcutils/include_vndk to libcutils/include_outside_system as
it provides the headers to the modules outside the system partition
including /product.

Bug: 150902910
Test: build
Change-Id: I791b5a6a1dc99442065debfce6fa0f54a335fcea
2020-12-04 09:59:20 +09:00
Hamzeh Zawawy
b425404633 Merge "Resolved UAF issue in RefBase fuzzer" am: 9a79c84499 am: da2960df35 am: 5a8869456e
Original change: https://android-review.googlesource.com/c/platform/system/core/+/1424812

Change-Id: Iac76b32d88a3618434669f6b1e00c3591340c849
2020-12-01 19:30:18 +00:00
Dylan Katz
55107c195d Resolved UAF issue in RefBase fuzzer
Restrucures this fuzzer to be far more robust and less brittle.
Fix: 163727995
Fix: 163449137
Test: libutils_fuzz_refbase clusterfuzz-testcase-minimized-libutils_fuzz_refbase-5674315436261376
Test: libutils_fuzz_refbase clusterfuzz-testcase-minimized-libutils_fuzz_refbase-5731662044069888
Test: libutils_fuzz_refbase clusterfuzz-testcase-minimized-libutils_fuzz_refbase-5081777218256896

Signed-off-by: Dylan Katz <dylan.katz@leviathansecurity.com>
Change-Id: I239298dc2895a06af5a126e9ca2ae452579e5cc0
2020-11-30 16:18:27 -08:00
Devin Moore
5f9490712b Merge "libutils: add unit tests for invalid utf-8 and utf-16 strings" am: eb85221dcf am: c21e63ea26 am: ddc33e4f85 am: cc2f1917ac
Original change: https://android-review.googlesource.com/c/platform/system/core/+/1470423

Change-Id: Ie9f981fb869868a3acc2ca60e1a1a727b0905ad5
2020-11-12 17:47:51 +00:00