summaryrefslogtreecommitdiff
path: root/core/java/android/app/StatsManager.java
Commit message (Collapse)AuthorAgeFilesLines
* Migrate StatsManager to apexJeffrey Huang2020-01-231-722/+0
| | | | | | | | | | | | | | | | Link frameworks-statsd.jar against framework-all since it is currently infeasible to to link against stubs Linking against stubs in frameworks/base cannot be done because we still have StatsLog that calls StatsEvent.getBytes which is a hidden API. We can't move StatsLog to the apex because of hidden APIs in the autogenerated code which is currently being migrated. Test: m -j Bug: 147923515 Change-Id: I0a59dce83a8075bdde3e72d1d8eceef2ed572791
* Delete References to Statsd in StatsManagerJeffrey Huang2020-01-171-64/+0
| | | | | Test: adb shell cmd stats pull-source 10000 (chosen randomly) Change-Id: I9578f84213e6c2787da60ae7e2c20157087d5b6a
* Expose java puller api as @SystemAPITej Singh2020-01-171-29/+48
| | | | | | | | | Also clear calling identity before invoking the pull. Test: make Test: atest GtsStatsdHostTestCases Bug: 146383532 Change-Id: I9a17d88944da0074dbbaffb0c1b99a9ce7743991
* Migrate puller registration to StatsManagerServiceRuchir Rastogi2020-01-091-16/+2
| | | | | | | | | | | | The code path to register and uregister pullers now goes through StatsManagerService as opposed to StatsCompanionService. Pullers are also now cached in StatsManagerService. Test: m -j Test: atest GtsStatsdHostTestCases (passes even when the RVC check is removed from relevant tests) Bug: 147010937 Change-Id: I6549a41e2059c5fc9e57d861b751760ef165f879
* Update Add/Remove ConfigurationJeffrey Huang2020-01-081-4/+4
| | | | | | Test: GTS Tests Bug: 146383400 Change-Id: Ibcd6802468fa3be3ffde4357b37060711deff9b3
* Update getReportsJeffrey Huang2020-01-071-2/+2
| | | | | | Test: GTS Tests Bug: 146383638 Change-Id: Id640e568d41c5f30e7c42a06addfba644061c706
* Update getStatsMetadataJeffrey Huang2020-01-071-2/+2
| | | | | | Test: GTS Tests Bug: 146384074 Change-Id: I263489874616d4ed5d16f2796fa74c740059a35a
* Update getRegisteredExperimentIdsJeffrey Huang2020-01-071-7/+5
| | | | | | Bug: 146384076 Test: GTS Tests Change-Id: I9da3526d97d5adef423c69366f50fac59a1d6247
* Update setBroadcastSubscriberJeffrey Huang2020-01-061-5/+4
| | | | | | | | | change #setBroadcastSubscriber and #unsetBroadcastSubscriber to avoid using intentsender Bug: 146074295 Test: Ran GTS Tests Change-Id: I1510e44bcdf49b579fd49f51081c6a40618039fa
* Update activeConfigsChangedBroadcastJeffrey Huang2020-01-061-6/+4
| | | | | | | | | avoid using intentsender in #sendActiveConfigsChangedBroadcast and #removeActiveConfigsChangedBroadcast. Bug: 146074295 Test: Ran GTS Tests Change-Id: I9313299ea0bc89f092b1c62fbfc34e06a127eaa9
* Creating PendingIntentRefJeffrey Huang2020-01-061-5/+3
| | | | | | | | Update #setDataFetchOperation to avoid using intentsender. Bug: 146074295 Test: Ran GTS Tests Change-Id: I7df5c6441725aa4e46fac18925664c9455f50fb9
* Unit tests for PullAtomMetadataTej Singh2019-12-301-2/+36
| | | | | | Bug: 146385269 Test: bit FrameworksCoreTests:android.app.PullAtomMetadata Change-Id: I4c78d2744348dbab6ee792caa0a7a8bbd3c17f28
* Allow pullAtomCallbacks to be unregistered in JavaTej Singh2019-12-181-9/+47
| | | | | | | | | | | | | | | Adds an API to unregister pullAtomCallbacks. Fixes bug where the StatsEventParcels are null. Makes onPullAtom a oneway call. OnPullAtom returns an int code instead of a boolean Made the APIs return RuntimeExceptions Test: make, boots Test: atest GtsStatsdHostTestCases Bug: 146385842 Bug: 146385173 Bug: 144373250 Change-Id: I107a705a9024240c5c9f9e276293de8410e2b6f3
* Create statsmanager serviceJeffrey Huang2019-12-171-0/+14
| | | | | | Bug: 146074170 Test: Manual Change-Id: Ia96f2df24e660fe3293fb2e873e9050a55398cee
* Rename IStatsManager to IStatsdJeffrey Huang2019-12-111-13/+13
| | | | | | Bug: 146075178 Test: CTS/GTS tests Change-Id: I235944758b8cc24a0df85b54d7441e7e8d0a8bbc
* StatsEventParcel impl.; move AIDL filesRuchir Rastogi2019-12-061-3/+6
| | | | | | | | | | | This implementation continue to uses libbinder, as opposed to libbinder_ndk. We also move many (but not all) statsd aidl files from frameworks/base/core into the apex. Test: m -j128 && bit statsd_test:* Change-Id: I95f06e937e50c1e2a638163b13587682402956a7
* StatsManager uses private object for synchronizingTej Singh2019-12-051-15/+16
| | | | | | | | | | | StatsManager used to synchronize on "this", which is dangerous because an app can get StatsManager and also sychronize on it, which would block all calls. We now lock on a private final object. Test: make Bug: 144315658 Fixes: 144315658 Change-Id: Ia34b1c586b09a48b244cc16dba77fe54e81f62cf
* Merge "PullAtomMetadata for Registering Pullers"TreeHugger Robot2019-11-201-9/+98
|\
| * PullAtomMetadata for Registering PullersTej Singh2019-11-191-9/+98
| | | | | | | | | | | | | | | | | | Create PullAtomMetadata for registering pullers. This will simplify the API design and allow users to not specify the metadata if they just want to use defaults. Test: builds, boots Change-Id: I6b84c02f535fc911d1dc66768413d27f342d9515
* | Statsd implementation of puller APITej Singh2019-11-191-1/+1
|/ | | | | | | | | | | | | | | Internal implementation of the puller API. Registers pullers by putting them in the kAllPullAtomInfo map. Implements the actual pull, with condition variables to timeout. Lastly, keys the kAllPullAtom info by a PullerKey, which is a uid and atom id. However, the uid is just set to a default of -1 for now. I will work the security implementation in a follow up CL. Test: builds, boots Test: I will write unit tests in the future. It's very difficult to write any without StatsEvent being completed. Change-Id: Id602dd297b6ba7df811e2d5ab2e77efc0684e418
* Java API for pulled atomsTej Singh2019-11-131-0/+96
| | | | | | | | This creates a java API for registering pullers. Will implement the statsd side in a follow up CL. Test: builds, boots Change-Id: Ib6735984297ce3148839a6370a3c15b2a585baf5
* Expose APIs for the experiment ids back from statsd.Joe Onorato2019-04-121-1/+0
| | | | | | Bug: 129099771 Test: treehugger Change-Id: I8689a06ae5667a146064bc870be8b5a4e92fb9b7
* Merge "Add an API to read experiment IDs."Jeff Hamilton2019-03-281-0/+30
|\
| * Add an API to read experiment IDs.Jeff Hamilton2019-03-271-0/+30
| | | | | | | | | | | | | | | | | | | | | | Change the file format to store the experiment IDs direclty so we don't need to parse the proto when reading the values out. Bug: 129099771 Test: bit statsd_test:* && adb shell cmd stats pull-source 10051 Change-Id: I0dc1fd118f4d9ba597c2f0959648136bbafb5aab
* | API Feedback on setActiveConfigsChangedOperationTej Singh2019-03-201-1/+2
|/ | | | | | | | | Adds @NonNull annotation to setActiveConfigsChangedOperation as per API feedback in b/126700913. Test: builds Bug: 126700913 Change-Id: If70f311dab6751644253b6192834bec3d9ac1b3c
* Statsd Puller Callback RegistrationTej Singh2019-02-111-0/+34
| | | | | | | | | Creates a hidden api to register puller callbacks for vendor atoms. Test: manual local test Test: statsd unit tests Bug: 119898637 Change-Id: Id28817b8fc718e128adc4e1c6b2e997db84517f9
* StatsManager setActiveConfigsChangedOperation APITej Singh2019-01-281-2/+5
| | | | | | | | | | | Changes the return type of the setActiveConfigsChangedOperation to long[] since it returns the configs that are currently active for the given client. Test: manually tested with local gmscore Bug: 122806328 Change-Id: I49c4a28313c1e410dd1fa61f6b8393334fecea5d
* APIs for registering config activation broadcastsTej Singh2019-01-251-0/+42
| | | | | | | | | | | | | | | Creates a StatsManager API to register a pending intent that is invoked whenever the active status of any of any config sent by that uid changes. ag/6112554 and further cls are needed to properly send back the pending intent. Bug: 123372077 Test: build success on blueline-eng. More thorough testing should be done once ag/6112554 is submitted. Change-Id: I36985c9820d4e7ac178064924190af88ea822254
* StatsManager: @Deprecated always-deprecated fieldsBookatz2018-12-041-0/+6
| | | | | | | | | | | | | | | When P shipped, StatsManager had some new (introduced in P) APIs that were already deprecated but had been needed temporarily. No one should ever have used these APIs when P shipped because they already had comments instructing the reader that they were deprecated. They were not marked @Deprecated, however, so this cl does that. Fixes: 113856561 Fixes: 77648233 Test: still compiles Test: make ROBOTEST_FILTER=AnomalyConfigJobServiceTest RunSettingsRoboTests Test: gts-tradefed run gts-dev --module GtsStatsdHostTestCases Change-Id: I7c5cdc616f806b9aa5a5e4ee4229750973f533ed
* Marks deprecated StatsManager APIs.David Chen2018-05-211-10/+12
| | | | | | | | Marking some API's as deprecated, so users avoid getting confused. Test: Test that build works. Bug: 80099023 Change-Id: I4b3d4e4fa1ee3d706e49b8180aa4d0ad0e7d6eeb
* Protect usage data with OP_GET_USAGE_STATS.Jeff Sharkey2018-04-161-23/+46
| | | | | | | | | | | | | | APIs that return package usage data (such as the new StatsManager) must ensure that callers hold both the PACKAGE_USAGE_STATS permission and the OP_GET_USAGE_STATS app-op. Add noteOp() method that can be called from native code. Also add missing security checks on command interface. Bug: 77662908, 78121728 Test: builds, boots Change-Id: Ie0d51e4baaacd9d7d36ba0c587ec91a870b9df17
* StatsManager throws exceptionsBookatz2018-04-101-66/+147
| | | | | | | | | | | | | | | When StatsManager fails to connect to statsd, it now throws an exception for the caller to catch. It also throws an exception of the config being added is of an unreadable format. Due to backwards compatibility issues, the old APIs could not be changed, so new ones were made to replace the old ones. The old ones are now temporary and will be removed when the compatibility issue is resolved. Bug: 77648233 Test: gts-tradefed run gts-dev --module GtsStatsdHostTestCases Change-Id: Ibea05883a29b9b3ef9927d2f8fe295eb99832ab7
* Small fixes to StatsManager API.David Chen2018-03-191-12/+6
| | | | | | | | | Adds some annotations, deletes an unused API method, and adds some comments. Test: Flashed onto marlin-eng and verified there are no crashes. Bug: 72562867 Change-Id: I6c93ee4aeeacf6842795256c76551cfb1c28888d
* StatsManager log lines should be in logcatBookatz2018-03-181-12/+12
| | | | | | | | | | Change the Slog.d to Slog.w and enable them, so that we can see them. They seem to represent important failure events when people call the public API into StatsManager. Bug: 74997752 Test: none Change-Id: I1c577b32358158f73453a8a3066013e0f3733d87
* Statsd BroadcastSubscribers can receive 'cookies'Bookatz2018-03-091-1/+8
| | | | | | | | | | | | Subscribers can now provide additional Strings that will be passed back to it when an anomaly is detected. This way, the Subscriber can be informed about anomaly-specific information has meaning to it. Statsd itself does not use these strings and doesn't care what they are - it simply passes them back to the subscriber. Change-Id: If269872397c4ed2c67e41d54d850cdc664d4f73e Fixes: 74012329 Test: run cts-dev -m CtsStatsdHostTestCases -t android.cts.statsd.alert.BroadcastSubscriberTests
* Revert "Small fixes to StatsManager API."Maurice Lam2018-02-281-7/+13
| | | | | | | | | This reverts commit 16dcd33abdc80b3bd4455ec867a32675f66faa13. Reason for revert: b/73975175 Bug: 73975175 Change-Id: I5bcccde100900b1370c2e43b8bcfc7d1697e5c72
* Small fixes to StatsManager API.David Chen2018-02-221-13/+7
| | | | | | | | | Adds some annotations, deletes an unused API method, and adds some comments. Test: Test that make succeeds. Bug: 72562867 Change-Id: I6c93ee4aeeacf6842795256c76551cfb1c28888d
* Merge "Turn off debug logging in statsd"TreeHugger Robot2018-02-091-8/+9
|\
| * Turn off debug logging in statsdTej Singh2018-02-081-8/+9
| | | | | | | | | | | | | | | | | | | | Sets DEBUG to false everywhere and replaces all ALOGD with VLOG so they do not print with DEBUG false. Leaves all ALOGI, ALOGW and ALOGE as is. Test: ran all CTS tests and checked "adb logcat -s statsd" to make sure it wasn't spammy Change-Id: Iaa8eb3a0a63723ffe40f94f2815f94df877fd432
* | Temporary fix to prevent breakage with new API.David Chen2018-02-081-0/+8
|/ | | | | | | | | | Adds back in the old method signature. This temporary method can be deleted in a week or so, after all callers have been migrated to the new API. Test: Test that make finishes. Bug: 72562867 Change-Id: I608fcab0ac5508a482fc8d1e63490d3cfc1fedb1
* Statsd notifies listener with pendingintent.David Chen2018-02-071-26/+64
| | | | | | | | | | | | | Previously, statsd would inform interested listeners that it's time to collect data via a protected broadcast. However, the preferred solution is to pass a PendingIntent via a separate setter. Whenever statsd wants the listener to call getData, StatsCompanionService will trigger the pending intent. Test: Tested in marlin-eng that functionality works as expected with dogfood app. Bug: 72562867 Change-Id: Ibcfcd5072a1a78947f8a7cbcd0bc429b54351da3
* Statsd broadcasts when it is aliveBookatz2018-01-241-0/+6
| | | | | | | | | | | | | | | To send configurations and PendingIntents to statsd, statsd must first be alive. In particular, a PendingIntent must be resent to statsd each time it starts (they are not stored, since reboots make them expire anyway). Therefore, statsd needs to send a broadcast to inform them of its starting. The broadcast receiver will require DUMP permission. Bug: 72450885 Bug: 70389379 Test: manually confirmed broadcast is sent Change-Id: I47c130130342465a50cd625bdb135855d5d04f6e
* Statsd broadcast subscriberBookatz2018-01-241-0/+238
Allows a uid that uploads a statsd config to additionally register a BroadcastSubscriber with statsd. If statsd detects an anomaly (according to the config's Alert), statsd can inform a BroadcastSubscriber provided in the config. The config uses a subscriberId (just an int) to identify the BroadcastSubscriber. It then uses StatsManager.setBroadcastSubscriber to associate that subscriberId with a given PendingIntent. Then, when the anomaly is detected, statsd sends a broadcast using that PendingIntent, alerting whoever was specified by the config/setBroadcastSubscriber. Bug: 70356901 Test: cts-tradefed run cts-dev -m CtsStatsdHostTestCases -t android.cts.statsd.alert.BroadcastSubscriberTests Change-Id: I4d9ea9a6c8a85e61fadfd99c1513c55abbadd5e9