Commit Graph

8 Commits

Author SHA1 Message Date
Muhammad Qureshi
b11e00d655 Add flag to stats-log-api-gen for WorkSource.
As part of getting rid of StatsLogInternal and moving every atom to be
logged from a module, this CL addresses 2 issues:
1. Add WorkSource logging to modules.
2. Gate WorkSource logging via a CLI flag to prevent WorkSource methods
from being included in modules that are Mainline modules and can't have
@hide calls.

Bug: 147541828
Test: m
Test: atest android.cts.statsd.atom.UidAtomTests

Change-Id: Icce2f6ed7298be5e5ceebfb05d87e6fa7cd6bdbb
Merged-In: Icce2f6ed7298be5e5ceebfb05d87e6fa7cd6bdbb
2020-01-23 11:39:38 -08:00
Muhammad Qureshi
17c204de33 Make writeKeyValuePairs accept Nullable args
API Review requested to remove unneeded allocations so pass null for
arguments that are empty when writing KeyValuePairs

Bug: 146383532
Test: m
Change-Id: Ic1788f65e8c7f837d6800d59c186519a82882bf7
Merged-In: Ic1788f65e8c7f837d6800d59c186519a82882bf7
(cherry picked from commit 996afa633c)
2020-01-23 11:32:07 -08:00
Muhammad Qureshi
0c8cdf54db Use preview_sdk_int for version code checks
Don't use Build.VERSION.CODENAME to check for R.
Use Build.VERSION.SDK_INT > Q || (Build.VERSION.SDK_INT == Q &&
        Build.VERSION.PREVIEW_SDK_INT > 0)

Bug: 146235828
Test: m DocumentsUIGoogle

Change-Id: I59e327d4e92d41a93b6bea145b8497fd4f85108c
Merged-In: I59e327d4e92d41a93b6bea145b8497fd4f85108c
(cherry picked from commit b6f32d9fe2)
2020-01-23 11:29:21 -08:00
Muhammad Qureshi
7182159154 Add --supportQ flag to java StatsLog codegen
Add support to generate Q schema code generation only for modules that
ship to Q.

Bug: 145606209
Test: m
Test: flashes successfully
Test: adb logcat "*:S statsd:*"
Change-Id: I978ac321415f1e8d76e4ec73445894965845aaea
Merged-In: I978ac321415f1e8d76e4ec73445894965845aaea
2020-01-08 17:07:18 -08:00
Muhammad Qureshi
6f65881d62 Support new socket schema in native codegen
New code generation implementation is flag guarded by
STATS_SCHEMA_LEGACY

Support for Q schema can be added by passing --supportQ flag in
stats_log_api_gen. (Only needed for statslog_resolv.cpp)

Q schema is supported through StatsEventCompat.

Generated R schema statslog.h:
https://paste.googleplex.com/4986214782337024

Generated R schema statslog.cpp:
https://paste.googleplex.com/4856851575341056

Generated R schema statslog_resolv.h:
https://paste.googleplex.com/6062978921136128

Generated R schema statslog_resolv.cpp:
https://paste.googleplex.com/4752329251225600

Generated Q schema statslog.h:
https://paste.googleplex.com/4766729873915904

Generated Q schema statslog.cpp:
https://paste.googleplex.com/5018563779756032

Generated Q schema statslog_resolv.h:
https://paste.googleplex.com/5338897498243072

Generated Q schema statslog_resolv.cpp:
https://paste.googleplex.com/5191011011657728

Test: m -j
Test: flashes successfully
Test: adb logcat inspection
Change-Id: I5675a80c03ca3fbd5cd4a02c04a4b9cb89ec32ab
Merged-In: I5675a80c03ca3fbd5cd4a02c04a4b9cb89ec32ab
2020-01-08 17:06:18 -08:00
Muhammad Qureshi
2a4c0782b5 Fix StatsEvent memory usage for pulled events
Add usePooledBuffer flag to the Builder which determines whether to reuse
the Buffer's byte array in StatsEvent or use a copy.
The build() function also calls release() on the Buffer
if a copy of the Buffer's byte array is passed to StatsEvent.

Also, for pushed events, release the StatsEvent object and consequently,
the Buffer in StatsLog.write(StatsEvent)

Fixes: 145026572
Fixes: 144126444
Test: bit FrameworksCoreTests:android.util.StatsEventTest
Change-Id: I1cdaf0027b69281cb7cb6f3c8ca923d03829b4dd
Merged-In: I1cdaf0027b69281cb7cb6f3c8ca923d03829b4dd
2020-01-08 17:04:27 -08:00
Muhammad Qureshi
01268dec13 Handle nulls in Java autogeneration
Bug: 143979391
Test: m -j
Change-Id: I93146faa1976cac195c2250832d12ee4a09ae969
Merged-In: I93146faa1976cac195c2250832d12ee4a09ae969
2020-01-08 17:02:22 -08:00
Muhammad Qureshi
ef19b08b05 Use StatsEvent in Java autogenerated code
The change is guarded by STATS_SCHEMA_LEGACY flag in the autogenerator
Android.bp.

The flag can only be removed once rest of statsd switches over to the
new socket schema.

The new autogeneration uses StatsEvent for both Mainline module
clients and the default platform client. For Mainline modules, the
autogenerated code uses a runtime dessert version check to use new
socket schema on R+ platforms and the legacy schema on the older
platforms.

The legacy schema is encapsulated in a separate autogenerated inner
class called QLogger.

generated DocumentsStatsLog.java: https://paste.googleplex.com/4665805503463424
generated StatsLogInternal.java: https://paste.googleplex.com/5955095055302656
generated android_util_StatsLogInternal.cpp:
    https://paste.googleplex.com/6737331711115264

Bug: 142811546
Test: m -j && m -j DocumentsUIGoogle
Test: Flashes successfully and events are logged to statsd
Change-Id: I4c804eaf4d5ae78001146c89ebe46dfb0a453853
Merged-In: I4c804eaf4d5ae78001146c89ebe46dfb0a453853
2020-01-08 17:01:43 -08:00