Commit graph

166 commits

Author SHA1 Message Date
Treehugger Robot
e7da3eb805 Merge "Doc Thread requirement." am: c545516e2c am: 40ce64b6db
Original change: https://android-review.googlesource.com/c/platform/system/core/+/2094349

Change-Id: I95cebb43fcd70803fe0bdece39d57546053264cb
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2022-05-12 03:21:16 +00:00
Treehugger Robot
c545516e2c Merge "Doc Thread requirement." 2022-05-12 01:53:32 +00:00
Christopher Ferris
39819bbc94 Merge "Use the new AndroidUnwinder object." am: af4db6749a am: ce1c33332c
Original change: https://android-review.googlesource.com/c/platform/system/core/+/2095264

Change-Id: Icc76b39136bce395106c070aeb338d4e6922a28e
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2022-05-12 00:32:48 +00:00
Steven Moreland
90722d254e Doc Thread requirement.
Fixes: 230893354
Test: N/A
Change-Id: I426184840c7bf61fe3369388cfc6db184470acf0
2022-05-11 23:13:17 +00:00
Christopher Ferris
ab63124cd9 Use the new AndroidUnwinder object.
Replaces libbacktrace in CallStack. There is one small behavioral
change, the BuildId data is added to the unwinds.

Bug: 120606663

Test: All unit tests pass.
Test: Run the fuzzer for over an hour without any crashes.
Change-Id: Ic8a4247c515ce0d3cdc4d2cc15167d1948b15fa5
2022-05-10 17:19:12 -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
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
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
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
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
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
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
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
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
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
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
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
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
a14beb2dbc Merge "Fix implicit cast from ssize_t to size_t in KeyedVector.h" 2021-05-22 03:46:09 +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
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
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
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
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
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
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
4b7b4d6d7b Remove move dead code.
Test: treehugger
Change-Id: I6a23b19d078400dfe90329a49ae1abbcb24ef2bf
2021-04-15 15:18:54 -07:00
Elliott Hughes
450f66bd8f Merge "Remove String8::toUpper()." 2021-04-14 17:36:36 +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
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
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