Commit Graph

19 Commits

Author SHA1 Message Date
Ruchir Rastogi
c480dd54ba Use proper platform version checks (apigen)
Test: m statslog-docsui-java-gen
Bug: 146235828
Change-Id: I5b1a2e0fa356368b91548bd050ec2c493b72f37c
2020-05-07 12:32:54 -07:00
Muhammad Qureshi
3f9c330eef Make state_option top-level boolean annotations
- Add AnnotationId enum stats-log-api-gen
- Rename RESET_STATE annotation to TRIGGER_STATE_RESET. Also rename the proto annotation.

Bug: 152412767
Test: stats-log-api-gen-test
Test: m statslog-framework-java-gen
Change-Id: I2c12ea0b9222ef28b8cc11ea36b272e518a96259
2020-04-03 17:00:55 -07:00
Muhammad Qureshi
4b141386b0 Use constant names instead of literals
Use constant names instead of literals when writing annotations to
increase readability.

FrameworkStatsLog.java: https://paste.googleplex.com/4789132691767296
statslog.h: https://paste.googleplex.com/4986214782337024
statslog.cpp: https://paste.googleplex.com/4856851575341056

Bug: 151786433
Test: m statslog-framework-java-gen
Test: m libstatslog
Change-Id: I47111fe02319bebf41f429642fb675f7a856710b
2020-03-31 17:52:07 -07:00
Muhammad Qureshi
23daf2656c Only send reset state annotation when needed
Only send reset state annotation when reset state occurs.

Bug: 151776731
Test: m libstatslog

Change-Id: I6f6b4d784d3741c0059085421565eba81db5527c
2020-03-27 02:23:38 -07:00
Muhammad Qureshi
c6c38632af Group annotations for the same atom id
Group annotations for the same atom id inside one if-block in generated
code.

Use shared_ptr to store AtomDecls in multiple data structures.

Store a mapping of field numbers to atoms that have annotations at
corresponding field numbers in Collation.h

Bug: 151744250
Test: stats-log-api-gen-test
Test: m stats-log-api-gen
Test: m libstatsmetadata
Test: m statslog-framework-java-gen
Test: m libstatslog

Change-Id: I874696cfb5c27141017b4293bec809ab510ceb98
2020-03-26 14:51:28 -07:00
Muhammad Qureshi
a345af9b40 Run clang-format in stats_log_api_gen
Bug: 152253223
Test: m stats-log-api-gen
Test: stats-log-api-gen-test
Change-Id: Iad76baea8cc9ae7b3978f1133ab94d8e96bbbafe
2020-03-24 17:35:08 -07:00
Muhammad Qureshi
9b995809fb Add truncate_timestamp annotation
Mark privacy-sensitive atoms with truncate_timestamp annotation.

Factor out annotation collation to a helper method.

Add truncate_timestamp annotation support in stats-log-api-gen.

Add writeAnnotation* calls in Java and native generated code for
atom id annotations.

TODO: remove kTruncatingTimestampAtoms from atoms_info.
TODO: use truncate_timestamp annotation inside statsd.

Bug: 151111680
Test: stats-log-api-gen-test
Test: m statslog-framework-java-gen
Test: m libstatsmetadata

Change-Id: I3db5f4ffbf959bd36c62f890cc88606912798d40
2020-03-24 16:49:36 -07:00
Jeffrey Huang
f960305a31 StatsEvent annotations java autogen
Autogenerate annotations for atoms logged in java.

generated FrameworkStatsLog.java:
https://paste.googleplex.com/4789132691767296

Bug: 151102209
Test: m stats-log-api-gen
Test: m statslog-framework-java-gen
Change-Id: I50b01feaacfcb8ad5d0236432ceb0e97c8c907ab
2020-03-17 22:01:58 -07:00
Muhammad Qureshi
b13a3214a1 Store annotation during collation
- Only collate atoms in the specified module.

- Replace signature_to_modules with signatureInfoMap. This maps each
signature to another map keyed by field number and whose values are vector of
annotations.

Bug: 151102006
Test: stats-log-api-gen-test
Change-Id: I25bbe4883c8f7f86a06d04d27cd425367b6d65a0
2020-03-17 20:19:04 -07:00
Muhammad Qureshi
4ef3c3bd26 Delete unused code in stats-log-api-gen
Bug: 145100015
Test: m
Change-Id: Idbbe35fbce0d751a5973128406596678e1ead5d3
2020-03-05 10:21:36 -08:00
Muhammad Qureshi
ad94425b15 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
2020-01-17 08:36:52 -08:00
Muhammad Qureshi
996afa633c 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
2020-01-15 13:35:41 -08:00
Muhammad Qureshi
b6f32d9fe2 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
2020-01-08 16:10:57 -08:00
Muhammad Qureshi
167ba844d7 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
2020-01-02 15:05:52 -08:00
Muhammad Qureshi
4fdc7fd375 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
2020-01-02 14:54:16 -08:00
TreeHugger Robot
5e68b5c709 Merge "Fix StatsEvent memory usage for pulled events" 2019-12-10 23:18:07 +00:00
Muhammad Qureshi
9e829804e1 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
2019-12-10 13:27:38 -08:00
Muhammad Qureshi
67df8893dd Handle nulls in Java autogeneration
Bug: 143979391
Test: m -j
Change-Id: I93146faa1976cac195c2250832d12ee4a09ae969
2019-12-08 20:40:46 -08:00
Muhammad Qureshi
9effe48706 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
2019-11-25 12:50:49 -08:00