commit | c9285856ee40e17c8a5aee1ab858b0f325454d0e | [log] [tgz] |
---|---|---|
author | Elliott Hughes <enh@google.com> | Wed May 20 08:03:50 2020 -0700 |
committer | Elliott Hughes <enh@google.com> | Thu May 21 16:19:51 2020 -0700 |
tree | f4971a4fb3b40c0556a821df27caf3be5f3c48c2 | |
parent | 18880334613a542289662f48523d5d8fcbaec8b1 [diff] |
Enable libcutils property_get()/property_set() on the host. Expose working equivalents of the bionic __system_property_get() and __system_property_set() functions for libcutils to use. Various improvements to the implementations so that we can pass all the libcutils tests too. Bug: http://b/151789258 Test: treehugger Change-Id: If4634d1ac11cc7c84c029518beedfa653f74f66b
This library is a collection of convenience functions to make common tasks easier and less error-prone.
In this context, "error-prone" covers both "hard to do correctly" and "hard to do with good performance", but as a general purpose library, libbase's primary focus is on making it easier to do things easily and correctly when a compromise has to be made between "simplest API" on the one hand and "fastest implementation" on the other. Though obviously the ideal is to have both.
The intention is to cover the 80% use cases, not be all things to all users.
If you have a routine that's really useful in your project, congratulations. But that doesn't mean it should be here rather than just in your project.
The question for libbase is "should everyone be doing this?"/"does this make everyone's code cleaner/safer?". Historically we've considered the bar for inclusion to be "are there at least three unrelated projects that would be cleaned up by doing so".
If your routine is actually something from a future C++ standard (that isn't yet in libc++), or it's widely used in another library, that helps show that there's precedent. Being able to say "so-and-so has used this API for n years" is a good way to reduce concerns about API choices.
Unlike most Android code, code in libbase has to build for Mac and Windows too.
Code here is also expected to have good test coverage.
By its nature, it's difficult to change libbase API. It's often best to start using your routine just in your project, and let it "graduate" after you're certain that the API is solid.