Commit graph

121 commits

Author SHA1 Message Date
Tom Cherry
a5edc0fbbc Use libcutils_headers for android_filesystem_config.h
android_filesystem_config.h is found since system/core/include is on
the include path for all projects and contains a symlink to the real
android_filesystem_config.h.  This is fragile and the below bug seeks
to remove this symlink and have users correctly depend on
libcutils_headers.

Bug: 165825252
Test: build
Change-Id: I1aad6a2e8fbe87635e97b0ac1be3414403353382
2020-09-18 22:48:42 +00:00
Tom Cherry
3d8b739f94 Remove include/private/android_logger.h
Users should depend on liblog or liblog_headers for this include.

Test: treehugger
Change-Id: I10dca8638082b2231e2c0713644f103c4c7e9b3f
2020-09-16 11:32:47 -07:00
Ruchir Rastogi
f2a5ed081a Do not truncate AStatsEvent buffers
Pushed atoms do not need to be truncated because only the bytes added to
the buffer are written to the socket. Pulled atoms do not need to be
truncated because within stats_pull_atom_callback.cpp, we only copy the
valid parts of the buffer to the StatsEventParcel object.

This improves performance by avoiding a needless call to realloc.

+ removed dead benchmarking code

Test: m libstatssocket
Test: atest libstatssocket_test
Test: atest GtsStatsdHostTestCases
Bug: 158717786
Change-Id: I6965f8832758203ca566336ba12d0acaf5f756d5
2020-06-10 20:43:53 -07:00
Muhammad Qureshi
9b9584b1a3 Increase size limit for pulled AStatsEvent
Increase AStatsEvent max byte size to 50 KB for pulled events.
All AStatsEvent instances are treated as pulled events unless
AStatsEvent_write() is called.

- Set the default max size to 50 KB
- The starting buffer size is still ~4 KB for pushed and pulled events.
- If a write would exceed the buffer bounds, double buffer size until
write fits or 50 KB limit is exceeded in which case the overflow bit is
set to true.
- If AStatsEvent_write() is called, max size is set to ~4 KB. And if
the current payload exceeds this limit, set overflow bit to true.

- Fix error mask checking in stats_event_test.
- Set ERROR_NO_ATOM_ID when atom id is missing.
- Make sure tests don't hit ERROR_TOO_MANY_FIELDS when testing buffer
overflow.
- Rename event->size to event->numBytesWritten

Fixes: 158214941
Test: libstatssocket_test
Change-Id: Ia26aeb775f7e4f2ffe87707bab6d0119e21da10e
2020-06-09 20:12:42 -07:00
Tej Singh
84db2e40e1 Merge "Retry pullfinish with empty payload if call fails" into rvc-dev 2020-06-01 19:14:09 +00:00
Howard Ro
413668bcf3 Merge "Libstatspull: decrease default pull timeout to 2s" into rvc-dev 2020-05-30 09:59:13 +00:00
Tej Singh
00ffb6c77e Libstatspull: decrease default pull timeout to 2s
Decrease the default pull timeout to 2 seconds.

Test: atest LibStatsPullTests
Test: atest libstatspull_test
Bug: 154056912
Change-Id: I8f7660de64e8c74a8c7ce7d252369c0456895e3b
2020-05-29 23:37:21 +00:00
Tej Singh
c95f781901 Retry pullfinish with empty payload if call fails
If the first call for pullFinished fails, it is likely because the
transaction is too large. Currently, if this happens statsd will just
sleep until the timeout. With this change, the client will retry calling
pullFinish if the first attempt fails, but with an empty payload (and
with success = false) to cause the puller to fail fast, and so statsd
does not wait for the timeout.

Test: atest LibStatsPullTests
Bug: 157768117
Change-Id: I3af991fae47bb7c09bf8a6fc83f28556b836c6e4
2020-05-29 15:21:08 -07:00
Chen Zhu
f584432c90 Merge "Add test config to libstatspull_test and libstatssocket_test" into rvc-dev 2020-05-27 07:47:03 +00:00
Chen Zhu
c724fb670f Add test config to libstatspull_test and libstatssocket_test
and apply mainline module test controller to it so that

the tests will only be run when statsd apex is found on device.

Bug: 154845935
Test: m mts && mts-tradefed run mts-statsd
Change-Id: I8939e68b4d4c3772e248c1960b74c0f1bd6a21a6
2020-05-21 14:51:59 -07:00
Howard Ro
516b632ff4 Remove statsd enable check when logging
statsd should now be enabled on all devices and this check is
unnnecessarily adding a check for each time there's a call into the
socket, which is inefficient.

Bug: 157082130
Test: make, statsd_test
Change-Id: I0bb0ae0c93516c3a02cb971742c3eba602668a09
2020-05-19 21:52:14 +00:00
Ruchir Rastogi
4ae167e829 Use proper platform version checks (libstats)
Test: bit libstatspush_compat_test
Bug: 146019024
Change-Id: If99a7067944ddfbe30bb0ddfe586a337a94d4c07
2020-05-07 12:31:39 -07:00
Jooyung Han
f2d4dc6b8f stats: Set min_sdk_version
Modules contributing mainline modules (APK/APEX) should set
min_sdk_version as well as apex_available.

For now setting min_sdk_version doesn't change build outputs.
But build-time checks will be added soon.

Bug: 152655956
Test: m
Merged-In: Icd184c6fe06a688bd79ef6514bb49dffb706a9a1
Change-Id: Icd184c6fe06a688bd79ef6514bb49dffb706a9a1
(cherry picked from commit cc3588afcb)
2020-05-02 02:29:19 +09:00
Jeffrey Huang
053ade4320 Merge "Add test for AStatsSocket_close()" into rvc-dev 2020-04-29 18:46:26 +00:00
Jeffrey Huang
6cc1d41527 Add test for AStatsSocket_close()
Bug: 154871176
Test: atest libstatssocket_test
Change-Id: If8aa26a9a9a75382b6f8779c23974a7008bd387a
2020-04-28 15:22:28 -07:00
Jeffrey Huang
18d239c5c5 Add require root to libstats tests
root is required for coverage tests

Bug: 154652564
Test: m -j
Change-Id: I3325565818a275a069aed35a34bf3a58ee4b5bfc
2020-04-24 10:44:25 -07:00
Jeffrey Huang
6d99e68e74 Merge "Tag libstatspull and libstatssocket tests as MTS" into rvc-dev 2020-04-23 23:55:31 +00:00
Jeffrey Huang
2f51ad7b86 Tag libstatspull and libstatssocket tests as MTS
create both 32 and 64 bit variants
fixes libstatssocket_test for 32 bit devices

Bug: 154652564
Test: make mts, adb push, adb shell all 4 tests
Change-Id: Ia6b51686c06e786b38cb3713315977533f1bb819
2020-04-22 17:13:24 -07:00
Jiyong Park
a6bcd4817c 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.

Exempt-From-Owner-Approval: cherry-pick from AOSP

Bug: 150999716
Test: m
Merged-In: I8fd2a3c9b69454c6018c72f5198898bc90dc4d0d
(cherry picked from commit 937b4bf173)
Change-Id: I8fd2a3c9b69454c6018c72f5198898bc90dc4d0d
2020-04-20 16:35:05 +09:00
Tej Singh
5d8f770b1c Link libc++ statically
Test: bit statsd_test:*
Test: bit libstatssocket_test:*
Test: bit libstatspull_test:*
Bug: 153349659
Change-Id: Ief3d0e062ed3e5cabf5b8b6198510caf3f64eefd
2020-04-06 19:52:03 -07:00
Tej Singh
0d7fb3d260 libstatspull documentation for puller guardrails
Test: atest LibStatsPullTests
Bug: 152543610
Change-Id: Ia5caad7c9307c02fef7d3dfe70998601e7ffeb55
2020-03-30 18:15:05 -07:00
Ruchir Rastogi
e39a7cf021 Merge "Support ERROR_ATOM_ID_INVALID_POSITION" into rvc-dev 2020-03-24 18:47:16 +00:00
Ruchir Rastogi
8056dd129a Support ERROR_ATOM_ID_INVALID_POSITION
Originally, the native implementation would discard everything clients
wrote to the buffer before the setAtomId call. Thus, the atom id was
always placed in the "correct position." However, for consistency with
the Java implementation, we now allow write calls before setAtomId to
occur and log an error in that case.

Test: bit libstatssocket_test:*
Bug: 152119205
Change-Id: Ib109c7a939a5ae92c1d5fc70aa647ac7390fadad
2020-03-24 07:57:51 -07:00
Hsin-Yi Chen
e3bdbfa46c Disable ABI check for libstatspull
The ABI dump for libstatspull can't be built due to the link error.

Test: development/vndk/tools/header-checker/utils/create_reference_dumps.py
Bug: 151102177
Bug: 151694054
Change-Id: Id324890235679b9593995b6e12a60ef055b4c825
2020-03-23 03:45:07 +00:00
Tej Singh
47e5ae49c2 Minor followups from api feedback
Bug: 150788562
Test: m
Change-Id: I3473e49bc3f3682300b036ddeb032c3776d8d830
2020-03-20 12:16:28 -07:00
Tej Singh
c06f147566 Native API feedback for puller API
1. Rename registerPullAtomCallback to setPullAtomCallback
2. Rename unregisterPullAtomCallback to clearPullAtomCallback
3. Change Ns to Millis for consistency with java
4. Swap metadata and callback params in setPullAtomCallback to match
java
5. Added getters for PullAtomMetadata
6. Added libstatspull_test to test PullAtomMetadata
7. Changed the types on setAdditiveFields from int to int32_t

Test: make
Test: atest LibStatsPullTests
Test: bit libstatspull_test:*
Bug: 1507885621
Bug: 151875223
Change-Id: I5cb07bfe71b1002180403828d5e8e6a5b88ce6fe
2020-03-20 11:10:56 -07:00
TreeHugger Robot
5a495becd0 Merge "Enforce permission in native puller API." into rvc-dev 2020-03-19 21:12:52 +00:00
Tej Singh
8196687d39 Enforce permission in native puller API.
Test: m
Test: No security exceptions on boot
Bug: 148955001
Change-Id: If196a82bf5a54ee15557825e16f70b5f64f45412
2020-03-17 11:26:00 -07:00
Ruchir Rastogi
e712eed24c Support atom-level annotations within AStatsEvent
Refactors implementation details to allow for atom-level annotations.
This CL does not change the API surface. addBoolAnnotation and
addInt32Annotation work for both atom-level and proto field annotations.

Test: bit libstatssocket_test:*
Bug: 151158794
Change-Id: I2c340b201aeb3bcddd5cfde171b7c4df1d8d69a4
2020-03-12 15:21:26 -07:00
Jiyong Park
c2a354be68 Merge "don't include liblog to APEXes" into rvc-dev 2020-03-12 04:10:15 +00:00
Jiyong Park
01aa81cec5 don't include liblog to APEXes
liblog is a platform library that provides stable C API. There is no
need to include the library, especialy by statically linking to it, in
any APEX. It not only wastes the storage/ram, but also is incorrect
because the socket interface to logd which is implemented in liblog is
not guaranteed to be stable.

Fixing this issue by converting static_libs: ["liblog"] into
shared_libs: ["liblog"], in which case the dependency to the library
is satisfied via the stub variant of the library.

As a result, we could restrict the availablity of the library to
the platform and the runtime APEX.

Exempt-From-Owner-Approval: already approved when this was in internal
master (ag/10572699)

Bug: http://b/151051671
Bug: http://b/150827719
Test: m
Merged-In: I5aab863cb12b8767b6979255c247000a59355b0e
(cherry picked from commit 95b6f45b0e)
Change-Id: I5aab863cb12b8767b6979255c247000a59355b0e
2020-03-11 18:30:06 +09:00
Ruchir Rastogi
7a287d0751 Use dlsym to load libstatssocket API
Also fixes a bug in the tests where the platform version was being
checked by querying version.release instead of version.codename
(currently, version.release == 10, while version.codename == R).

Test: bit libstatspush_compat_test:* (on Q and R)
Test: libsstatssocket.so is not placed in resolv apex (on R)

1|bonito:/ $ ls apex/com.android.resolv/lib64
libclang_rt.ubsan_standalone-aarch64-android.so
libcrypto.so
libnetd_resolv.so
libssl.so

Test: NETWORK_DNS_EVENT_REPORTED atom is logged to statsd (on R)
    - adb shell cmd stats print-stats (atom 116 count > 0)

Bug: 148743333
Change-Id: Ib3eaa32835905bcf6e3b003054bf0f3c4e7ec0a4
Merged-In: Ib3eaa32835905bcf6e3b003054bf0f3c4e7ec0a4
(cherry picked from commit 9848eb4f1c)
2020-03-09 15:16:11 -07:00
Luke Huang
7452e46ae0 Use libbase to get the elapsed time instead of libutils
To minimize the external library dependencies

Bug: 149721367
Test: atest
Change-Id: I7b79223ad58c2af94d01a35ad39be6cdd1de7f47
Merged-In: I7b79223ad58c2af94d01a35ad39be6cdd1de7f47
(cherry picked from commit cab9854fa9)
2020-03-06 22:09:44 +00:00
Tej Singh
d78f4dab02 Make libstatssocket a shared_lib
Make libstatssocket unable to be linked as a static lib on the platform.

Test: bit libstatssocket_test:*
Test: bit statsd_test:*
Test: atest LibStatsPullTests
Bug: 149340100

Change-Id: I5889dd718536f5f2c693b4c2e7331c9cc2eb2ac9
2020-02-27 11:37:33 -08:00
Muhammad Qureshi
3a40ee5402 //apex_available:platform should be first in list
Test: m
Change-Id: I6ede6f008bc149f587ae2fc024d5869463b2c64d
2020-02-18 17:05:19 -08:00
Ruchir Rastogi
d430c85c52 Merge "Delete stats_event_list from libstatssocket" 2020-02-15 01:34:34 +00:00
TreeHugger Robot
ea37af2c62 Merge "AStatsEvent_overwriteTimestamp" 2020-02-14 23:11:48 +00:00
Ruchir Rastogi
e1cff24259 Delete stats_event_list from libstatssocket
This change is done in internal master because the flag has not been
switched in AOSP, so stats_event_list is still being used there.

Test: m -j
Bug: 145573568
Change-Id: Ica525d0fd731b8d3e9d273ce2220a3d3179d93d9
2020-02-14 13:34:10 -08:00
Howard Ro
f8e70a5bf8 Merge "Expose AStatsSocket_close() from the statsd apex" 2020-02-14 19:43:21 +00:00
Ruchir Rastogi
e41a6c621c AStatsEvent_overwriteTimestamp
Create a function to overwrite timestamp for LogEvent tests. This
function is not exposed outside of the APEX.

Test: bit libstatssocket_test:*
Change-Id: Id0eac485af60e952cc700f7d1231b1b971400982
2020-02-14 10:56:49 -08:00
Muhammad Qureshi
2ebc2e3d8f Expose AStatsSocket_close() from the statsd apex
As part of statsd becoming a Mainline module in R, we need to formalize
the statsd APIs called from outside the statsd apex.

Bug: 145923416
Test: m
Change-Id: I296a018cc93d95bda77d95f8161acbbe983a5d51
2020-02-13 16:16:48 -08:00
Jeffrey Huang
b0a85dc46d Add apex_available to libs
Bug: 145922701
Test: m -j
Change-Id: If5cbe5651e47878520bdc5b943b17a4f72a2a2f3
2020-02-12 18:30:26 -08:00
Ruchir Rastogi
223dadb830 Migrate libstatspull to libbinder_ndk
Since libstatspull will be placed within the APEX, we need to move to
libbinder_ndk.

Test: m -j libstatspull
Test: atest LibStatsPullTests
Bug: 145213327
Change-Id: I86dd6e759efa5eb20bffc76492d5fa72cf279872
2020-02-10 16:07:18 -08:00
Jeffrey Huang
8095e4eef1 Update libstatspull lib
statsd_aidl was updated, so this is the matching change.

Test: m -j
Bug: 148682447
Change-Id: Iec0459cec9f649eb23c6d04b205075fff9b6e911
2020-02-07 12:17:40 -08:00
Muhammad Qureshi
b173a95ae8 Fix native stats_event logging
pass the byte array pointer; not the reference to the pointer.

Also turn on new socket protocol.

Bug: 148909969
Bug: 143979391
Test: m
Test: fastboot flashall
Test: atest android.cts.statsd.atom.UidAtomTests#testLmkKillOccurred
Test: atest LibStatsPullTests
Test: atest GtsStatsdHostTestCases
Change-Id: If7abae5cadb036555540d1b9b5e7f2cabe99beb8
2020-02-05 17:10:46 -08:00
Howard Ro
f49c38beb5 Merge "Expose libstatspull as a stable C API" 2020-02-05 18:28:12 +00:00
Tej Singh
0fca736e6c Add libstatssocket_test to TEST_MAPPING
Test: treehugger
Change-Id: Iddff5df4c498bf7c93e57b1ae214f813920243e1
2020-02-04 16:08:21 -08:00
Tej Singh
a8fd39d83f Expose libstatspull as a stable C API
Libstatspull will ship as a part of the statsd apex in R.

Also update libstatssocket to have version 30 to align with api level,
as per native api council feedback.

Change both libraries to use NDK style naming conventions (AStatsEvent,
AStatsManager), and remove unneeded APIs in libstatssocket.

Remove KeyValuePairs from libstatssocket. KeyValuePairs will not be
supported in native code.

Bug: 147499386
Test: make libstatspull
Test: make libstatssocket
Test: atest libstatssocket_test
Change-Id: Ie79771461215a057529aaac91db95e4334c3960e
2020-02-04 14:07:35 -08:00
Muhammad Qureshi
a37a2bc415 export libstatssocket_headers
Add export_header_lib_headers: ["libstatssocket_headers"]
to libstatspush_compat

Test: m
Change-Id: I70d7a214a5233c6a730b24c9c21b8bd654a78b04
2020-01-30 16:44:53 -08:00
Tej Singh
518d77d208 Register pullers in separate thread
This cl modifies getStatsService to use the blocking getService, but
also makes the binder call in a separate thread to not block the client
thread. This is needed because it is possible for pullers to be
registered before statsd starts, and calling checkService before statsd
is up will fail. We also would never receive the binderDied to register
it, because we would never have a binder object to linkToDeath on.

Bug: 147682855
Test: atest LibStatsPullTests
Change-Id: I68c04bc24c7fe066eca88cab4f6a76885581c1ee
2020-01-15 21:15:26 +00:00