Commit Graph

282 Commits

Author SHA1 Message Date
Jeffrey Huang
9740023631 Fix package name for LibStatsPullTests
The previous package name was wrong. When the kWhiteListedAtoms was
removed, the breadcrumb atom was no longer being logged properly due to
the incorrect package name.

Bug: 159768218
Test: atest LibStatsPullTests
Change-Id: I2277d205d66ef0cdc4954990db0cd783d5d5401e
2020-06-24 19:40:32 -07:00
waynema
41e5aac60f Add framework-statsd dependency and make framework-statsd visible to
Tethering package.

Tethering needs StatsEvent and StatsLog which are in
framework-statsd.stubs.module_lib to write metrics.

Bug: 153942334

Test: make
Change-Id: I8ba142a9b3678de36e6c4880a64e992e00680f38
2020-06-22 06:57:51 +00:00
Jeffrey Huang
5c8ac36d78 Merge "Add FrameworkStatsdTest to mts" into rvc-dev 2020-06-17 21:11:47 +00:00
Jeffrey Huang
ceaa76970f Add FrameworkStatsdTest to mts
Bug: 154652564
Test: m mts && mts-tradefed run mts-statsd
Change-Id: Iefb2a96f6cb2663146c7a1578c08ce82c43160f4
2020-06-15 19:13:57 -07:00
Muhammad Qureshi
351e40fb8d Increase size limit for pulled StatsEvent.
Increase StatsEvent max byte size to 50 KB when not using pooled buffer.

- 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 usePooledBuffer() is called, max size is set to ~4 KB but buffer
isn't resized. And if the current payload exceeds this limit, set
overflow bit to true.
- Only "recycle" Buffer object if its size is <= ~4 KB.

Bug: 158214941
Test: atest FrameworkStatsdTest
Change-Id: I9b6f73688b0bccb5a70f4ef51750464ec9c87fb9
2020-06-04 14:02:24 -07:00
Tej Singh
36c9766d46 Merge "Change package of StatsdStatsLog" into rvc-dev 2020-06-02 18:24:45 +00:00
Paul Duffin
abebc6a897 Switch to standard naming scheme
Removes use of the special framework-modules naming scheme.

Bug: 155164730
Test: m java
Exempt-From-Owner-Approval: Build cleanup.
Change-Id: I3b78fcbcacc3df787e171d6eedeef1e51b087615
Merged-In: I0c31e2183353dfb5bd49f04f3455cb7b10be6866
(cherry picked from 8b864fb45c)
2020-06-02 06:53:53 +00:00
Tej Singh
058db967d9 Change package of StatsdStatsLog
Change package of StatsdStatsLog from com.android.internal.util to
com.android.internal.statsd

Test: atest GtsStatsdHostTestCases
Bug: 157649935
Change-Id: Iee2af03c950b7cc054f7d77e721694a7f429ae9d
2020-06-01 19:01:43 -07:00
Tej Singh
273c839a06 Merge "Retry pullfinish with empty payload if call fails" into rvc-dev 2020-06-01 19:14:10 +00:00
Paul Duffin
dde22307b1 Clean up the visibility rules for framework modules
Switching from java_library to java_sdk_library switched the meaning
of the module name from referring to the implementation library to
referring to the stubs. This change updates the visibility rules to
reflect that new meaning.

Visibility rules that were previously set for the java_library have
been moved to the impl_library_visibility property and the special
//visibility:override value has been prepended to prevent it from
inheriting the values from the visibility property.

Visibility rules set for the stubs (via stubs_library_visibility)
property have been moved to the visibility property.

Bug: 155164730
Test: m nothing
Exempt-From-Owner-Approval: Build cleanup
Change-Id: Icc9bc5a9ef86cf7ba0f15c2b2a4abd596ec9f640
2020-05-31 13:45:51 +01:00
Orion Hodson
1d76e46116 Merge "Drop dependency on libnativehelper" into rvc-dev 2020-05-30 10:05:06 +00:00
Howard Ro
ceb2602851 Merge "Decrease default pull timeout to 2 seconds." into rvc-dev 2020-05-30 09:59:13 +00:00
Tej Singh
73bad98e46 Decrease default pull timeout to 2 seconds.
This can result in more pull failures, but can prohibit slow pullers
from slowing down statsd.

Test: atest GtsStatsdHostTestCases
Test: atest statsd_test
Test: atest FrameworkStatsdTest
Bug: 154056912
Change-Id: Ie30bd3584d808bb11aaaf0fe2057c9adfb198644
2020-05-29 23:37:03 +00:00
Tej Singh
2330e9be15 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 GtsStatsdHostTestCases
Bug: 157768117
Change-Id: I1af29b6c83039ab56ef847832a600d4afea34000
2020-05-29 15:19:48 -07:00
Orion Hodson
1cec75dd50 Drop dependency on libnativehelper
Pending changes to libnativehelper API mean modules should not depend
on it as a stable API.

Bug: 157711673
Test: atest FrameworkStatsdTest LibStatsPullTests
Change-Id: I708a1489b5a1e30185b7e3677393c446074dc96c
2020-05-29 14:05:50 +01:00
Paul Duffin
e21f7f885f Switch framework-statsd to use java_sdk_library
The names of the individual modules do not quite follow the pattern
that java_sdk_library uses so this temporarily sets the following:
    naming_scheme: "frameworks-modules"

That causes java_sdk_library to use a naming scheme that matches the
one used by the individual modules of this. It will be cleaned up
later.

Test: m update-api
Bug: 155164730
Change-Id: Iadb4020a8b97c7f1eed8ee6752d91e827404441e
2020-05-28 17:17:53 +01:00
Paul Duffin
3efcb54161 framework-statsd: Add missing permitted package
A bug in Soong prevented the permitted package check from being
performed. Fixing the bug revealed that there was a missing package
on framework-statsd which this change adds.

Test: m framework-statsd
Bug: 157633658
Change-Id: Ic0602b9c4a65b57c1ee87ba2fcfaf82c2606e640
2020-05-28 16:24:39 +01:00
Stanislav Zholnin
eec8ee430c Fix race condition on cancelling alarms
There was a race condition in which pulling alarms can be cancellled
after they are initialized, causing bucket boundary pulls to fail.

Test: manually verifified alarm consistently cancelled before being set
Test: manually verified alarms were properly cancelled on statsd crash
Fix: 156855909
Change-Id: I913b6f3e3d03269fb9283199f8b9d666a298e145
2020-05-19 01:30:14 -07:00
Tej Singh
6dfbdb3e2f Merge "Fix statsd NPE on setPullAtomCallback" into rvc-dev 2020-05-06 22:11:02 +00:00
Ruchir Rastogi
76994e73a7 Merge "Handle race conditions in SCS when statsd dies" into rvc-dev 2020-05-06 22:10:42 +00:00
Ruchir Rastogi
e92edbaffc Handle race conditions in SCS when statsd dies
This CL aims to fix two race conditions:

1. When statsd restarts after a crash, the ordering of sayHiToStatsd and
binderDied is not guaranteed. However, previously, we assumed that
binderDied would get called first and reset sStatsd to null. To solve,
we don't assume a function ordering and don't throw an error message in
sayHiToStatsd if sStatsd is not null.

2. When statsd was linked to death, the death recipient was not informed
about all broadcast receivers. Thus, the death recipient might have
known only a partial list of receivers when #binderDied was triggered. To
solve, we make sure that the death recipient knows about all receivers
before we link to death.

Test: atest statsd_test
Test: atest CtsStatsdHostTestCases
Bug: 154275510

Change-Id: I11be65ca2135cde200ab8ecb611a363d8f7c2eb6
2020-05-06 11:06:55 -07:00
Tej Singh
baed5257ad Fix statsd NPE on setPullAtomCallback
Suspected root cause: if a process crashes right after calling
setPullAtomCallback, it's possible that oneway binder calls can queue
but do not execute before the process crashes. Then, when the process
crashes, nothing has a strong reference to the IPullAtomCallback, so
it gets deallocated. Then, when the oneway call actually executes, the
callback is null. This is being followed up in b/155793159

Regardless, statsd should handle null input properly.

Test: GTS test in ag/11348719 now passes
Test: atest GtsStatsdHostTestCases
Bug: 153822941
Change-Id: Ic6d415e10eca8d133290de80cb61e1634590ca6a
2020-05-05 14:51:57 -07:00
Anton Hansson
340954c017 Enable api lint and check_last_api for modules
This adds checking of module api compatibility to the individual module
api rules. Until now, this checking has been done via the monolithic
metalava runs which we are aiming to get rid of.

Now is a good time to do this because we can compare them to the just
finalized version 30 API, which we have no diffs with. Baseline the
existing wifi failures that metalava fails to find in the previous API.

Bug: 144149403
Test: m checkapi
Change-Id: Id222895daa3a769c265965b052a17d5a1ca18462
2020-05-05 19:17:08 +01:00
Anton Hansson
8bf731c0fc Rename module dist files
This makes the filenames of the disted artifacts (api txts and stubs)
match the module name of the modules they're from. This matches the
naming scheme used by java_sdk_library, which should make the future
transition to this build rule easier.

Bug: 149293194
Test: lunch sdk_phone_armv7 && m sdk dist && find out/dist/apistubs
Change-Id: I076f30931bf2524d57703873cd7de25b3f23b457
2020-04-30 17:42:20 +01:00
Jeffrey Huang
91c6dd813e Merge "Add LibStatsPullTests to MTS" into rvc-dev 2020-04-23 23:55:12 +00:00
Jeffrey Huang
73bd866a11 Add LibStatsPullTests to MTS
Bug: 154652564
Test: make mts
Change-Id: I97000354089cb372ebd70ce1665b8dc2445b2e81
2020-04-22 17:41:15 -07:00
Jeffrey Huang
64c55e7e8a Merge "Remove IStatsd reference from StatsLog.java" into rvc-dev 2020-04-22 00:08:44 +00:00
Jeffrey Huang
d8a7f947ba Remove IStatsd reference from StatsLog.java
Also remove sendAppBreadcrumb binder api because it's no longer used.

Bug: 154264326
Test: atest com.google.android.statsd.gts.StatsdHostTestCases
Change-Id: Ic51a057bb01a89a24337521a49c54a52e2073cd1
2020-04-21 15:04:28 -07:00
Jiyong Park
28665792a2 Merge "Mark some aidl_interface modules as unstable" into rvc-dev 2020-04-20 03:23:06 +00:00
Jiyong Park
db589dded4 Mark some aidl_interface modules as unstable
With b/152655547, all aidl_interface modules are considered as stable
unless it is explicitly with "unstable: true". This change marks the
aidl_interface that are not used across updatable module bounraries
as unstable, so that the build system does not run the API
dumping/checking on them.

Bug: 152655547
Test: m
Change-Id: I1257c66de6dd42b2d32d47ed74cb2878f79d14fb
2020-04-13 13:00:47 +09:00
Jeffrey Huang
9446080f3c Remove clear/restore callingUid
We no longer need to do this because UserManager.getUserHandles and
PackageManager.getInstalledPackagesAsUser are now called in a separate
background thread.

Bug: 130773130
Test: adb shell stop statsd && adb shell start statsd. Manually verified
that the uidmap was sent successfully.

Change-Id: Ifde1ba09575a479952bdbcd98aec4c34b3210974
2020-04-10 17:40:59 -07:00
Jeffrey Huang
b010fc5534 Merge changes I3f912418,Idd2465d5 into rvc-dev
* changes:
  Send boot completed to statsd
  Send puller registration signal to statsd
2020-04-10 18:38:00 +00:00
Jeffrey Huang
d8f533060d Send boot completed to statsd
Bug: 153384066
Test: m -j
Change-Id: I3f91241851a93d0869dad210bc278b3a1ba6b762
2020-04-09 17:29:19 -07:00
Jeffrey Huang
0118b5a6a0 Add APEX UIDs to PackageManager query
Because of internal implementation of one way binder calls, in order to
unblock the boot phase, we need to put both the binder call and the
filedescriptor in the background thread.

Original boot time: 17758.6ms
New boot time: 17608.0ms

Bug: 130773130
Test: DeviceBootTest.DeviceBootTest#SuccessiveBootTest
Change-Id: Ib3524418a387c5902af8139e1b2aee82525b8e04
2020-04-09 10:43:13 -07:00
Jeffrey Huang
d7fda53855 Send puller registration signal to statsd
Bug: 153384066
Test: m -j
Change-Id: Idd2465d52e6720d7bce26ecc7998721b9d9790e3
2020-04-08 22:20:41 -07:00
TreeHugger Robot
855ae008ba Merge "Change to device-tests" into rvc-dev 2020-04-08 01:45:31 +00:00
Tej Singh
fa49ff93f9 Merge "Move proto, c++, and test libs to static" into rvc-dev 2020-04-08 00:37:49 +00:00
Sundong Ahn
14867bb4b8 Change to device-tests
In cf, signing key has been changed to dev key. So LibStatsPullTests
tests is changed to device-tests.

Change-Id: I5971ae584afeebccc0ba3ed55e6579858666db79
Bug: 153482272
Test: m -j
2020-04-08 09:28:25 +09:00
Tej Singh
1d4b4653cd Move proto, c++, and test libs to static
Link libgtest_prod, libprotobuf-cpp-lite, and libc++ statically.
This reduces the size of the statsd apex from 2.8M to 1.6M.

Initial:
blueline:/apex/com.android.os.statsd # du -h
16K	./lost+found
764K	./bin
1.3M	./lib64
8.0K	./etc
600K	./lib
120K	./javalib
2.8M	.

After linking proto lite and libgtest_prod statically (saves ~500kb):
blueline:/apex/com.android.os.statsd # du -h
16K	./lost+found
800K	./bin
876K	./lib64
8.0K	./etc
600K	./lib
120K	./javalib
2.3M	.

After also linking libc++ statically (saves ~700kb):
blueline:/apex/com.android.os.statsd # du -h
16K	./lost+found
0.9M	./bin
296K	./lib64
8.0K	./etc
204K	./lib
120K	./javalib
1.6M	.

After this change, the only libraries in both /lib and /lib64 are:
libstats_jni.so
libstatspull.so
libstatssocket.so

These are the 3 libraries we actually want to ship.

Test: m
Test: bit statsd_test:*
Test: atest GtsStatsdHostTestCases
Test: manually inspecting the size of the apex, statsd binary, and
libraries
Bug: 153349706
Bug: 153349659
Bug: 153350187

Change-Id: I00796fc1cf33e394422c6dc617a8430a5f5c5bbb
2020-04-06 20:01:49 -07:00
Jooyung Han
db38a2d64e Add min_sdk_version:R to updatable apexes
APEXes introduced in R need to set min_sdk_version to ensure that they
are built against correct version(30 or R) of stubs (libc/liblog/...).

Bug: 152655956
Test: /vendor/google/build/build_mainline_modules.sh
Change-Id: I4a893c34b09334eea124266287301e479b9e8a59
2020-04-02 13:54:06 +00:00
Anton Hansson
fd3f01df12 Merge "Give MediaProvider visibility of the statsd module_libs stub" into rvc-dev 2020-04-02 11:07:16 +00:00
Jeffrey Huang
f3364db2d1 Merge "Remove Exception in getRegisteredExperimentIds" into rvc-dev 2020-04-01 17:58:45 +00:00
Jeffrey Huang
c43a267c4d Remove Exception in getRegisteredExperimentIds
This check was not useful since service can only be null if system
server is not running or the app does not have permissions to access
statsd. This check is not done anywhere else, so removing it for
consistency.

Bug: 150645647
Test: atest StatsdHostTestCases
Change-Id: I6465697f0157c5a9583025979c55cb2e3dc1ef84
2020-03-31 14:38:05 -07:00
Anton Hansson
e85c52514d Give MediaProvider visibility of the statsd module_libs stub
MediaProvider uses StatsLog.

Bug: 152891096
Test: m
Change-Id: I3e0f47b734015dde6007596afae051535184c284
2020-03-31 20:49:43 +01:00
Tej Singh
abc1b8de87 Guardrail for pull cooldown/timeout
Enforce a 1 second minimum cooldown and a 10 second maximum timeout on
pullers.

Test: bit statsd_test:*
Test: atest LibStatsPullTests
Test: atest GtsStatsdHostTestCases
Bug: 152543610
Change-Id: Ida0047235a7e56d7b700f1a7ab5cfbc2a147caeb
2020-03-30 22:26:46 -07:00
Anton Hansson
578cac6e93 Merge "Fix statsd publicapi stub default usage" into rvc-dev 2020-03-28 16:51:47 +00:00
Tej Singh
f4e17e6639 LibstatsPullTest, Testdrive updates for sandboxing
Test: atest LibStatsPullTests
Test: statsd_testdrive 10051 10004 10055
Test: adb shell cmd stats pull-source 10051 AID_STATSD
Test: adb shell cmd stats pull-source 10055 AID_GPU_SERVICE
Test: adb shell cmd stats pull-source 10004
Bug: 151642352
Change-Id: I3b104cb2f2427b4558d5175dfeb3bb2c80012d0e
2020-03-27 19:02:10 -07:00
Anton Hansson
4f8f0d9d5b Fix statsd publicapi stub default usage
It was referring to the systemapi defaults, which is incorrect.
I noticed this as I was adding all the stub txt variants to dist.

Bug: 147768409
Test: m
Change-Id: If12fe22c92fbfc82a6efce9c466990d9c3da242e
2020-03-27 21:05:16 +00:00
Anton Hansson
6efada1ada Merge "Make framework-statsd stubs use the new defaults" into rvc-dev 2020-03-26 08:39:40 +00:00
Anton Hansson
4bb837b058 Make framework-statsd stubs use the new defaults
Makes it convenient to change all stubs from a central place.
Also remove the framework-statsd-defaults that were only used
in a single place.

Bug: 149293194
Test: m framework-statsd-stubs{public,system,module_libs_}api
Change-Id: Ib2e01cddfaceb7f24fd2e60c3a365a79a035bcae
2020-03-24 19:42:36 +00:00