blob: 32da94f862c59b76363ee026e78562f871f689e5 [file] [log] [blame]
Joe Onorato5dcbc6c2017-08-29 15:13:58 -07001/*
yro0feae942017-11-15 14:38:48 -08002 * Copyright (C) 2017 The Android Open Source Project
Joe Onorato5dcbc6c2017-08-29 15:13:58 -07003 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
yro74fed972017-11-27 14:42:42 -080017#define DEBUG true // STOPSHIP if true
Joe Onorato9fc9edf2017-10-15 20:08:52 -070018#include "Log.h"
Joe Onorato5dcbc6c2017-08-29 15:13:58 -070019
20#include "StatsService.h"
Yao Chen8d9989b2017-11-18 18:54:50 -080021#include "android-base/stringprintf.h"
David Chenadaf8b32017-11-03 15:42:08 -070022#include "config/ConfigKey.h"
23#include "config/ConfigManager.h"
Yao Chen8d9989b2017-11-18 18:54:50 -080024#include "guardrail/MemoryLeakTrackUtil.h"
Yao Chenb3561512017-11-21 18:07:17 -080025#include "guardrail/StatsdStats.h"
yro947fbce2017-11-15 22:50:23 -080026#include "storage/StorageManager.h"
Bookatzc6977972018-01-16 16:55:05 -080027#include "subscriber/SubscriberReporter.h"
Joe Onorato5dcbc6c2017-08-29 15:13:58 -070028
David Chen0656b7a2017-09-13 15:53:39 -070029#include <android-base/file.h>
Joe Onorato5dcbc6c2017-08-29 15:13:58 -070030#include <binder/IPCThreadState.h>
31#include <binder/IServiceManager.h>
yro87d983c2017-11-14 21:31:43 -080032#include <dirent.h>
David Chen0656b7a2017-09-13 15:53:39 -070033#include <frameworks/base/cmds/statsd/src/statsd_config.pb.h>
Joe Onorato5dcbc6c2017-08-29 15:13:58 -070034#include <private/android_filesystem_config.h>
35#include <utils/Looper.h>
Joe Onorato2cbc2cc2017-08-30 17:03:23 -070036#include <utils/String16.h>
Bookatzb223c4e2018-02-01 15:35:04 -080037#include <statslog.h>
Joe Onorato5dcbc6c2017-08-29 15:13:58 -070038#include <stdio.h>
Yao Chen482d2722017-09-12 13:25:43 -070039#include <stdlib.h>
Joe Onorato9fc9edf2017-10-15 20:08:52 -070040#include <sys/system_properties.h>
Yao Chenef99c4f2017-09-22 16:26:54 -070041#include <unistd.h>
Joe Onorato5dcbc6c2017-08-29 15:13:58 -070042
43using namespace android;
44
Bookatz906a35c2017-09-20 15:26:44 -070045namespace android {
46namespace os {
47namespace statsd {
48
David Chenadaf8b32017-11-03 15:42:08 -070049constexpr const char* kPermissionDump = "android.permission.DUMP";
yro03faf092017-12-12 00:17:50 -080050#define STATS_SERVICE_DIR "/data/misc/stats-service"
David Chenadaf8b32017-11-03 15:42:08 -070051
Joe Onorato9fc9edf2017-10-15 20:08:52 -070052// ======================================================================
53/**
54 * Watches for the death of the stats companion (system process).
55 */
56class CompanionDeathRecipient : public IBinder::DeathRecipient {
57public:
58 CompanionDeathRecipient(const sp<AnomalyMonitor>& anomalyMonitor);
59 virtual void binderDied(const wp<IBinder>& who);
60
61private:
62 const sp<AnomalyMonitor> mAnomalyMonitor;
63};
64
65CompanionDeathRecipient::CompanionDeathRecipient(const sp<AnomalyMonitor>& anomalyMonitor)
66 : mAnomalyMonitor(anomalyMonitor) {
67}
68
69void CompanionDeathRecipient::binderDied(const wp<IBinder>& who) {
70 ALOGW("statscompanion service died");
71 mAnomalyMonitor->setStatsCompanionService(nullptr);
Bookatzc6977972018-01-16 16:55:05 -080072 SubscriberReporter::getInstance().setStatsCompanionService(nullptr);
Joe Onorato9fc9edf2017-10-15 20:08:52 -070073}
74
75// ======================================================================
Joe Onorato5dcbc6c2017-08-29 15:13:58 -070076StatsService::StatsService(const sp<Looper>& handlerLooper)
Bookatz1d0136d2017-12-01 11:13:32 -080077 : mAnomalyMonitor(new AnomalyMonitor(MIN_DIFF_TO_UPDATE_REGISTERED_ALARM_SECS))
Joe Onorato5dcbc6c2017-08-29 15:13:58 -070078{
Joe Onorato9fc9edf2017-10-15 20:08:52 -070079 mUidMap = new UidMap();
80 mConfigManager = new ConfigManager();
Yangster-mac20877162017-12-22 17:19:39 -080081 mProcessor = new StatsLogProcessor(mUidMap, mAnomalyMonitor, time(nullptr), [this](const ConfigKey& key) {
yro947fbce2017-11-15 22:50:23 -080082 sp<IStatsCompanionService> sc = getStatsCompanionService();
David Chen1d7b0cd2017-11-15 14:20:04 -080083 auto receiver = mConfigManager->GetConfigReceiver(key);
84 if (sc == nullptr) {
yro74fed972017-11-27 14:42:42 -080085 VLOG("Could not find StatsCompanionService");
David Chen1d7b0cd2017-11-15 14:20:04 -080086 } else if (receiver.first.size() == 0) {
yro74fed972017-11-27 14:42:42 -080087 VLOG("Statscompanion could not find a broadcast receiver for %s",
88 key.ToString().c_str());
David Chen1d7b0cd2017-11-15 14:20:04 -080089 } else {
90 sc->sendBroadcast(String16(receiver.first.c_str()),
91 String16(receiver.second.c_str()));
92 }
yro31eb67b2017-10-24 13:33:21 -070093 });
Joe Onorato9fc9edf2017-10-15 20:08:52 -070094
95 mConfigManager->AddListener(mProcessor);
96
97 init_system_properties();
Joe Onorato5dcbc6c2017-08-29 15:13:58 -070098}
99
Yao Chenef99c4f2017-09-22 16:26:54 -0700100StatsService::~StatsService() {
Joe Onorato5dcbc6c2017-08-29 15:13:58 -0700101}
102
Joe Onorato9fc9edf2017-10-15 20:08:52 -0700103void StatsService::init_system_properties() {
104 mEngBuild = false;
105 const prop_info* buildType = __system_property_find("ro.build.type");
106 if (buildType != NULL) {
107 __system_property_read_callback(buildType, init_build_type_callback, this);
108 }
David Chen0656b7a2017-09-13 15:53:39 -0700109}
110
Joe Onorato9fc9edf2017-10-15 20:08:52 -0700111void StatsService::init_build_type_callback(void* cookie, const char* /*name*/, const char* value,
112 uint32_t serial) {
Yao Chen729093d2017-10-16 10:33:26 -0700113 if (0 == strcmp("eng", value) || 0 == strcmp("userdebug", value)) {
Joe Onorato9fc9edf2017-10-15 20:08:52 -0700114 reinterpret_cast<StatsService*>(cookie)->mEngBuild = true;
115 }
116}
117
118/**
119 * Implement our own because the default binder implementation isn't
120 * properly handling SHELL_COMMAND_TRANSACTION.
121 */
Yao Chenef99c4f2017-09-22 16:26:54 -0700122status_t StatsService::onTransact(uint32_t code, const Parcel& data, Parcel* reply,
123 uint32_t flags) {
Joe Onorato2cbc2cc2017-08-30 17:03:23 -0700124 status_t err;
125
126 switch (code) {
127 case SHELL_COMMAND_TRANSACTION: {
128 int in = data.readFileDescriptor();
129 int out = data.readFileDescriptor();
130 int err = data.readFileDescriptor();
131 int argc = data.readInt32();
132 Vector<String8> args;
133 for (int i = 0; i < argc && data.dataAvail() > 0; i++) {
134 args.add(String8(data.readString16()));
135 }
Yao Chenef99c4f2017-09-22 16:26:54 -0700136 sp<IShellCallback> shellCallback = IShellCallback::asInterface(data.readStrongBinder());
137 sp<IResultReceiver> resultReceiver =
138 IResultReceiver::asInterface(data.readStrongBinder());
Joe Onorato2cbc2cc2017-08-30 17:03:23 -0700139
140 FILE* fin = fdopen(in, "r");
141 FILE* fout = fdopen(out, "w");
142 FILE* ferr = fdopen(err, "w");
143
144 if (fin == NULL || fout == NULL || ferr == NULL) {
145 resultReceiver->send(NO_MEMORY);
146 } else {
147 err = command(fin, fout, ferr, args);
148 resultReceiver->send(err);
149 }
150
151 if (fin != NULL) {
152 fflush(fin);
153 fclose(fin);
154 }
155 if (fout != NULL) {
156 fflush(fout);
157 fclose(fout);
158 }
159 if (fout != NULL) {
160 fflush(ferr);
161 fclose(ferr);
162 }
163
164 return NO_ERROR;
165 }
Yao Chenef99c4f2017-09-22 16:26:54 -0700166 default: { return BnStatsManager::onTransact(code, data, reply, flags); }
Joe Onorato2cbc2cc2017-08-30 17:03:23 -0700167 }
168}
169
Joe Onorato9fc9edf2017-10-15 20:08:52 -0700170/**
171 * Write debugging data about statsd.
172 */
Yao Chenef99c4f2017-09-22 16:26:54 -0700173status_t StatsService::dump(int fd, const Vector<String16>& args) {
Joe Onorato5dcbc6c2017-08-29 15:13:58 -0700174 FILE* out = fdopen(fd, "w");
175 if (out == NULL) {
176 return NO_MEMORY; // the fd is already open
177 }
178
Yao Chen884c8c12018-01-26 10:36:25 -0800179 bool verbose = false;
180 if (args.size() > 0 && !args[0].compare(String16("-v"))) {
181 verbose = true;
182 }
183
Joe Onorato9fc9edf2017-10-15 20:08:52 -0700184 // TODO: Proto format for incident reports
Yao Chen884c8c12018-01-26 10:36:25 -0800185 dump_impl(out, verbose);
Joe Onorato5dcbc6c2017-08-29 15:13:58 -0700186
187 fclose(out);
188 return NO_ERROR;
189}
190
Joe Onorato9fc9edf2017-10-15 20:08:52 -0700191/**
192 * Write debugging data about statsd in text format.
193 */
Yao Chen884c8c12018-01-26 10:36:25 -0800194void StatsService::dump_impl(FILE* out, bool verbose) {
Yao Chenf5acabe2018-01-17 14:10:34 -0800195 StatsdStats::getInstance().dumpStats(out);
Yao Chen884c8c12018-01-26 10:36:25 -0800196 mProcessor->dumpStates(out, verbose);
Joe Onorato9fc9edf2017-10-15 20:08:52 -0700197}
198
199/**
200 * Implementation of the adb shell cmd stats command.
201 */
Yao Chenef99c4f2017-09-22 16:26:54 -0700202status_t StatsService::command(FILE* in, FILE* out, FILE* err, Vector<String8>& args) {
Joe Onorato9fc9edf2017-10-15 20:08:52 -0700203 // TODO: Permission check
204
205 const int argCount = args.size();
206 if (argCount >= 1) {
207 // adb shell cmd stats config ...
David Chen0656b7a2017-09-13 15:53:39 -0700208 if (!args[0].compare(String8("config"))) {
Joe Onorato9fc9edf2017-10-15 20:08:52 -0700209 return cmd_config(in, out, err, args);
David Chen0656b7a2017-09-13 15:53:39 -0700210 }
Joe Onorato9fc9edf2017-10-15 20:08:52 -0700211
David Chende701692017-10-05 13:16:02 -0700212 if (!args[0].compare(String8("print-uid-map"))) {
Yao Chend10f7b12017-12-18 12:53:50 -0800213 return cmd_print_uid_map(out, args);
David Chende701692017-10-05 13:16:02 -0700214 }
Yao Chen729093d2017-10-16 10:33:26 -0700215
216 if (!args[0].compare(String8("dump-report"))) {
217 return cmd_dump_report(out, err, args);
218 }
David Chen1481fe12017-10-16 13:16:34 -0700219
220 if (!args[0].compare(String8("pull-source")) && args.size() > 1) {
221 return cmd_print_pulled_metrics(out, args);
222 }
David Chenadaf8b32017-11-03 15:42:08 -0700223
224 if (!args[0].compare(String8("send-broadcast"))) {
David Chen1d7b0cd2017-11-15 14:20:04 -0800225 return cmd_trigger_broadcast(out, args);
226 }
227
228 if (!args[0].compare(String8("print-stats"))) {
Yao Chenb3561512017-11-21 18:07:17 -0800229 return cmd_print_stats(out, args);
David Chenadaf8b32017-11-03 15:42:08 -0700230 }
yro87d983c2017-11-14 21:31:43 -0800231
Yao Chen8d9989b2017-11-18 18:54:50 -0800232 if (!args[0].compare(String8("meminfo"))) {
233 return cmd_dump_memory_info(out);
234 }
yro947fbce2017-11-15 22:50:23 -0800235
236 if (!args[0].compare(String8("write-to-disk"))) {
237 return cmd_write_data_to_disk(out);
238 }
Bookatzb223c4e2018-02-01 15:35:04 -0800239
240 if (!args[0].compare(String8("log-app-hook"))) {
241 return cmd_log_app_hook(out, args);
242 }
Joe Onorato2cbc2cc2017-08-30 17:03:23 -0700243 }
Joe Onorato2cbc2cc2017-08-30 17:03:23 -0700244
Joe Onorato9fc9edf2017-10-15 20:08:52 -0700245 print_cmd_help(out);
Joe Onorato2cbc2cc2017-08-30 17:03:23 -0700246 return NO_ERROR;
247}
248
Joe Onorato9fc9edf2017-10-15 20:08:52 -0700249void StatsService::print_cmd_help(FILE* out) {
250 fprintf(out,
251 "usage: adb shell cmd stats print-stats-log [tag_required] "
252 "[timestamp_nsec_optional]\n");
253 fprintf(out, "\n");
254 fprintf(out, "\n");
Yao Chen8d9989b2017-11-18 18:54:50 -0800255 fprintf(out, "usage: adb shell cmd stats meminfo\n");
256 fprintf(out, "\n");
257 fprintf(out, " Prints the malloc debug information. You need to run the following first: \n");
258 fprintf(out, " # adb shell stop\n");
259 fprintf(out, " # adb shell setprop libc.debug.malloc.program statsd \n");
260 fprintf(out, " # adb shell setprop libc.debug.malloc.options backtrace \n");
261 fprintf(out, " # adb shell start\n");
262 fprintf(out, "\n");
263 fprintf(out, "\n");
Yao Chend10f7b12017-12-18 12:53:50 -0800264 fprintf(out, "usage: adb shell cmd stats print-uid-map [PKG]\n");
Joe Onorato9fc9edf2017-10-15 20:08:52 -0700265 fprintf(out, "\n");
266 fprintf(out, " Prints the UID, app name, version mapping.\n");
Yao Chend10f7b12017-12-18 12:53:50 -0800267 fprintf(out, " PKG Optional package name to print the uids of the package\n");
Joe Onorato9fc9edf2017-10-15 20:08:52 -0700268 fprintf(out, "\n");
269 fprintf(out, "\n");
yro3fca5ba2017-11-17 13:22:52 -0800270 fprintf(out, "usage: adb shell cmd stats pull-source [int] \n");
David Chen1481fe12017-10-16 13:16:34 -0700271 fprintf(out, "\n");
272 fprintf(out, " Prints the output of a pulled metrics source (int indicates source)\n");
273 fprintf(out, "\n");
274 fprintf(out, "\n");
yro947fbce2017-11-15 22:50:23 -0800275 fprintf(out, "usage: adb shell cmd stats write-to-disk \n");
276 fprintf(out, "\n");
277 fprintf(out, " Flushes all data on memory to disk.\n");
278 fprintf(out, "\n");
279 fprintf(out, "\n");
Bookatzb223c4e2018-02-01 15:35:04 -0800280 fprintf(out, "usage: adb shell cmd stats log-app-hook [UID] LABEL STATE\n");
281 fprintf(out, " Writes an AppHook event to the statslog buffer.\n");
282 fprintf(out, " UID The uid to use. It is only possible to pass a UID\n");
283 fprintf(out, " parameter on eng builds. If UID is omitted the calling\n");
284 fprintf(out, " uid is used.\n");
285 fprintf(out, " LABEL Integer in [0, 15], as per atoms.proto.\n");
286 fprintf(out, " STATE Integer in [0, 3], as per atoms.proto.\n");
287 fprintf(out, "\n");
288 fprintf(out, "\n");
yro74fed972017-11-27 14:42:42 -0800289 fprintf(out, "usage: adb shell cmd stats config remove [UID] [NAME]\n");
Joe Onorato9fc9edf2017-10-15 20:08:52 -0700290 fprintf(out, "usage: adb shell cmd stats config update [UID] NAME\n");
291 fprintf(out, "\n");
292 fprintf(out, " Adds, updates or removes a configuration. The proto should be in\n");
yro74fed972017-11-27 14:42:42 -0800293 fprintf(out, " wire-encoded protobuf format and passed via stdin. If no UID and name is\n");
294 fprintf(out, " provided, then all configs will be removed from memory and disk.\n");
Joe Onorato9fc9edf2017-10-15 20:08:52 -0700295 fprintf(out, "\n");
296 fprintf(out, " UID The uid to use. It is only possible to pass the UID\n");
yro74fed972017-11-27 14:42:42 -0800297 fprintf(out, " parameter on eng builds. If UID is omitted the calling\n");
Joe Onorato9fc9edf2017-10-15 20:08:52 -0700298 fprintf(out, " uid is used.\n");
299 fprintf(out, " NAME The per-uid name to use\n");
Yao Chen5154a372017-10-30 22:57:06 -0700300 fprintf(out, "\n");
yro74fed972017-11-27 14:42:42 -0800301 fprintf(out, "\n *Note: If both UID and NAME are omitted then all configs will\n");
302 fprintf(out, "\n be removed from memory and disk!\n");
Yao Chen5154a372017-10-30 22:57:06 -0700303 fprintf(out, "\n");
Chenjie Yub236c862017-11-28 22:20:44 -0800304 fprintf(out, "usage: adb shell cmd stats dump-report [UID] NAME [--proto]\n");
Yao Chen5154a372017-10-30 22:57:06 -0700305 fprintf(out, " Dump all metric data for a configuration.\n");
306 fprintf(out, " UID The uid of the configuration. It is only possible to pass\n");
307 fprintf(out, " the UID parameter on eng builds. If UID is omitted the\n");
308 fprintf(out, " calling uid is used.\n");
309 fprintf(out, " NAME The name of the configuration\n");
Chenjie Yub236c862017-11-28 22:20:44 -0800310 fprintf(out, " --proto Print proto binary.\n");
David Chenadaf8b32017-11-03 15:42:08 -0700311 fprintf(out, "\n");
312 fprintf(out, "\n");
David Chen1d7b0cd2017-11-15 14:20:04 -0800313 fprintf(out, "usage: adb shell cmd stats send-broadcast [UID] NAME\n");
314 fprintf(out, " Send a broadcast that triggers the subscriber to fetch metrics.\n");
315 fprintf(out, " UID The uid of the configuration. It is only possible to pass\n");
316 fprintf(out, " the UID parameter on eng builds. If UID is omitted the\n");
317 fprintf(out, " calling uid is used.\n");
318 fprintf(out, " NAME The name of the configuration\n");
319 fprintf(out, "\n");
320 fprintf(out, "\n");
Yao Chenf5acabe2018-01-17 14:10:34 -0800321 fprintf(out, "usage: adb shell cmd stats print-stats\n");
David Chen1d7b0cd2017-11-15 14:20:04 -0800322 fprintf(out, " Prints some basic stats.\n");
David Chenadaf8b32017-11-03 15:42:08 -0700323}
324
David Chen1d7b0cd2017-11-15 14:20:04 -0800325status_t StatsService::cmd_trigger_broadcast(FILE* out, Vector<String8>& args) {
326 string name;
327 bool good = false;
328 int uid;
329 const int argCount = args.size();
330 if (argCount == 2) {
331 // Automatically pick the UID
332 uid = IPCThreadState::self()->getCallingUid();
333 // TODO: What if this isn't a binder call? Should we fail?
334 name.assign(args[1].c_str(), args[1].size());
335 good = true;
336 } else if (argCount == 3) {
337 // If it's a userdebug or eng build, then the shell user can
338 // impersonate other uids.
339 if (mEngBuild) {
340 const char* s = args[1].c_str();
341 if (*s != '\0') {
342 char* end = NULL;
343 uid = strtol(s, &end, 0);
344 if (*end == '\0') {
345 name.assign(args[2].c_str(), args[2].size());
346 good = true;
347 }
348 }
349 } else {
350 fprintf(out,
351 "The metrics can only be dumped for other UIDs on eng or userdebug "
352 "builds.\n");
353 }
354 }
355 if (!good) {
356 print_cmd_help(out);
357 return UNKNOWN_ERROR;
358 }
Yangster-mac94e197c2018-01-02 16:03:03 -0800359 auto receiver = mConfigManager->GetConfigReceiver(ConfigKey(uid, StrToInt64(name)));
yro4d889e62017-11-17 15:44:48 -0800360 sp<IStatsCompanionService> sc = getStatsCompanionService();
361 if (sc != nullptr) {
362 sc->sendBroadcast(String16(receiver.first.c_str()), String16(receiver.second.c_str()));
yro74fed972017-11-27 14:42:42 -0800363 VLOG("StatsService::trigger broadcast succeeded to %s, %s", args[1].c_str(),
364 args[2].c_str());
yro4d889e62017-11-17 15:44:48 -0800365 } else {
yro74fed972017-11-27 14:42:42 -0800366 VLOG("Could not access statsCompanion");
yro4d889e62017-11-17 15:44:48 -0800367 }
368
David Chenadaf8b32017-11-03 15:42:08 -0700369 return NO_ERROR;
Joe Onorato9fc9edf2017-10-15 20:08:52 -0700370}
371
372status_t StatsService::cmd_config(FILE* in, FILE* out, FILE* err, Vector<String8>& args) {
373 const int argCount = args.size();
374 if (argCount >= 2) {
375 if (args[1] == "update" || args[1] == "remove") {
376 bool good = false;
377 int uid = -1;
378 string name;
379
380 if (argCount == 3) {
381 // Automatically pick the UID
382 uid = IPCThreadState::self()->getCallingUid();
383 // TODO: What if this isn't a binder call? Should we fail?
384 name.assign(args[2].c_str(), args[2].size());
385 good = true;
386 } else if (argCount == 4) {
387 // If it's a userdebug or eng build, then the shell user can
388 // impersonate other uids.
389 if (mEngBuild) {
390 const char* s = args[2].c_str();
391 if (*s != '\0') {
392 char* end = NULL;
393 uid = strtol(s, &end, 0);
394 if (*end == '\0') {
395 name.assign(args[3].c_str(), args[3].size());
396 good = true;
397 }
398 }
399 } else {
Yao Chen729093d2017-10-16 10:33:26 -0700400 fprintf(err,
401 "The config can only be set for other UIDs on eng or userdebug "
402 "builds.\n");
Joe Onorato9fc9edf2017-10-15 20:08:52 -0700403 }
yroe5f82922018-01-22 18:37:27 -0800404 } else if (argCount == 2 && args[1] == "remove") {
405 good = true;
Joe Onorato9fc9edf2017-10-15 20:08:52 -0700406 }
407
408 if (!good) {
409 // If arg parsing failed, print the help text and return an error.
410 print_cmd_help(out);
411 return UNKNOWN_ERROR;
412 }
413
414 if (args[1] == "update") {
415 // Read stream into buffer.
416 string buffer;
417 if (!android::base::ReadFdToString(fileno(in), &buffer)) {
418 fprintf(err, "Error reading stream for StatsConfig.\n");
419 return UNKNOWN_ERROR;
420 }
421
422 // Parse buffer.
423 StatsdConfig config;
424 if (!config.ParseFromString(buffer)) {
425 fprintf(err, "Error parsing proto stream for StatsConfig.\n");
426 return UNKNOWN_ERROR;
427 }
428
429 // Add / update the config.
Yangster-mac94e197c2018-01-02 16:03:03 -0800430 mConfigManager->UpdateConfig(ConfigKey(uid, StrToInt64(name)), config);
Joe Onorato9fc9edf2017-10-15 20:08:52 -0700431 } else {
yro74fed972017-11-27 14:42:42 -0800432 if (argCount == 2) {
433 cmd_remove_all_configs(out);
434 } else {
435 // Remove the config.
Yangster-mac94e197c2018-01-02 16:03:03 -0800436 mConfigManager->RemoveConfig(ConfigKey(uid, StrToInt64(name)));
yro74fed972017-11-27 14:42:42 -0800437 }
Joe Onorato9fc9edf2017-10-15 20:08:52 -0700438 }
439
440 return NO_ERROR;
441 }
David Chen0656b7a2017-09-13 15:53:39 -0700442 }
Joe Onorato9fc9edf2017-10-15 20:08:52 -0700443 print_cmd_help(out);
444 return UNKNOWN_ERROR;
445}
446
Yao Chen729093d2017-10-16 10:33:26 -0700447status_t StatsService::cmd_dump_report(FILE* out, FILE* err, const Vector<String8>& args) {
448 if (mProcessor != nullptr) {
Chenjie Yub236c862017-11-28 22:20:44 -0800449 int argCount = args.size();
Yao Chen729093d2017-10-16 10:33:26 -0700450 bool good = false;
Chenjie Yub236c862017-11-28 22:20:44 -0800451 bool proto = false;
Yao Chen729093d2017-10-16 10:33:26 -0700452 int uid;
453 string name;
Chenjie Yub236c862017-11-28 22:20:44 -0800454 if (!std::strcmp("--proto", args[argCount-1].c_str())) {
455 proto = true;
456 argCount -= 1;
457 }
Yao Chen729093d2017-10-16 10:33:26 -0700458 if (argCount == 2) {
459 // Automatically pick the UID
460 uid = IPCThreadState::self()->getCallingUid();
461 // TODO: What if this isn't a binder call? Should we fail?
Yao Chen5154a372017-10-30 22:57:06 -0700462 name.assign(args[1].c_str(), args[1].size());
Yao Chen729093d2017-10-16 10:33:26 -0700463 good = true;
464 } else if (argCount == 3) {
465 // If it's a userdebug or eng build, then the shell user can
466 // impersonate other uids.
467 if (mEngBuild) {
468 const char* s = args[1].c_str();
469 if (*s != '\0') {
470 char* end = NULL;
471 uid = strtol(s, &end, 0);
472 if (*end == '\0') {
473 name.assign(args[2].c_str(), args[2].size());
474 good = true;
475 }
476 }
477 } else {
478 fprintf(out,
479 "The metrics can only be dumped for other UIDs on eng or userdebug "
480 "builds.\n");
481 }
482 }
483 if (good) {
David Chen1d7b0cd2017-11-15 14:20:04 -0800484 vector<uint8_t> data;
Yangster-mac94e197c2018-01-02 16:03:03 -0800485 mProcessor->onDumpReport(ConfigKey(uid, StrToInt64(name)), &data);
Yao Chen729093d2017-10-16 10:33:26 -0700486 // TODO: print the returned StatsLogReport to file instead of printing to logcat.
Chenjie Yub236c862017-11-28 22:20:44 -0800487 if (proto) {
488 for (size_t i = 0; i < data.size(); i ++) {
489 fprintf(out, "%c", data[i]);
490 }
491 } else {
492 fprintf(out, "Dump report for Config [%d,%s]\n", uid, name.c_str());
493 fprintf(out, "See the StatsLogReport in logcat...\n");
494 }
Yao Chen729093d2017-10-16 10:33:26 -0700495 return android::OK;
496 } else {
497 // If arg parsing failed, print the help text and return an error.
498 print_cmd_help(out);
499 return UNKNOWN_ERROR;
500 }
501 } else {
502 fprintf(out, "Log processor does not exist...\n");
503 return UNKNOWN_ERROR;
504 }
505}
506
Yao Chenb3561512017-11-21 18:07:17 -0800507status_t StatsService::cmd_print_stats(FILE* out, const Vector<String8>& args) {
David Chen1d7b0cd2017-11-15 14:20:04 -0800508 vector<ConfigKey> configs = mConfigManager->GetAllConfigKeys();
509 for (const ConfigKey& key : configs) {
510 fprintf(out, "Config %s uses %zu bytes\n", key.ToString().c_str(),
511 mProcessor->GetMetricsSize(key));
512 }
Yao Chenb3561512017-11-21 18:07:17 -0800513 StatsdStats& statsdStats = StatsdStats::getInstance();
Yao Chenf5acabe2018-01-17 14:10:34 -0800514 statsdStats.dumpStats(out);
David Chen1d7b0cd2017-11-15 14:20:04 -0800515 return NO_ERROR;
516}
517
Yao Chend10f7b12017-12-18 12:53:50 -0800518status_t StatsService::cmd_print_uid_map(FILE* out, const Vector<String8>& args) {
519 if (args.size() > 1) {
520 string pkg;
521 pkg.assign(args[1].c_str(), args[1].size());
522 auto uids = mUidMap->getAppUid(pkg);
523 fprintf(out, "%s -> [ ", pkg.c_str());
524 for (const auto& uid : uids) {
525 fprintf(out, "%d ", uid);
526 }
527 fprintf(out, "]\n");
528 } else {
529 mUidMap->printUidMap(out);
530 }
Joe Onorato9fc9edf2017-10-15 20:08:52 -0700531 return NO_ERROR;
David Chen0656b7a2017-09-13 15:53:39 -0700532}
533
yro947fbce2017-11-15 22:50:23 -0800534status_t StatsService::cmd_write_data_to_disk(FILE* out) {
535 fprintf(out, "Writing data to disk\n");
536 mProcessor->WriteDataToDisk();
537 return NO_ERROR;
538}
539
Bookatzb223c4e2018-02-01 15:35:04 -0800540status_t StatsService::cmd_log_app_hook(FILE* out, const Vector<String8>& args) {
541 bool good = false;
542 int32_t uid;
543 int32_t label;
544 int32_t state;
545 const int argCount = args.size();
546 if (argCount == 3) {
547 // Automatically pick the UID
548 uid = IPCThreadState::self()->getCallingUid();
549 label = atoi(args[1].c_str());
550 state = atoi(args[2].c_str());
551 good = true;
552 } else if (argCount == 4) {
553 uid = atoi(args[1].c_str());
554 // If it's a userdebug or eng build, then the shell user can impersonate other uids.
555 // Otherwise, the uid must match the actual caller's uid.
556 if (mEngBuild || (uid >= 0 && (uid_t)uid == IPCThreadState::self()->getCallingUid())) {
557 label = atoi(args[2].c_str());
558 state = atoi(args[3].c_str());
559 good = true;
560 } else {
561 fprintf(out,
562 "Selecting a UID for writing AppHook can only be dumped for other UIDs on eng"
563 " or userdebug builds.\n");
564 }
565 }
566 if (good) {
567 fprintf(out, "Logging AppHook(%d, %d, %d) to statslog.\n", uid, label, state);
568 android::util::stats_write(android::util::APP_HOOK, uid, label, state);
569 } else {
570 print_cmd_help(out);
571 return UNKNOWN_ERROR;
572 }
573 return NO_ERROR;
574}
575
David Chen1481fe12017-10-16 13:16:34 -0700576status_t StatsService::cmd_print_pulled_metrics(FILE* out, const Vector<String8>& args) {
577 int s = atoi(args[1].c_str());
Chenjie Yu5305e1d2017-10-31 13:49:36 -0700578 vector<shared_ptr<LogEvent> > stats;
579 if (mStatsPullerManager.Pull(s, &stats)) {
580 for (const auto& it : stats) {
581 fprintf(out, "Pull from %d: %s\n", s, it->ToString().c_str());
582 }
583 fprintf(out, "Pull from %d: Received %zu elements\n", s, stats.size());
584 return NO_ERROR;
David Chen1481fe12017-10-16 13:16:34 -0700585 }
Chenjie Yu5305e1d2017-10-31 13:49:36 -0700586 return UNKNOWN_ERROR;
David Chen1481fe12017-10-16 13:16:34 -0700587}
588
yro74fed972017-11-27 14:42:42 -0800589status_t StatsService::cmd_remove_all_configs(FILE* out) {
590 fprintf(out, "Removing all configs...\n");
591 VLOG("StatsService::cmd_remove_all_configs was called");
592 mConfigManager->RemoveAllConfigs();
yro947fbce2017-11-15 22:50:23 -0800593 StorageManager::deleteAllFiles(STATS_SERVICE_DIR);
yro87d983c2017-11-14 21:31:43 -0800594 return NO_ERROR;
595}
596
Yao Chen8d9989b2017-11-18 18:54:50 -0800597status_t StatsService::cmd_dump_memory_info(FILE* out) {
598 std::string s = dumpMemInfo(100);
599 fprintf(out, "Memory Info\n");
600 fprintf(out, "%s", s.c_str());
601 return NO_ERROR;
602}
603
Chenjie Yue72252b2018-02-01 13:19:35 -0800604status_t StatsService::cmd_clear_puller_cache(FILE* out) {
605 mStatsPullerManager.ClearPullerCache();
606 fprintf(out, "Puller cached data removed!\n");
607 return NO_ERROR;
608}
609
Dianne Hackborn3accca02013-09-20 09:32:11 -0700610Status StatsService::informAllUidData(const vector<int32_t>& uid, const vector<int64_t>& version,
David Chende701692017-10-05 13:16:02 -0700611 const vector<String16>& app) {
yro74fed972017-11-27 14:42:42 -0800612 VLOG("StatsService::informAllUidData was called");
David Chende701692017-10-05 13:16:02 -0700613
614 if (IPCThreadState::self()->getCallingUid() != AID_SYSTEM) {
615 return Status::fromExceptionCode(Status::EX_SECURITY,
616 "Only system uid can call informAllUidData");
617 }
618
Joe Onorato9fc9edf2017-10-15 20:08:52 -0700619 mUidMap->updateMap(uid, version, app);
yro74fed972017-11-27 14:42:42 -0800620 VLOG("StatsService::informAllUidData succeeded");
David Chende701692017-10-05 13:16:02 -0700621
622 return Status::ok();
623}
624
Dianne Hackborn3accca02013-09-20 09:32:11 -0700625Status StatsService::informOnePackage(const String16& app, int32_t uid, int64_t version) {
yro74fed972017-11-27 14:42:42 -0800626 VLOG("StatsService::informOnePackage was called");
David Chende701692017-10-05 13:16:02 -0700627
628 if (IPCThreadState::self()->getCallingUid() != AID_SYSTEM) {
629 return Status::fromExceptionCode(Status::EX_SECURITY,
630 "Only system uid can call informOnePackage");
631 }
Joe Onorato9fc9edf2017-10-15 20:08:52 -0700632 mUidMap->updateApp(app, uid, version);
David Chende701692017-10-05 13:16:02 -0700633 return Status::ok();
634}
635
636Status StatsService::informOnePackageRemoved(const String16& app, int32_t uid) {
yro74fed972017-11-27 14:42:42 -0800637 VLOG("StatsService::informOnePackageRemoved was called");
David Chende701692017-10-05 13:16:02 -0700638
639 if (IPCThreadState::self()->getCallingUid() != AID_SYSTEM) {
640 return Status::fromExceptionCode(Status::EX_SECURITY,
641 "Only system uid can call informOnePackageRemoved");
642 }
Joe Onorato9fc9edf2017-10-15 20:08:52 -0700643 mUidMap->removeApp(app, uid);
David Chende701692017-10-05 13:16:02 -0700644 return Status::ok();
645}
646
Yao Chenef99c4f2017-09-22 16:26:54 -0700647Status StatsService::informAnomalyAlarmFired() {
yro74fed972017-11-27 14:42:42 -0800648 VLOG("StatsService::informAnomalyAlarmFired was called");
Bookatz1b0b1142017-09-08 11:58:42 -0700649
650 if (IPCThreadState::self()->getCallingUid() != AID_SYSTEM) {
651 return Status::fromExceptionCode(Status::EX_SECURITY,
Yao Chenef99c4f2017-09-22 16:26:54 -0700652 "Only system uid can call informAnomalyAlarmFired");
Bookatz1b0b1142017-09-08 11:58:42 -0700653 }
654
yro74fed972017-11-27 14:42:42 -0800655 VLOG("StatsService::informAnomalyAlarmFired succeeded");
Bookatzcc5adef2017-11-21 14:36:23 -0800656 uint64_t currentTimeSec = time(nullptr);
Yangster-mace2cd6d52017-11-09 20:38:30 -0800657 std::unordered_set<sp<const AnomalyAlarm>, SpHash<AnomalyAlarm>> anomalySet =
Bookatzcc5adef2017-11-21 14:36:23 -0800658 mAnomalyMonitor->popSoonerThan(static_cast<uint32_t>(currentTimeSec));
659 mProcessor->onAnomalyAlarmFired(currentTimeSec * NS_PER_SEC, anomalySet);
Bookatz1b0b1142017-09-08 11:58:42 -0700660 return Status::ok();
661}
662
Yao Chenef99c4f2017-09-22 16:26:54 -0700663Status StatsService::informPollAlarmFired() {
yro74fed972017-11-27 14:42:42 -0800664 VLOG("StatsService::informPollAlarmFired was called");
Bookatz1b0b1142017-09-08 11:58:42 -0700665
666 if (IPCThreadState::self()->getCallingUid() != AID_SYSTEM) {
667 return Status::fromExceptionCode(Status::EX_SECURITY,
Yao Chenef99c4f2017-09-22 16:26:54 -0700668 "Only system uid can call informPollAlarmFired");
Bookatz1b0b1142017-09-08 11:58:42 -0700669 }
670
Chenjie Yu5305e1d2017-10-31 13:49:36 -0700671 mStatsPullerManager.OnAlarmFired();
Chenjie Yub3dda412017-10-24 13:41:59 -0700672
yro74fed972017-11-27 14:42:42 -0800673 VLOG("StatsService::informPollAlarmFired succeeded");
Bookatz1b0b1142017-09-08 11:58:42 -0700674
675 return Status::ok();
676}
677
Yao Chenef99c4f2017-09-22 16:26:54 -0700678Status StatsService::systemRunning() {
Joe Onorato5dcbc6c2017-08-29 15:13:58 -0700679 if (IPCThreadState::self()->getCallingUid() != AID_SYSTEM) {
680 return Status::fromExceptionCode(Status::EX_SECURITY,
Yao Chenef99c4f2017-09-22 16:26:54 -0700681 "Only system uid can call systemRunning");
Joe Onorato5dcbc6c2017-08-29 15:13:58 -0700682 }
683
684 // When system_server is up and running, schedule the dropbox task to run.
yro74fed972017-11-27 14:42:42 -0800685 VLOG("StatsService::systemRunning");
Joe Onorato5dcbc6c2017-08-29 15:13:58 -0700686
Bookatzb487b552017-09-18 11:26:01 -0700687 sayHiToStatsCompanion();
688
Joe Onorato5dcbc6c2017-08-29 15:13:58 -0700689 return Status::ok();
690}
691
yro947fbce2017-11-15 22:50:23 -0800692Status StatsService::writeDataToDisk() {
693 if (IPCThreadState::self()->getCallingUid() != AID_SYSTEM) {
694 return Status::fromExceptionCode(Status::EX_SECURITY,
695 "Only system uid can call systemRunning");
696 }
697
yro74fed972017-11-27 14:42:42 -0800698 VLOG("StatsService::writeDataToDisk");
yro947fbce2017-11-15 22:50:23 -0800699
700 mProcessor->WriteDataToDisk();
701
702 return Status::ok();
703}
704
Yao Chenef99c4f2017-09-22 16:26:54 -0700705void StatsService::sayHiToStatsCompanion() {
706 // TODO: This method needs to be private. It is temporarily public and unsecured for testing
707 // purposes.
Bookatzb487b552017-09-18 11:26:01 -0700708 sp<IStatsCompanionService> statsCompanion = getStatsCompanionService();
709 if (statsCompanion != nullptr) {
yro74fed972017-11-27 14:42:42 -0800710 VLOG("Telling statsCompanion that statsd is ready");
Bookatzb487b552017-09-18 11:26:01 -0700711 statsCompanion->statsdReady();
712 } else {
yro74fed972017-11-27 14:42:42 -0800713 VLOG("Could not access statsCompanion");
Bookatzb487b552017-09-18 11:26:01 -0700714 }
715}
716
Yao Chenef99c4f2017-09-22 16:26:54 -0700717sp<IStatsCompanionService> StatsService::getStatsCompanionService() {
Bookatz906a35c2017-09-20 15:26:44 -0700718 sp<IStatsCompanionService> statsCompanion = nullptr;
719 // Get statscompanion service from service manager
720 const sp<IServiceManager> sm(defaultServiceManager());
721 if (sm != nullptr) {
722 const String16 name("statscompanion");
723 statsCompanion = interface_cast<IStatsCompanionService>(sm->checkService(name));
724 if (statsCompanion == nullptr) {
725 ALOGW("statscompanion service unavailable!");
726 return nullptr;
727 }
728 }
729 return statsCompanion;
730}
731
Yao Chenef99c4f2017-09-22 16:26:54 -0700732Status StatsService::statsCompanionReady() {
yro74fed972017-11-27 14:42:42 -0800733 VLOG("StatsService::statsCompanionReady was called");
Bookatzb487b552017-09-18 11:26:01 -0700734
735 if (IPCThreadState::self()->getCallingUid() != AID_SYSTEM) {
736 return Status::fromExceptionCode(Status::EX_SECURITY,
737 "Only system uid can call statsCompanionReady");
738 }
739
740 sp<IStatsCompanionService> statsCompanion = getStatsCompanionService();
741 if (statsCompanion == nullptr) {
Yao Chenef99c4f2017-09-22 16:26:54 -0700742 return Status::fromExceptionCode(
743 Status::EX_NULL_POINTER,
744 "statscompanion unavailable despite it contacting statsd!");
Bookatzb487b552017-09-18 11:26:01 -0700745 }
yro74fed972017-11-27 14:42:42 -0800746 VLOG("StatsService::statsCompanionReady linking to statsCompanion.");
Joe Onorato9fc9edf2017-10-15 20:08:52 -0700747 IInterface::asBinder(statsCompanion)->linkToDeath(new CompanionDeathRecipient(mAnomalyMonitor));
Bookatzb487b552017-09-18 11:26:01 -0700748 mAnomalyMonitor->setStatsCompanionService(statsCompanion);
Bookatzc6977972018-01-16 16:55:05 -0800749 SubscriberReporter::getInstance().setStatsCompanionService(statsCompanion);
Bookatzb487b552017-09-18 11:26:01 -0700750
751 return Status::ok();
752}
753
Joe Onorato9fc9edf2017-10-15 20:08:52 -0700754void StatsService::Startup() {
755 mConfigManager->Startup();
Bookatz906a35c2017-09-20 15:26:44 -0700756}
757
Yangster-macd40053e2018-01-09 16:29:22 -0800758void StatsService::OnLogEvent(LogEvent* event) {
Joe Onoratoc4dfae52017-10-17 23:38:21 -0700759 mProcessor->OnLogEvent(event);
Bookatz906a35c2017-09-20 15:26:44 -0700760}
761
Yangster-mac94e197c2018-01-02 16:03:03 -0800762Status StatsService::getData(int64_t key, vector<uint8_t>* output) {
David Chenadaf8b32017-11-03 15:42:08 -0700763 IPCThreadState* ipc = IPCThreadState::self();
yro74fed972017-11-27 14:42:42 -0800764 VLOG("StatsService::getData with Pid %i, Uid %i", ipc->getCallingPid(), ipc->getCallingUid());
Yao Chen7ee94152017-11-17 09:44:40 -0800765 if (checkCallingPermission(String16(kPermissionDump))) {
Yangster-mac94e197c2018-01-02 16:03:03 -0800766 ConfigKey configKey(ipc->getCallingUid(), key);
David Chen1d7b0cd2017-11-15 14:20:04 -0800767 mProcessor->onDumpReport(configKey, output);
David Chenadaf8b32017-11-03 15:42:08 -0700768 return Status::ok();
769 } else {
770 return Status::fromExceptionCode(binder::Status::EX_SECURITY);
771 }
yro31eb67b2017-10-24 13:33:21 -0700772}
773
David Chen2e8f3802017-11-22 10:56:48 -0800774Status StatsService::getMetadata(vector<uint8_t>* output) {
775 IPCThreadState* ipc = IPCThreadState::self();
776 VLOG("StatsService::getMetadata with Pid %i, Uid %i", ipc->getCallingPid(),
777 ipc->getCallingUid());
778 if (checkCallingPermission(String16(kPermissionDump))) {
779 StatsdStats::getInstance().dumpStats(output, false); // Don't reset the counters.
780 return Status::ok();
781 } else {
782 return Status::fromExceptionCode(binder::Status::EX_SECURITY);
783 }
784}
785
Yangster-mac94e197c2018-01-02 16:03:03 -0800786Status StatsService::addConfiguration(int64_t key,
David Chenadaf8b32017-11-03 15:42:08 -0700787 const vector <uint8_t>& config,
788 const String16& package, const String16& cls,
789 bool* success) {
790 IPCThreadState* ipc = IPCThreadState::self();
Yao Chen7ee94152017-11-17 09:44:40 -0800791 if (checkCallingPermission(String16(kPermissionDump))) {
Yangster-mac94e197c2018-01-02 16:03:03 -0800792 ConfigKey configKey(ipc->getCallingUid(), key);
David Chenadaf8b32017-11-03 15:42:08 -0700793 StatsdConfig cfg;
Yangster-macbbd056a2018-01-22 13:37:02 -0800794 if (config.empty() || !cfg.ParseFromArray(&config[0], config.size())) {
David Chen7d8aa4d2017-12-27 13:37:01 -0800795 *success = false;
796 return Status::ok();
797 }
David Chenadaf8b32017-11-03 15:42:08 -0700798 mConfigManager->UpdateConfig(configKey, cfg);
799 mConfigManager->SetConfigReceiver(configKey, string(String8(package).string()),
800 string(String8(cls).string()));
801 *success = true;
802 return Status::ok();
803 } else {
Yao Chenaa39bc72017-12-01 11:16:50 -0800804 *success = false;
David Chenadaf8b32017-11-03 15:42:08 -0700805 return Status::fromExceptionCode(binder::Status::EX_SECURITY);
yro31eb67b2017-10-24 13:33:21 -0700806 }
yro31eb67b2017-10-24 13:33:21 -0700807}
808
Yangster-mac94e197c2018-01-02 16:03:03 -0800809Status StatsService::removeConfiguration(int64_t key, bool* success) {
David Chenadaf8b32017-11-03 15:42:08 -0700810 IPCThreadState* ipc = IPCThreadState::self();
Yao Chen7ee94152017-11-17 09:44:40 -0800811 if (checkCallingPermission(String16(kPermissionDump))) {
Bookatzc6977972018-01-16 16:55:05 -0800812 ConfigKey configKey(ipc->getCallingUid(), key);
813 mConfigManager->RemoveConfig(configKey);
814 SubscriberReporter::getInstance().removeConfig(configKey);
Yao Chenaa39bc72017-12-01 11:16:50 -0800815 *success = true;
David Chenadaf8b32017-11-03 15:42:08 -0700816 return Status::ok();
817 } else {
818 *success = false;
819 return Status::fromExceptionCode(binder::Status::EX_SECURITY);
yro31eb67b2017-10-24 13:33:21 -0700820 }
yro31eb67b2017-10-24 13:33:21 -0700821}
822
Bookatzc6977972018-01-16 16:55:05 -0800823Status StatsService::setBroadcastSubscriber(int64_t configId,
824 int64_t subscriberId,
825 const sp<android::IBinder>& intentSender,
826 bool* success) {
827 VLOG("StatsService::setBroadcastSubscriber called.");
828 IPCThreadState* ipc = IPCThreadState::self();
829 if (checkCallingPermission(String16(kPermissionDump))) {
830 ConfigKey configKey(ipc->getCallingUid(), configId);
831 SubscriberReporter::getInstance()
832 .setBroadcastSubscriber(configKey, subscriberId, intentSender);
833 *success = true;
834 return Status::ok();
835 } else {
836 *success = false;
837 return Status::fromExceptionCode(binder::Status::EX_SECURITY);
838 }
839}
840
841Status StatsService::unsetBroadcastSubscriber(int64_t configId,
842 int64_t subscriberId,
843 bool* success) {
844 VLOG("StatsService::unsetBroadcastSubscriber called.");
845 IPCThreadState* ipc = IPCThreadState::self();
846 if (checkCallingPermission(String16(kPermissionDump))) {
847 ConfigKey configKey(ipc->getCallingUid(), configId);
848 SubscriberReporter::getInstance()
849 .unsetBroadcastSubscriber(configKey, subscriberId);
850 *success = true;
851 return Status::ok();
852 } else {
853 *success = false;
854 return Status::fromExceptionCode(binder::Status::EX_SECURITY);
855 }
856}
857
858
David Chen1d7b0cd2017-11-15 14:20:04 -0800859void StatsService::binderDied(const wp <IBinder>& who) {
yro31eb67b2017-10-24 13:33:21 -0700860}
861
Yao Chenef99c4f2017-09-22 16:26:54 -0700862} // namespace statsd
863} // namespace os
864} // namespace android