summaryrefslogtreecommitdiff
path: root/cmds/statsd/tests/shell/ShellSubscriber_test.cpp
diff options
context:
space:
mode:
authorTej Singh <singhtejinder@google.com>2020-03-04 20:08:38 -0800
committerTej Singh <singhtejinder@google.com>2020-03-27 18:07:24 -0700
commit3be093b518e2bca5df14d4816dbc1a17f0fe7f2a (patch)
tree18f467d35b12c68d4a9dc27b0739e31406213c0b /cmds/statsd/tests/shell/ShellSubscriber_test.cpp
parent0941d63aeed85374285a86151da96770a49367ed (diff)
Uid Sandboxing of Pullers
Overall flow of implementation: 1. parsing the config in MetricsManager to store the uids per atom. It follows the mAllowedLogSources logic very closely 2. MetricsManager register itself as a PullUidProvider with the PullerManager. 3. Metrics pass the config key when pulling (for both registering receivers and normal pulls) , and the puller manager gets the allowed uids from the PullUidProvider for that config. 4. PullerManager keys receivers by <atomId, configKey> so that it can look up the uids for that atom using the PullUidProvider as well. 5. Added shell subscriber support. Hardcode a default of AID_SYSTEM for them and also allow packages per atom. This involved adding a second interface to Pull that simply accepts the uids, since I didnt want to make the ShellSubscriber a PullUidProvider as well. 6. Change adb shell cmd stats pull-source to allow users to specify a package. Default to AID_SYSTEM as well. Notes: The feature is flagged off right now, since configs do not pass in the desired package. Another approach could be to hardcode in the current mapping, but that doesn't work for OEM pulled atoms. Test: m statsd Test: bit statsd_test:* with useUids = false Test: bit statsd_test:* with useUids = true Bug: 144099783 Bug: 151978258 Change-Id: I4a7481d7402a52b9beb4ea28b102803f9e50e79f
Diffstat (limited to 'cmds/statsd/tests/shell/ShellSubscriber_test.cpp')
-rw-r--r--cmds/statsd/tests/shell/ShellSubscriber_test.cpp6
1 files changed, 4 insertions, 2 deletions
diff --git a/cmds/statsd/tests/shell/ShellSubscriber_test.cpp b/cmds/statsd/tests/shell/ShellSubscriber_test.cpp
index 5eef92e12ba9..ac3ad690f81e 100644
--- a/cmds/statsd/tests/shell/ShellSubscriber_test.cpp
+++ b/cmds/statsd/tests/shell/ShellSubscriber_test.cpp
@@ -187,8 +187,10 @@ TEST(ShellSubscriberTest, testPulledSubscription) {
sp<MockUidMap> uidMap = new NaggyMock<MockUidMap>();
sp<MockStatsPullerManager> pullerManager = new StrictMock<MockStatsPullerManager>();
- EXPECT_CALL(*pullerManager, Pull(10016, _))
- .WillRepeatedly(Invoke([](int tagId, vector<std::shared_ptr<LogEvent>>* data) {
+ const vector<int32_t> uids = {AID_SYSTEM};
+ EXPECT_CALL(*pullerManager, Pull(10016, uids, _, _))
+ .WillRepeatedly(Invoke([](int tagId, const vector<int32_t>&,
+ vector<std::shared_ptr<LogEvent>>* data, bool) {
data->clear();
data->push_back(makeCpuActiveTimeAtom(/*uid=*/kUid1, /*timeMillis=*/kCpuTime1));
data->push_back(makeCpuActiveTimeAtom(/*uid=*/kUid2, /*timeMillis=*/kCpuTime2));