summaryrefslogtreecommitdiff
path: root/libutils/include/utils
AgeCommit message (Collapse)Author
2021-05-21Fix implicit cast from ssize_t to size_t in KeyedVector.hVishnu Nair
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-13Merge "Remove String16::remove."Elliott Hughes
2021-05-12Remove String16::remove.Elliott Hughes
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-11libutils: remove the unused StopWatch lap functionality.Elliott Hughes
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-04libutils: LightRefBase: incStrongRequireStrongSteven Moreland
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-04-15Remove move dead code.Elliott Hughes
Test: treehugger Change-Id: I6a23b19d078400dfe90329a49ae1abbcb24ef2bf
2021-04-14Merge "Remove String8::toUpper()."Elliott Hughes
2021-04-13Merge "libutils: group deprecated RefBase functions"Steven Moreland
2021-04-12libutils: group deprecated RefBase functionsSteven Moreland
Make it easier to see reference to usage documentation, as requested in review. Bug: 184190315 Test: libutils_test Change-Id: If9056e35b1c7a779dd78f2b986ad10d02f25eaf3
2021-04-12Remove String8::toUpper().Elliott Hughes
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-12Merge "Remove the weird range variants of String8::toLower() and ↵Elliott Hughes
String8::toUpper()."
2021-04-09Remove the weird range variants of String8::toLower() and String8::toUpper().Elliott Hughes
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-09Merge "Remove String16::makeLower()."Treehugger Robot
2021-04-07libutils: wp::fromExisting bugfixSteven Moreland
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-07Remove String16::makeLower().Elliott Hughes
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-07libutils: add sp::cast methodSteven Moreland
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-05ANDROID_UTILS_REF_BASE_DISABLE_IMPLICIT_CONSTRUCTIONSteven Moreland
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-02libutils: better docs for sp<>::makeSteven Moreland
Bug: 184190315 Test: N/A Change-Id: I56621058b9d85122b7dca3727e40c8c85595031f
2021-02-23Add docs to SystemClock.hZhomart Mukhamejanov
Test: n/a Change-Id: I16a41e9b98c88270857fe2a1d6b382bfe469bca6
2020-10-26Remove unused utf8_length().Elliott Hughes
Test: treehugger Change-Id: Idcebc4ae1dcad102873d50f199f5e8745e589da4
2020-09-27Revert "Add choice for changing sched policy when setting thread priority"Rick Yiu
This reverts commit 57affbf91d016eda1395106c4d5f0350471dca85. Reason for revert: new API is no longer used Change-Id: I97128c1d367e161aa50deaefa8b73a0f25e29af4
2020-09-27Revert "Fix API for C compatibility"Rick Yiu
This reverts commit b473061c5a1b6e609188310e8d63f12380b4c74a. Reason for revert: new API is no longer used Change-Id: I2c4f9f37736faeb5d0403c2ba531c792d2531505
2020-09-02Move PropertyMap from libutils to libinputSiarhei Vishniakou
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-08-24Fix API for C compatibilityGreg Kaiser
In https://android-review.googlesource.com/c/platform/system/core/+/1224544 when we introduced a default argument to androidSetThreadPriority(), we broke C compatibility with this API, and with the header file in general. We fix this up by instead introducing a new method that takes three arguments. This gets this header file compiling for C again, and keeps this particular API C compatible. Any C++ callers of the three argument version of androidSetThreadPriority() will need to switch to using androidSetThreadPriorityAndPolicy(). Although since this was a recent change, we believe there is only one such user, which we are fixing at the same time. Test: TreeHugger Bug: 165009705 Merged-In: Iab0b7e6c91a8e32a17ba1b186fd0c2fe96b601e4 Change-Id: Iab0b7e6c91a8e32a17ba1b186fd0c2fe96b601e4
2020-08-17Merge "Deprecate <utils/Debug.h>."Elliott Hughes
2020-08-17Don't #include <utils/Debug.h> from <utils/Flattenable.h>.Elliott Hughes
It's not used, and shouldn't be used. Also switch to `#pragma once`. Test: treehugger Change-Id: I464d3de1b0e1d536cea06362e6c73fddaad967d1
2020-08-17Deprecate <utils/Debug.h>.Elliott Hughes
I stumbled across this because of the `#ifdef __cplusplus` inside an unguarded `namespace`, but this whole file should be deprecated and removed in favor of static_assert. Test: treehugger Change-Id: I2b65db67e694115e915f0cc9d762b0fd41a7d2af
2020-08-08Merge "Add uptimeNanos to SystemClock"Treehugger Robot
2020-08-07Add uptimeNanos to SystemClockSuprabh Shukla
Test: system/core/libutils/SystemClock_test.cpp Bug: 162791194 Change-Id: I0e3ea2004146eb7442c89bb35a9f3a2171d9c4b8
2020-07-28Update language to comply with Android's inclusive language guidanceDan Albert
See https://source.android.com/setup/contribute/respectful-code for reference Bug: http://b/161896447 Test: None Change-Id: I9e5a37a20012b2f7a8eac55701df03f7b7a9ab6c
2020-07-16Soften BitSet class comment.Michael Wright
std::bitset<> doesn't have exact replacements for all of the functionality of BitSet32/64, so there are still places we want to use these classes. Bug: 160010896 Test: test BitSet_test.cpp Change-Id: Ica59a138e014d82139fb6dcea0597a207faecc2a
2020-07-12Cast away signedness of built-ins in BitSet.Michael Wright
Most of the built-in functions return signed values but BitSet deals only in unsigned values. We can safely cast these away though as they're always indices, which can't be negative. Bug: 160010896 Test: atest inputflinger_tests, atest libinput_tests Change-Id: I6e0b33972fabcd41ad1c269ea0e2a07b13b33c12
2020-05-27Make systemTime() abort on bad input.Elliott Hughes
There's no CHECK in libutils, sadly. Bug: http://b/157167405 Test: treehugger Change-Id: I1532bf80ba7fdafad016610be3c782b547417126
2020-05-15Add choice for changing sched policy when setting thread priorityRick Yiu
If the policy has been changed already, we do not need to change it again. Bug: 139521784 Test: functionality verified Change-Id: I251db1d3f874896ba9be68df87209e7e514b80f9
2020-05-08Fix mac build.Christopher Ferris
Add an inline for mmap64 to use on mac. Bug: 156053599 Test: Builds. Change-Id: Id02e2c2f40acea2bdef604e9b80b70a85a941927
2020-04-22[cleanup] Fix a clang-tidy warningYurii Zubrytskyi
const parameters can't be moved but only get copied - removed const Bug: 153704006 Test: builds & boots Change-Id: If7e2250325bf1bc498afd3539f60bcb075a1d43b
2020-02-27Merge "String8: operator<<"Steven Moreland
2020-02-26Merge "String*: remove 'StaticLinkage' constructor"Steven Moreland
2020-02-25String8: operator<<Steven Moreland
For parity with String16. Bug: N/A Test: N/A Change-Id: I2d7d207138c96146814da31cf27a49cc310e5362
2020-02-20libutils: introduce sp<T>::makeSteven Moreland
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-11Merge "String16: operator<<"Steven Moreland
2020-02-10String16: operator<<Steven Moreland
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-10String*: remove 'StaticLinkage' constructorSteven Moreland
Unneeded. Bug: N/A Test: N/A Change-Id: I3ff473d1e2fec98e47abd8abb45dd36e0a808170
2020-02-10Remove String16 header cruft.Steven Moreland
-= forward declaration of imported class -= empty extern decl Bug: N/A Test: N/A Change-Id: I4eba90870f6d2e8d06fb49872cad51ca95da5ad9
2020-01-17libutils: sp lh comparison w/ pointerSteven Moreland
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-02DO NOT MERGE - Merge QQ1A.200105.003 into stage-aosp-masterXin Li
Change-Id: I307003cb8d6311ed3662535a54ac8586b8a25bd0
2019-12-19libutils: sp/wp: undef #definesSteven Moreland
Seems these undefs are slightly out of sync/out of date. Bug: N/A Test: libutils_test Change-Id: I884ae1ca97754a6459a2c7844264f513eecddaba
2019-11-26Add check to sp<> raw pointer constructorHans Boehm
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-18Add statusToString function.Steven Moreland
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-15FlattenableUtils::align memsetsSteven Moreland
Bug: 141890807 Test: boot, check data is zero'd Change-Id: I45aaeac369f4c5cf3eb44f61c233e00f870a5c79 (cherry picked from commit bf824f8fa50d9f7390057278fefb58e83323a644) (cherry picked from commit e62a9d7669ac85844d4424474f5c88c096f7160b)