Joe Onorato | 5dcbc6c | 2017-08-29 15:13:58 -0700 | [diff] [blame] | 1 | /* |
yro | 0feae94 | 2017-11-15 14:38:48 -0800 | [diff] [blame] | 2 | * Copyright (C) 2017 The Android Open Source Project |
Joe Onorato | 5dcbc6c | 2017-08-29 15:13:58 -0700 | [diff] [blame] | 3 | * |
| 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 | |
Tej Singh | 484524a | 2018-02-01 15:10:05 -0800 | [diff] [blame] | 17 | #define DEBUG false // STOPSHIP if true |
Joe Onorato | 9fc9edf | 2017-10-15 20:08:52 -0700 | [diff] [blame] | 18 | #include "Log.h" |
Joe Onorato | 5dcbc6c | 2017-08-29 15:13:58 -0700 | [diff] [blame] | 19 | |
| 20 | #include "StatsService.h" |
Yangster-mac | 330af58 | 2018-02-08 15:24:38 -0800 | [diff] [blame] | 21 | #include "stats_log_util.h" |
Yao Chen | 8d9989b | 2017-11-18 18:54:50 -0800 | [diff] [blame] | 22 | #include "android-base/stringprintf.h" |
David Chen | adaf8b3 | 2017-11-03 15:42:08 -0700 | [diff] [blame] | 23 | #include "config/ConfigKey.h" |
| 24 | #include "config/ConfigManager.h" |
Yao Chen | b356151 | 2017-11-21 18:07:17 -0800 | [diff] [blame] | 25 | #include "guardrail/StatsdStats.h" |
yro | 947fbce | 2017-11-15 22:50:23 -0800 | [diff] [blame] | 26 | #include "storage/StorageManager.h" |
Bookatz | c697797 | 2018-01-16 16:55:05 -0800 | [diff] [blame] | 27 | #include "subscriber/SubscriberReporter.h" |
Joe Onorato | 5dcbc6c | 2017-08-29 15:13:58 -0700 | [diff] [blame] | 28 | |
David Chen | 0656b7a | 2017-09-13 15:53:39 -0700 | [diff] [blame] | 29 | #include <android-base/file.h> |
Jeff Sharkey | 6b64925 | 2018-04-16 09:50:22 -0600 | [diff] [blame] | 30 | #include <android-base/stringprintf.h> |
Joe Onorato | 5dcbc6c | 2017-08-29 15:13:58 -0700 | [diff] [blame] | 31 | #include <binder/IPCThreadState.h> |
| 32 | #include <binder/IServiceManager.h> |
Jeff Sharkey | 6b64925 | 2018-04-16 09:50:22 -0600 | [diff] [blame] | 33 | #include <binder/PermissionController.h> |
yro | 87d983c | 2017-11-14 21:31:43 -0800 | [diff] [blame] | 34 | #include <dirent.h> |
David Chen | 0656b7a | 2017-09-13 15:53:39 -0700 | [diff] [blame] | 35 | #include <frameworks/base/cmds/statsd/src/statsd_config.pb.h> |
Joe Onorato | 5dcbc6c | 2017-08-29 15:13:58 -0700 | [diff] [blame] | 36 | #include <private/android_filesystem_config.h> |
Bookatz | b223c4e | 2018-02-01 15:35:04 -0800 | [diff] [blame] | 37 | #include <statslog.h> |
Joe Onorato | 5dcbc6c | 2017-08-29 15:13:58 -0700 | [diff] [blame] | 38 | #include <stdio.h> |
Yao Chen | 482d272 | 2017-09-12 13:25:43 -0700 | [diff] [blame] | 39 | #include <stdlib.h> |
Joe Onorato | 9fc9edf | 2017-10-15 20:08:52 -0700 | [diff] [blame] | 40 | #include <sys/system_properties.h> |
Yao Chen | ef99c4f | 2017-09-22 16:26:54 -0700 | [diff] [blame] | 41 | #include <unistd.h> |
Yao Chen | a80e5c0 | 2018-09-04 13:55:29 -0700 | [diff] [blame] | 42 | #include <utils/Looper.h> |
| 43 | #include <utils/String16.h> |
| 44 | #include <chrono> |
Joe Onorato | 5dcbc6c | 2017-08-29 15:13:58 -0700 | [diff] [blame] | 45 | |
| 46 | using namespace android; |
| 47 | |
Jeff Sharkey | 6b64925 | 2018-04-16 09:50:22 -0600 | [diff] [blame] | 48 | using android::base::StringPrintf; |
Bookatz | ff71cad | 2018-09-20 17:17:49 -0700 | [diff] [blame] | 49 | using android::util::FIELD_COUNT_REPEATED; |
| 50 | using android::util::FIELD_TYPE_MESSAGE; |
Jeff Sharkey | 6b64925 | 2018-04-16 09:50:22 -0600 | [diff] [blame] | 51 | |
Bookatz | 906a35c | 2017-09-20 15:26:44 -0700 | [diff] [blame] | 52 | namespace android { |
| 53 | namespace os { |
| 54 | namespace statsd { |
| 55 | |
David Chen | adaf8b3 | 2017-11-03 15:42:08 -0700 | [diff] [blame] | 56 | constexpr const char* kPermissionDump = "android.permission.DUMP"; |
Jeff Sharkey | 6b64925 | 2018-04-16 09:50:22 -0600 | [diff] [blame] | 57 | constexpr const char* kPermissionUsage = "android.permission.PACKAGE_USAGE_STATS"; |
| 58 | |
| 59 | constexpr const char* kOpUsage = "android:get_usage_stats"; |
| 60 | |
yro | 03faf09 | 2017-12-12 00:17:50 -0800 | [diff] [blame] | 61 | #define STATS_SERVICE_DIR "/data/misc/stats-service" |
David Chen | adaf8b3 | 2017-11-03 15:42:08 -0700 | [diff] [blame] | 62 | |
Bookatz | ff71cad | 2018-09-20 17:17:49 -0700 | [diff] [blame] | 63 | // for StatsDataDumpProto |
| 64 | const int FIELD_ID_REPORTS_LIST = 1; |
| 65 | |
Jeff Sharkey | 6b64925 | 2018-04-16 09:50:22 -0600 | [diff] [blame] | 66 | static binder::Status ok() { |
| 67 | return binder::Status::ok(); |
| 68 | } |
| 69 | |
| 70 | static binder::Status exception(uint32_t code, const std::string& msg) { |
| 71 | ALOGE("%s (%d)", msg.c_str(), code); |
| 72 | return binder::Status::fromExceptionCode(code, String8(msg.c_str())); |
| 73 | } |
| 74 | |
| 75 | binder::Status checkUid(uid_t expectedUid) { |
| 76 | uid_t uid = IPCThreadState::self()->getCallingUid(); |
| 77 | if (uid == expectedUid || uid == AID_ROOT) { |
| 78 | return ok(); |
| 79 | } else { |
| 80 | return exception(binder::Status::EX_SECURITY, |
| 81 | StringPrintf("UID %d is not expected UID %d", uid, expectedUid)); |
| 82 | } |
| 83 | } |
| 84 | |
| 85 | binder::Status checkDumpAndUsageStats(const String16& packageName) { |
| 86 | pid_t pid = IPCThreadState::self()->getCallingPid(); |
| 87 | uid_t uid = IPCThreadState::self()->getCallingUid(); |
| 88 | |
| 89 | // Root, system, and shell always have access |
| 90 | if (uid == AID_ROOT || uid == AID_SYSTEM || uid == AID_SHELL) { |
| 91 | return ok(); |
| 92 | } |
| 93 | |
| 94 | // Caller must be granted these permissions |
| 95 | if (!checkCallingPermission(String16(kPermissionDump))) { |
| 96 | return exception(binder::Status::EX_SECURITY, |
| 97 | StringPrintf("UID %d / PID %d lacks permission %s", uid, pid, kPermissionDump)); |
| 98 | } |
| 99 | if (!checkCallingPermission(String16(kPermissionUsage))) { |
| 100 | return exception(binder::Status::EX_SECURITY, |
| 101 | StringPrintf("UID %d / PID %d lacks permission %s", uid, pid, kPermissionUsage)); |
| 102 | } |
| 103 | |
| 104 | // Caller must also have usage stats op granted |
| 105 | PermissionController pc; |
| 106 | switch (pc.noteOp(String16(kOpUsage), uid, packageName)) { |
| 107 | case PermissionController::MODE_ALLOWED: |
| 108 | case PermissionController::MODE_DEFAULT: |
| 109 | return ok(); |
| 110 | default: |
| 111 | return exception(binder::Status::EX_SECURITY, |
| 112 | StringPrintf("UID %d / PID %d lacks app-op %s", uid, pid, kOpUsage)); |
| 113 | } |
| 114 | } |
| 115 | |
| 116 | #define ENFORCE_UID(uid) { \ |
| 117 | binder::Status status = checkUid((uid)); \ |
| 118 | if (!status.isOk()) { \ |
| 119 | return status; \ |
| 120 | } \ |
| 121 | } |
| 122 | |
| 123 | #define ENFORCE_DUMP_AND_USAGE_STATS(packageName) { \ |
| 124 | binder::Status status = checkDumpAndUsageStats(packageName); \ |
| 125 | if (!status.isOk()) { \ |
| 126 | return status; \ |
| 127 | } \ |
| 128 | } |
| 129 | |
Joe Onorato | 5dcbc6c | 2017-08-29 15:13:58 -0700 | [diff] [blame] | 130 | StatsService::StatsService(const sp<Looper>& handlerLooper) |
Yangster-mac | 932ecec | 2018-02-01 10:23:52 -0800 | [diff] [blame] | 131 | : mAnomalyAlarmMonitor(new AlarmMonitor(MIN_DIFF_TO_UPDATE_REGISTERED_ALARM_SECS, |
| 132 | [](const sp<IStatsCompanionService>& sc, int64_t timeMillis) { |
| 133 | if (sc != nullptr) { |
| 134 | sc->setAnomalyAlarm(timeMillis); |
| 135 | StatsdStats::getInstance().noteRegisteredAnomalyAlarmChanged(); |
| 136 | } |
| 137 | }, |
| 138 | [](const sp<IStatsCompanionService>& sc) { |
| 139 | if (sc != nullptr) { |
| 140 | sc->cancelAnomalyAlarm(); |
| 141 | StatsdStats::getInstance().noteRegisteredAnomalyAlarmChanged(); |
| 142 | } |
| 143 | })), |
| 144 | mPeriodicAlarmMonitor(new AlarmMonitor(MIN_DIFF_TO_UPDATE_REGISTERED_ALARM_SECS, |
| 145 | [](const sp<IStatsCompanionService>& sc, int64_t timeMillis) { |
| 146 | if (sc != nullptr) { |
| 147 | sc->setAlarmForSubscriberTriggering(timeMillis); |
| 148 | StatsdStats::getInstance().noteRegisteredPeriodicAlarmChanged(); |
| 149 | } |
| 150 | }, |
| 151 | [](const sp<IStatsCompanionService>& sc) { |
| 152 | if (sc != nullptr) { |
| 153 | sc->cancelAlarmForSubscriberTriggering(); |
| 154 | StatsdStats::getInstance().noteRegisteredPeriodicAlarmChanged(); |
| 155 | } |
| 156 | |
| 157 | })) { |
Joe Onorato | 9fc9edf | 2017-10-15 20:08:52 -0700 | [diff] [blame] | 158 | mUidMap = new UidMap(); |
Chenjie Yu | e221920 | 2018-06-08 10:07:51 -0700 | [diff] [blame] | 159 | mPullerManager = new StatsPullerManager(); |
Chenjie Yu | 80f9112 | 2018-01-31 20:24:50 -0800 | [diff] [blame] | 160 | StatsPuller::SetUidMap(mUidMap); |
Joe Onorato | 9fc9edf | 2017-10-15 20:08:52 -0700 | [diff] [blame] | 161 | mConfigManager = new ConfigManager(); |
Chenjie Yu | e221920 | 2018-06-08 10:07:51 -0700 | [diff] [blame] | 162 | mProcessor = new StatsLogProcessor( |
| 163 | mUidMap, mPullerManager, mAnomalyAlarmMonitor, mPeriodicAlarmMonitor, |
Chenjie Yu | c7939cb | 2019-02-04 17:25:45 -0800 | [diff] [blame^] | 164 | getElapsedRealtimeNs(), |
| 165 | [this](const ConfigKey& key) { |
Chenjie Yu | e221920 | 2018-06-08 10:07:51 -0700 | [diff] [blame] | 166 | sp<IStatsCompanionService> sc = getStatsCompanionService(); |
| 167 | auto receiver = mConfigManager->GetConfigReceiver(key); |
| 168 | if (sc == nullptr) { |
| 169 | VLOG("Could not find StatsCompanionService"); |
| 170 | return false; |
| 171 | } else if (receiver == nullptr) { |
| 172 | VLOG("Statscompanion could not find a broadcast receiver for %s", |
| 173 | key.ToString().c_str()); |
| 174 | return false; |
| 175 | } else { |
| 176 | sc->sendDataBroadcast(receiver, mProcessor->getLastReportTimeNs(key)); |
| 177 | return true; |
| 178 | } |
| 179 | }); |
Joe Onorato | 9fc9edf | 2017-10-15 20:08:52 -0700 | [diff] [blame] | 180 | |
| 181 | mConfigManager->AddListener(mProcessor); |
| 182 | |
| 183 | init_system_properties(); |
Joe Onorato | 5dcbc6c | 2017-08-29 15:13:58 -0700 | [diff] [blame] | 184 | } |
| 185 | |
Yao Chen | ef99c4f | 2017-09-22 16:26:54 -0700 | [diff] [blame] | 186 | StatsService::~StatsService() { |
Joe Onorato | 5dcbc6c | 2017-08-29 15:13:58 -0700 | [diff] [blame] | 187 | } |
| 188 | |
Joe Onorato | 9fc9edf | 2017-10-15 20:08:52 -0700 | [diff] [blame] | 189 | void StatsService::init_system_properties() { |
| 190 | mEngBuild = false; |
| 191 | const prop_info* buildType = __system_property_find("ro.build.type"); |
| 192 | if (buildType != NULL) { |
| 193 | __system_property_read_callback(buildType, init_build_type_callback, this); |
| 194 | } |
David Chen | 0656b7a | 2017-09-13 15:53:39 -0700 | [diff] [blame] | 195 | } |
| 196 | |
Joe Onorato | 9fc9edf | 2017-10-15 20:08:52 -0700 | [diff] [blame] | 197 | void StatsService::init_build_type_callback(void* cookie, const char* /*name*/, const char* value, |
| 198 | uint32_t serial) { |
Yao Chen | 729093d | 2017-10-16 10:33:26 -0700 | [diff] [blame] | 199 | if (0 == strcmp("eng", value) || 0 == strcmp("userdebug", value)) { |
Joe Onorato | 9fc9edf | 2017-10-15 20:08:52 -0700 | [diff] [blame] | 200 | reinterpret_cast<StatsService*>(cookie)->mEngBuild = true; |
| 201 | } |
| 202 | } |
| 203 | |
| 204 | /** |
| 205 | * Implement our own because the default binder implementation isn't |
| 206 | * properly handling SHELL_COMMAND_TRANSACTION. |
| 207 | */ |
Yao Chen | ef99c4f | 2017-09-22 16:26:54 -0700 | [diff] [blame] | 208 | status_t StatsService::onTransact(uint32_t code, const Parcel& data, Parcel* reply, |
| 209 | uint32_t flags) { |
Joe Onorato | 2cbc2cc | 2017-08-30 17:03:23 -0700 | [diff] [blame] | 210 | switch (code) { |
| 211 | case SHELL_COMMAND_TRANSACTION: { |
| 212 | int in = data.readFileDescriptor(); |
| 213 | int out = data.readFileDescriptor(); |
| 214 | int err = data.readFileDescriptor(); |
| 215 | int argc = data.readInt32(); |
| 216 | Vector<String8> args; |
| 217 | for (int i = 0; i < argc && data.dataAvail() > 0; i++) { |
| 218 | args.add(String8(data.readString16())); |
| 219 | } |
Yao Chen | ef99c4f | 2017-09-22 16:26:54 -0700 | [diff] [blame] | 220 | sp<IShellCallback> shellCallback = IShellCallback::asInterface(data.readStrongBinder()); |
| 221 | sp<IResultReceiver> resultReceiver = |
| 222 | IResultReceiver::asInterface(data.readStrongBinder()); |
Joe Onorato | 2cbc2cc | 2017-08-30 17:03:23 -0700 | [diff] [blame] | 223 | |
Yao Chen | a80e5c0 | 2018-09-04 13:55:29 -0700 | [diff] [blame] | 224 | err = command(in, out, err, args, resultReceiver); |
| 225 | resultReceiver->send(err); |
Joe Onorato | 2cbc2cc | 2017-08-30 17:03:23 -0700 | [diff] [blame] | 226 | return NO_ERROR; |
| 227 | } |
Yao Chen | ef99c4f | 2017-09-22 16:26:54 -0700 | [diff] [blame] | 228 | default: { return BnStatsManager::onTransact(code, data, reply, flags); } |
Joe Onorato | 2cbc2cc | 2017-08-30 17:03:23 -0700 | [diff] [blame] | 229 | } |
| 230 | } |
| 231 | |
Joe Onorato | 9fc9edf | 2017-10-15 20:08:52 -0700 | [diff] [blame] | 232 | /** |
Bookatz | ff71cad | 2018-09-20 17:17:49 -0700 | [diff] [blame] | 233 | * Write data from statsd. |
| 234 | * Format for statsdStats: adb shell dumpsys stats --metadata [-v] [--proto] |
| 235 | * Format for data report: adb shell dumpsys stats [anything other than --metadata] [--proto] |
| 236 | * Anything ending in --proto will be in proto format. |
| 237 | * Anything without --metadata as the first argument will be report information. |
| 238 | * (bugreports call "adb shell dumpsys stats --dump-priority NORMAL -a --proto") |
| 239 | * TODO: Come up with a more robust method of enacting <serviceutils/PriorityDumper.h>. |
Joe Onorato | 9fc9edf | 2017-10-15 20:08:52 -0700 | [diff] [blame] | 240 | */ |
Yao Chen | ef99c4f | 2017-09-22 16:26:54 -0700 | [diff] [blame] | 241 | status_t StatsService::dump(int fd, const Vector<String16>& args) { |
Tej Singh | dd83d70 | 2018-04-10 17:24:50 -0700 | [diff] [blame] | 242 | if (!checkCallingPermission(String16(kPermissionDump))) { |
| 243 | return PERMISSION_DENIED; |
| 244 | } |
Bookatz | ff71cad | 2018-09-20 17:17:49 -0700 | [diff] [blame] | 245 | int lastArg = args.size() - 1; |
| 246 | bool asProto = false; |
| 247 | if (lastArg >= 0 && !args[lastArg].compare(String16("--proto"))) { // last argument |
| 248 | asProto = true; |
| 249 | lastArg--; |
Yao Chen | 884c8c1 | 2018-01-26 10:36:25 -0800 | [diff] [blame] | 250 | } |
Bookatz | ff71cad | 2018-09-20 17:17:49 -0700 | [diff] [blame] | 251 | if (args.size() > 0 && !args[0].compare(String16("--metadata"))) { // first argument |
| 252 | // Request is to dump statsd stats. |
| 253 | bool verbose = false; |
| 254 | if (lastArg >= 0 && !args[lastArg].compare(String16("-v"))) { |
| 255 | verbose = true; |
| 256 | lastArg--; |
| 257 | } |
| 258 | dumpStatsdStats(fd, verbose, asProto); |
| 259 | } else { |
| 260 | // Request is to dump statsd report data. |
| 261 | if (asProto) { |
| 262 | dumpIncidentSection(fd); |
| 263 | } else { |
| 264 | dprintf(fd, "Non-proto format of stats data dump not available; see proto version.\n"); |
| 265 | } |
Tej Singh | 41b3f9a | 2018-04-03 17:06:35 -0700 | [diff] [blame] | 266 | } |
Yao Chen | 884c8c1 | 2018-01-26 10:36:25 -0800 | [diff] [blame] | 267 | |
Joe Onorato | 5dcbc6c | 2017-08-29 15:13:58 -0700 | [diff] [blame] | 268 | return NO_ERROR; |
| 269 | } |
| 270 | |
Joe Onorato | 9fc9edf | 2017-10-15 20:08:52 -0700 | [diff] [blame] | 271 | /** |
Tej Singh | 41b3f9a | 2018-04-03 17:06:35 -0700 | [diff] [blame] | 272 | * Write debugging data about statsd in text or proto format. |
Joe Onorato | 9fc9edf | 2017-10-15 20:08:52 -0700 | [diff] [blame] | 273 | */ |
Bookatz | ff71cad | 2018-09-20 17:17:49 -0700 | [diff] [blame] | 274 | void StatsService::dumpStatsdStats(int out, bool verbose, bool proto) { |
Tej Singh | 41b3f9a | 2018-04-03 17:06:35 -0700 | [diff] [blame] | 275 | if (proto) { |
| 276 | vector<uint8_t> data; |
| 277 | StatsdStats::getInstance().dumpStats(&data, false); // does not reset statsdStats. |
| 278 | for (size_t i = 0; i < data.size(); i ++) { |
Yao Chen | a80e5c0 | 2018-09-04 13:55:29 -0700 | [diff] [blame] | 279 | dprintf(out, "%c", data[i]); |
Tej Singh | 41b3f9a | 2018-04-03 17:06:35 -0700 | [diff] [blame] | 280 | } |
| 281 | } else { |
| 282 | StatsdStats::getInstance().dumpStats(out); |
| 283 | mProcessor->dumpStates(out, verbose); |
| 284 | } |
Joe Onorato | 9fc9edf | 2017-10-15 20:08:52 -0700 | [diff] [blame] | 285 | } |
| 286 | |
| 287 | /** |
Bookatz | ff71cad | 2018-09-20 17:17:49 -0700 | [diff] [blame] | 288 | * Write stats report data in StatsDataDumpProto incident section format. |
| 289 | */ |
| 290 | void StatsService::dumpIncidentSection(int out) { |
| 291 | ProtoOutputStream proto; |
| 292 | for (const ConfigKey& configKey : mConfigManager->GetAllConfigKeys()) { |
| 293 | uint64_t reportsListToken = |
| 294 | proto.start(FIELD_TYPE_MESSAGE | FIELD_COUNT_REPEATED | FIELD_ID_REPORTS_LIST); |
| 295 | mProcessor->onDumpReport(configKey, getElapsedRealtimeNs(), |
| 296 | true /* includeCurrentBucket */, false /* erase_data */, |
| 297 | ADB_DUMP, &proto); |
| 298 | proto.end(reportsListToken); |
| 299 | proto.flush(out); |
Bookatz | c71d901 | 2018-12-19 12:28:38 -0800 | [diff] [blame] | 300 | proto.clear(); |
Bookatz | ff71cad | 2018-09-20 17:17:49 -0700 | [diff] [blame] | 301 | } |
| 302 | } |
| 303 | |
| 304 | /** |
Joe Onorato | 9fc9edf | 2017-10-15 20:08:52 -0700 | [diff] [blame] | 305 | * Implementation of the adb shell cmd stats command. |
| 306 | */ |
Yao Chen | a80e5c0 | 2018-09-04 13:55:29 -0700 | [diff] [blame] | 307 | status_t StatsService::command(int in, int out, int err, Vector<String8>& args, |
| 308 | sp<IResultReceiver> resultReceiver) { |
Jeff Sharkey | 6b64925 | 2018-04-16 09:50:22 -0600 | [diff] [blame] | 309 | uid_t uid = IPCThreadState::self()->getCallingUid(); |
| 310 | if (uid != AID_ROOT && uid != AID_SHELL) { |
| 311 | return PERMISSION_DENIED; |
| 312 | } |
Joe Onorato | 9fc9edf | 2017-10-15 20:08:52 -0700 | [diff] [blame] | 313 | |
| 314 | const int argCount = args.size(); |
| 315 | if (argCount >= 1) { |
| 316 | // adb shell cmd stats config ... |
David Chen | 0656b7a | 2017-09-13 15:53:39 -0700 | [diff] [blame] | 317 | if (!args[0].compare(String8("config"))) { |
Joe Onorato | 9fc9edf | 2017-10-15 20:08:52 -0700 | [diff] [blame] | 318 | return cmd_config(in, out, err, args); |
David Chen | 0656b7a | 2017-09-13 15:53:39 -0700 | [diff] [blame] | 319 | } |
Joe Onorato | 9fc9edf | 2017-10-15 20:08:52 -0700 | [diff] [blame] | 320 | |
David Chen | de70169 | 2017-10-05 13:16:02 -0700 | [diff] [blame] | 321 | if (!args[0].compare(String8("print-uid-map"))) { |
Yao Chen | d10f7b1 | 2017-12-18 12:53:50 -0800 | [diff] [blame] | 322 | return cmd_print_uid_map(out, args); |
David Chen | de70169 | 2017-10-05 13:16:02 -0700 | [diff] [blame] | 323 | } |
Yao Chen | 729093d | 2017-10-16 10:33:26 -0700 | [diff] [blame] | 324 | |
| 325 | if (!args[0].compare(String8("dump-report"))) { |
Bookatz | ff71cad | 2018-09-20 17:17:49 -0700 | [diff] [blame] | 326 | return cmd_dump_report(out, args); |
Yao Chen | 729093d | 2017-10-16 10:33:26 -0700 | [diff] [blame] | 327 | } |
David Chen | 1481fe1 | 2017-10-16 13:16:34 -0700 | [diff] [blame] | 328 | |
| 329 | if (!args[0].compare(String8("pull-source")) && args.size() > 1) { |
| 330 | return cmd_print_pulled_metrics(out, args); |
| 331 | } |
David Chen | adaf8b3 | 2017-11-03 15:42:08 -0700 | [diff] [blame] | 332 | |
| 333 | if (!args[0].compare(String8("send-broadcast"))) { |
David Chen | 1d7b0cd | 2017-11-15 14:20:04 -0800 | [diff] [blame] | 334 | return cmd_trigger_broadcast(out, args); |
| 335 | } |
| 336 | |
| 337 | if (!args[0].compare(String8("print-stats"))) { |
Yao Chen | b356151 | 2017-11-21 18:07:17 -0800 | [diff] [blame] | 338 | return cmd_print_stats(out, args); |
David Chen | adaf8b3 | 2017-11-03 15:42:08 -0700 | [diff] [blame] | 339 | } |
yro | 87d983c | 2017-11-14 21:31:43 -0800 | [diff] [blame] | 340 | |
Yao Chen | 8d9989b | 2017-11-18 18:54:50 -0800 | [diff] [blame] | 341 | if (!args[0].compare(String8("meminfo"))) { |
| 342 | return cmd_dump_memory_info(out); |
| 343 | } |
yro | 947fbce | 2017-11-15 22:50:23 -0800 | [diff] [blame] | 344 | |
| 345 | if (!args[0].compare(String8("write-to-disk"))) { |
| 346 | return cmd_write_data_to_disk(out); |
| 347 | } |
Bookatz | b223c4e | 2018-02-01 15:35:04 -0800 | [diff] [blame] | 348 | |
David Chen | 0b5c90c | 2018-01-25 16:51:49 -0800 | [diff] [blame] | 349 | if (!args[0].compare(String8("log-app-breadcrumb"))) { |
| 350 | return cmd_log_app_breadcrumb(out, args); |
Bookatz | b223c4e | 2018-02-01 15:35:04 -0800 | [diff] [blame] | 351 | } |
Chenjie Yu | fa22d65 | 2018-02-05 14:37:48 -0800 | [diff] [blame] | 352 | |
| 353 | if (!args[0].compare(String8("clear-puller-cache"))) { |
| 354 | return cmd_clear_puller_cache(out); |
| 355 | } |
Yao Chen | 876889c | 2018-05-02 11:16:16 -0700 | [diff] [blame] | 356 | |
| 357 | if (!args[0].compare(String8("print-logs"))) { |
| 358 | return cmd_print_logs(out, args); |
| 359 | } |
Yao Chen | a80e5c0 | 2018-09-04 13:55:29 -0700 | [diff] [blame] | 360 | if (!args[0].compare(String8("data-subscribe"))) { |
| 361 | if (mShellSubscriber == nullptr) { |
Yao Chen | 41e606c | 2018-10-05 15:54:11 -0700 | [diff] [blame] | 362 | mShellSubscriber = new ShellSubscriber(mUidMap, mPullerManager); |
Yao Chen | a80e5c0 | 2018-09-04 13:55:29 -0700 | [diff] [blame] | 363 | } |
Yao Chen | 35cb8d6 | 2019-01-03 16:49:14 -0800 | [diff] [blame] | 364 | int timeoutSec = -1; |
| 365 | if (argCount >= 2) { |
| 366 | timeoutSec = atoi(args[1].c_str()); |
| 367 | } |
| 368 | mShellSubscriber->startNewSubscription(in, out, resultReceiver, timeoutSec); |
Yao Chen | a80e5c0 | 2018-09-04 13:55:29 -0700 | [diff] [blame] | 369 | return NO_ERROR; |
| 370 | } |
Joe Onorato | 2cbc2cc | 2017-08-30 17:03:23 -0700 | [diff] [blame] | 371 | } |
Joe Onorato | 2cbc2cc | 2017-08-30 17:03:23 -0700 | [diff] [blame] | 372 | |
Joe Onorato | 9fc9edf | 2017-10-15 20:08:52 -0700 | [diff] [blame] | 373 | print_cmd_help(out); |
Joe Onorato | 2cbc2cc | 2017-08-30 17:03:23 -0700 | [diff] [blame] | 374 | return NO_ERROR; |
| 375 | } |
| 376 | |
Yao Chen | a80e5c0 | 2018-09-04 13:55:29 -0700 | [diff] [blame] | 377 | void StatsService::print_cmd_help(int out) { |
| 378 | dprintf(out, |
Joe Onorato | 9fc9edf | 2017-10-15 20:08:52 -0700 | [diff] [blame] | 379 | "usage: adb shell cmd stats print-stats-log [tag_required] " |
| 380 | "[timestamp_nsec_optional]\n"); |
Yao Chen | a80e5c0 | 2018-09-04 13:55:29 -0700 | [diff] [blame] | 381 | dprintf(out, "\n"); |
| 382 | dprintf(out, "\n"); |
| 383 | dprintf(out, "usage: adb shell cmd stats meminfo\n"); |
| 384 | dprintf(out, "\n"); |
| 385 | dprintf(out, " Prints the malloc debug information. You need to run the following first: \n"); |
| 386 | dprintf(out, " # adb shell stop\n"); |
| 387 | dprintf(out, " # adb shell setprop libc.debug.malloc.program statsd \n"); |
| 388 | dprintf(out, " # adb shell setprop libc.debug.malloc.options backtrace \n"); |
| 389 | dprintf(out, " # adb shell start\n"); |
| 390 | dprintf(out, "\n"); |
| 391 | dprintf(out, "\n"); |
| 392 | dprintf(out, "usage: adb shell cmd stats print-uid-map [PKG]\n"); |
| 393 | dprintf(out, "\n"); |
| 394 | dprintf(out, " Prints the UID, app name, version mapping.\n"); |
| 395 | dprintf(out, " PKG Optional package name to print the uids of the package\n"); |
| 396 | dprintf(out, "\n"); |
| 397 | dprintf(out, "\n"); |
| 398 | dprintf(out, "usage: adb shell cmd stats pull-source [int] \n"); |
| 399 | dprintf(out, "\n"); |
| 400 | dprintf(out, " Prints the output of a pulled metrics source (int indicates source)\n"); |
| 401 | dprintf(out, "\n"); |
| 402 | dprintf(out, "\n"); |
| 403 | dprintf(out, "usage: adb shell cmd stats write-to-disk \n"); |
| 404 | dprintf(out, "\n"); |
| 405 | dprintf(out, " Flushes all data on memory to disk.\n"); |
| 406 | dprintf(out, "\n"); |
| 407 | dprintf(out, "\n"); |
| 408 | dprintf(out, "usage: adb shell cmd stats log-app-breadcrumb [UID] LABEL STATE\n"); |
| 409 | dprintf(out, " Writes an AppBreadcrumbReported event to the statslog buffer.\n"); |
| 410 | dprintf(out, " UID The uid to use. It is only possible to pass a UID\n"); |
| 411 | dprintf(out, " parameter on eng builds. If UID is omitted the calling\n"); |
| 412 | dprintf(out, " uid is used.\n"); |
| 413 | dprintf(out, " LABEL Integer in [0, 15], as per atoms.proto.\n"); |
| 414 | dprintf(out, " STATE Integer in [0, 3], as per atoms.proto.\n"); |
| 415 | dprintf(out, "\n"); |
| 416 | dprintf(out, "\n"); |
| 417 | dprintf(out, "usage: adb shell cmd stats config remove [UID] [NAME]\n"); |
| 418 | dprintf(out, "usage: adb shell cmd stats config update [UID] NAME\n"); |
| 419 | dprintf(out, "\n"); |
| 420 | dprintf(out, " Adds, updates or removes a configuration. The proto should be in\n"); |
| 421 | dprintf(out, " wire-encoded protobuf format and passed via stdin. If no UID and name is\n"); |
| 422 | dprintf(out, " provided, then all configs will be removed from memory and disk.\n"); |
| 423 | dprintf(out, "\n"); |
| 424 | dprintf(out, " UID The uid to use. It is only possible to pass the UID\n"); |
| 425 | dprintf(out, " parameter on eng builds. If UID is omitted the calling\n"); |
| 426 | dprintf(out, " uid is used.\n"); |
| 427 | dprintf(out, " NAME The per-uid name to use\n"); |
| 428 | dprintf(out, "\n"); |
| 429 | dprintf(out, "\n *Note: If both UID and NAME are omitted then all configs will\n"); |
| 430 | dprintf(out, "\n be removed from memory and disk!\n"); |
| 431 | dprintf(out, "\n"); |
| 432 | dprintf(out, |
Bookatz | 3e90658 | 2018-12-10 17:26:58 -0800 | [diff] [blame] | 433 | "usage: adb shell cmd stats dump-report [UID] NAME [--keep_data] " |
| 434 | "[--include_current_bucket] [--proto]\n"); |
Yao Chen | a80e5c0 | 2018-09-04 13:55:29 -0700 | [diff] [blame] | 435 | dprintf(out, " Dump all metric data for a configuration.\n"); |
| 436 | dprintf(out, " UID The uid of the configuration. It is only possible to pass\n"); |
| 437 | dprintf(out, " the UID parameter on eng builds. If UID is omitted the\n"); |
| 438 | dprintf(out, " calling uid is used.\n"); |
| 439 | dprintf(out, " NAME The name of the configuration\n"); |
Bookatz | 3e90658 | 2018-12-10 17:26:58 -0800 | [diff] [blame] | 440 | dprintf(out, " --keep_data Do NOT erase the data upon dumping it.\n"); |
Yao Chen | a80e5c0 | 2018-09-04 13:55:29 -0700 | [diff] [blame] | 441 | dprintf(out, " --proto Print proto binary.\n"); |
| 442 | dprintf(out, "\n"); |
| 443 | dprintf(out, "\n"); |
| 444 | dprintf(out, "usage: adb shell cmd stats send-broadcast [UID] NAME\n"); |
| 445 | dprintf(out, " Send a broadcast that triggers the subscriber to fetch metrics.\n"); |
| 446 | dprintf(out, " UID The uid of the configuration. It is only possible to pass\n"); |
| 447 | dprintf(out, " the UID parameter on eng builds. If UID is omitted the\n"); |
| 448 | dprintf(out, " calling uid is used.\n"); |
| 449 | dprintf(out, " NAME The name of the configuration\n"); |
| 450 | dprintf(out, "\n"); |
| 451 | dprintf(out, "\n"); |
| 452 | dprintf(out, "usage: adb shell cmd stats print-stats\n"); |
| 453 | dprintf(out, " Prints some basic stats.\n"); |
| 454 | dprintf(out, " --proto Print proto binary instead of string format.\n"); |
| 455 | dprintf(out, "\n"); |
| 456 | dprintf(out, "\n"); |
| 457 | dprintf(out, "usage: adb shell cmd stats clear-puller-cache\n"); |
| 458 | dprintf(out, " Clear cached puller data.\n"); |
| 459 | dprintf(out, "\n"); |
| 460 | dprintf(out, "usage: adb shell cmd stats print-logs\n"); |
| 461 | dprintf(out, " Only works on eng build\n"); |
David Chen | adaf8b3 | 2017-11-03 15:42:08 -0700 | [diff] [blame] | 462 | } |
| 463 | |
Yao Chen | a80e5c0 | 2018-09-04 13:55:29 -0700 | [diff] [blame] | 464 | status_t StatsService::cmd_trigger_broadcast(int out, Vector<String8>& args) { |
David Chen | 1d7b0cd | 2017-11-15 14:20:04 -0800 | [diff] [blame] | 465 | string name; |
| 466 | bool good = false; |
| 467 | int uid; |
| 468 | const int argCount = args.size(); |
| 469 | if (argCount == 2) { |
| 470 | // Automatically pick the UID |
| 471 | uid = IPCThreadState::self()->getCallingUid(); |
David Chen | 1d7b0cd | 2017-11-15 14:20:04 -0800 | [diff] [blame] | 472 | name.assign(args[1].c_str(), args[1].size()); |
| 473 | good = true; |
| 474 | } else if (argCount == 3) { |
Bookatz | d238657 | 2018-12-14 15:53:14 -0800 | [diff] [blame] | 475 | good = getUidFromArgs(args, 1, uid); |
| 476 | if (!good) { |
| 477 | dprintf(out, "Invalid UID. Note that the metrics can only be dumped for " |
| 478 | "other UIDs on eng or userdebug builds.\n"); |
David Chen | 1d7b0cd | 2017-11-15 14:20:04 -0800 | [diff] [blame] | 479 | } |
Bookatz | d238657 | 2018-12-14 15:53:14 -0800 | [diff] [blame] | 480 | name.assign(args[2].c_str(), args[2].size()); |
David Chen | 1d7b0cd | 2017-11-15 14:20:04 -0800 | [diff] [blame] | 481 | } |
| 482 | if (!good) { |
| 483 | print_cmd_help(out); |
| 484 | return UNKNOWN_ERROR; |
| 485 | } |
David Chen | d37bc23 | 2018-04-12 18:05:11 -0700 | [diff] [blame] | 486 | ConfigKey key(uid, StrToInt64(name)); |
| 487 | auto receiver = mConfigManager->GetConfigReceiver(key); |
yro | 4d889e6 | 2017-11-17 15:44:48 -0800 | [diff] [blame] | 488 | sp<IStatsCompanionService> sc = getStatsCompanionService(); |
David Chen | 661f791 | 2018-01-22 17:46:24 -0800 | [diff] [blame] | 489 | if (sc == nullptr) { |
| 490 | VLOG("Could not access statsCompanion"); |
| 491 | } else if (receiver == nullptr) { |
| 492 | VLOG("Could not find receiver for %s, %s", args[1].c_str(), args[2].c_str()) |
| 493 | } else { |
David Chen | d37bc23 | 2018-04-12 18:05:11 -0700 | [diff] [blame] | 494 | sc->sendDataBroadcast(receiver, mProcessor->getLastReportTimeNs(key)); |
yro | 74fed97 | 2017-11-27 14:42:42 -0800 | [diff] [blame] | 495 | VLOG("StatsService::trigger broadcast succeeded to %s, %s", args[1].c_str(), |
| 496 | args[2].c_str()); |
yro | 4d889e6 | 2017-11-17 15:44:48 -0800 | [diff] [blame] | 497 | } |
| 498 | |
David Chen | adaf8b3 | 2017-11-03 15:42:08 -0700 | [diff] [blame] | 499 | return NO_ERROR; |
Joe Onorato | 9fc9edf | 2017-10-15 20:08:52 -0700 | [diff] [blame] | 500 | } |
| 501 | |
Yao Chen | a80e5c0 | 2018-09-04 13:55:29 -0700 | [diff] [blame] | 502 | status_t StatsService::cmd_config(int in, int out, int err, Vector<String8>& args) { |
Joe Onorato | 9fc9edf | 2017-10-15 20:08:52 -0700 | [diff] [blame] | 503 | const int argCount = args.size(); |
| 504 | if (argCount >= 2) { |
| 505 | if (args[1] == "update" || args[1] == "remove") { |
| 506 | bool good = false; |
| 507 | int uid = -1; |
| 508 | string name; |
| 509 | |
| 510 | if (argCount == 3) { |
| 511 | // Automatically pick the UID |
| 512 | uid = IPCThreadState::self()->getCallingUid(); |
Joe Onorato | 9fc9edf | 2017-10-15 20:08:52 -0700 | [diff] [blame] | 513 | name.assign(args[2].c_str(), args[2].size()); |
| 514 | good = true; |
| 515 | } else if (argCount == 4) { |
Bookatz | d238657 | 2018-12-14 15:53:14 -0800 | [diff] [blame] | 516 | good = getUidFromArgs(args, 2, uid); |
| 517 | if (!good) { |
| 518 | dprintf(err, "Invalid UID. Note that the config can only be set for " |
| 519 | "other UIDs on eng or userdebug builds.\n"); |
Joe Onorato | 9fc9edf | 2017-10-15 20:08:52 -0700 | [diff] [blame] | 520 | } |
Bookatz | d238657 | 2018-12-14 15:53:14 -0800 | [diff] [blame] | 521 | name.assign(args[3].c_str(), args[3].size()); |
yro | e5f8292 | 2018-01-22 18:37:27 -0800 | [diff] [blame] | 522 | } else if (argCount == 2 && args[1] == "remove") { |
| 523 | good = true; |
Joe Onorato | 9fc9edf | 2017-10-15 20:08:52 -0700 | [diff] [blame] | 524 | } |
| 525 | |
| 526 | if (!good) { |
| 527 | // If arg parsing failed, print the help text and return an error. |
| 528 | print_cmd_help(out); |
| 529 | return UNKNOWN_ERROR; |
| 530 | } |
| 531 | |
| 532 | if (args[1] == "update") { |
yro | 255f72e | 2018-02-26 15:15:17 -0800 | [diff] [blame] | 533 | char* endp; |
| 534 | int64_t configID = strtoll(name.c_str(), &endp, 10); |
| 535 | if (endp == name.c_str() || *endp != '\0') { |
Yao Chen | a80e5c0 | 2018-09-04 13:55:29 -0700 | [diff] [blame] | 536 | dprintf(err, "Error parsing config ID.\n"); |
yro | 255f72e | 2018-02-26 15:15:17 -0800 | [diff] [blame] | 537 | return UNKNOWN_ERROR; |
| 538 | } |
| 539 | |
Joe Onorato | 9fc9edf | 2017-10-15 20:08:52 -0700 | [diff] [blame] | 540 | // Read stream into buffer. |
| 541 | string buffer; |
Yao Chen | a80e5c0 | 2018-09-04 13:55:29 -0700 | [diff] [blame] | 542 | if (!android::base::ReadFdToString(in, &buffer)) { |
| 543 | dprintf(err, "Error reading stream for StatsConfig.\n"); |
Joe Onorato | 9fc9edf | 2017-10-15 20:08:52 -0700 | [diff] [blame] | 544 | return UNKNOWN_ERROR; |
| 545 | } |
| 546 | |
| 547 | // Parse buffer. |
| 548 | StatsdConfig config; |
| 549 | if (!config.ParseFromString(buffer)) { |
Yao Chen | a80e5c0 | 2018-09-04 13:55:29 -0700 | [diff] [blame] | 550 | dprintf(err, "Error parsing proto stream for StatsConfig.\n"); |
Joe Onorato | 9fc9edf | 2017-10-15 20:08:52 -0700 | [diff] [blame] | 551 | return UNKNOWN_ERROR; |
| 552 | } |
| 553 | |
| 554 | // Add / update the config. |
yro | 255f72e | 2018-02-26 15:15:17 -0800 | [diff] [blame] | 555 | mConfigManager->UpdateConfig(ConfigKey(uid, configID), config); |
Joe Onorato | 9fc9edf | 2017-10-15 20:08:52 -0700 | [diff] [blame] | 556 | } else { |
yro | 74fed97 | 2017-11-27 14:42:42 -0800 | [diff] [blame] | 557 | if (argCount == 2) { |
| 558 | cmd_remove_all_configs(out); |
| 559 | } else { |
| 560 | // Remove the config. |
Yangster-mac | 94e197c | 2018-01-02 16:03:03 -0800 | [diff] [blame] | 561 | mConfigManager->RemoveConfig(ConfigKey(uid, StrToInt64(name))); |
yro | 74fed97 | 2017-11-27 14:42:42 -0800 | [diff] [blame] | 562 | } |
Joe Onorato | 9fc9edf | 2017-10-15 20:08:52 -0700 | [diff] [blame] | 563 | } |
| 564 | |
| 565 | return NO_ERROR; |
| 566 | } |
David Chen | 0656b7a | 2017-09-13 15:53:39 -0700 | [diff] [blame] | 567 | } |
Joe Onorato | 9fc9edf | 2017-10-15 20:08:52 -0700 | [diff] [blame] | 568 | print_cmd_help(out); |
| 569 | return UNKNOWN_ERROR; |
| 570 | } |
| 571 | |
Bookatz | ff71cad | 2018-09-20 17:17:49 -0700 | [diff] [blame] | 572 | status_t StatsService::cmd_dump_report(int out, const Vector<String8>& args) { |
Yao Chen | 729093d | 2017-10-16 10:33:26 -0700 | [diff] [blame] | 573 | if (mProcessor != nullptr) { |
Chenjie Yu | b236c86 | 2017-11-28 22:20:44 -0800 | [diff] [blame] | 574 | int argCount = args.size(); |
Yao Chen | 729093d | 2017-10-16 10:33:26 -0700 | [diff] [blame] | 575 | bool good = false; |
Chenjie Yu | b236c86 | 2017-11-28 22:20:44 -0800 | [diff] [blame] | 576 | bool proto = false; |
Chenjie Yu | bd1a28f | 2018-07-17 14:55:19 -0700 | [diff] [blame] | 577 | bool includeCurrentBucket = false; |
Bookatz | 3e90658 | 2018-12-10 17:26:58 -0800 | [diff] [blame] | 578 | bool eraseData = true; |
Yao Chen | 729093d | 2017-10-16 10:33:26 -0700 | [diff] [blame] | 579 | int uid; |
| 580 | string name; |
Chenjie Yu | b236c86 | 2017-11-28 22:20:44 -0800 | [diff] [blame] | 581 | if (!std::strcmp("--proto", args[argCount-1].c_str())) { |
| 582 | proto = true; |
| 583 | argCount -= 1; |
| 584 | } |
Chenjie Yu | bd1a28f | 2018-07-17 14:55:19 -0700 | [diff] [blame] | 585 | if (!std::strcmp("--include_current_bucket", args[argCount-1].c_str())) { |
| 586 | includeCurrentBucket = true; |
| 587 | argCount -= 1; |
| 588 | } |
Bookatz | 3e90658 | 2018-12-10 17:26:58 -0800 | [diff] [blame] | 589 | if (!std::strcmp("--keep_data", args[argCount-1].c_str())) { |
| 590 | eraseData = false; |
| 591 | argCount -= 1; |
| 592 | } |
Yao Chen | 729093d | 2017-10-16 10:33:26 -0700 | [diff] [blame] | 593 | if (argCount == 2) { |
| 594 | // Automatically pick the UID |
| 595 | uid = IPCThreadState::self()->getCallingUid(); |
Yao Chen | 5154a379 | 2017-10-30 22:57:06 -0700 | [diff] [blame] | 596 | name.assign(args[1].c_str(), args[1].size()); |
Yao Chen | 729093d | 2017-10-16 10:33:26 -0700 | [diff] [blame] | 597 | good = true; |
| 598 | } else if (argCount == 3) { |
Bookatz | d238657 | 2018-12-14 15:53:14 -0800 | [diff] [blame] | 599 | good = getUidFromArgs(args, 1, uid); |
| 600 | if (!good) { |
| 601 | dprintf(out, "Invalid UID. Note that the metrics can only be dumped for " |
| 602 | "other UIDs on eng or userdebug builds.\n"); |
Yao Chen | 729093d | 2017-10-16 10:33:26 -0700 | [diff] [blame] | 603 | } |
Bookatz | d238657 | 2018-12-14 15:53:14 -0800 | [diff] [blame] | 604 | name.assign(args[2].c_str(), args[2].size()); |
Yao Chen | 729093d | 2017-10-16 10:33:26 -0700 | [diff] [blame] | 605 | } |
| 606 | if (good) { |
David Chen | 1d7b0cd | 2017-11-15 14:20:04 -0800 | [diff] [blame] | 607 | vector<uint8_t> data; |
David Chen | 926fc75 | 2018-02-23 13:31:43 -0800 | [diff] [blame] | 608 | mProcessor->onDumpReport(ConfigKey(uid, StrToInt64(name)), getElapsedRealtimeNs(), |
Bookatz | 3e90658 | 2018-12-10 17:26:58 -0800 | [diff] [blame] | 609 | includeCurrentBucket, eraseData, ADB_DUMP, &data); |
Chenjie Yu | b236c86 | 2017-11-28 22:20:44 -0800 | [diff] [blame] | 610 | if (proto) { |
| 611 | for (size_t i = 0; i < data.size(); i ++) { |
Yao Chen | a80e5c0 | 2018-09-04 13:55:29 -0700 | [diff] [blame] | 612 | dprintf(out, "%c", data[i]); |
Chenjie Yu | b236c86 | 2017-11-28 22:20:44 -0800 | [diff] [blame] | 613 | } |
| 614 | } else { |
Bookatz | ff71cad | 2018-09-20 17:17:49 -0700 | [diff] [blame] | 615 | dprintf(out, "Non-proto stats data dump not currently supported.\n"); |
Chenjie Yu | b236c86 | 2017-11-28 22:20:44 -0800 | [diff] [blame] | 616 | } |
Yao Chen | 729093d | 2017-10-16 10:33:26 -0700 | [diff] [blame] | 617 | return android::OK; |
| 618 | } else { |
| 619 | // If arg parsing failed, print the help text and return an error. |
| 620 | print_cmd_help(out); |
| 621 | return UNKNOWN_ERROR; |
| 622 | } |
| 623 | } else { |
Yao Chen | a80e5c0 | 2018-09-04 13:55:29 -0700 | [diff] [blame] | 624 | dprintf(out, "Log processor does not exist...\n"); |
Yao Chen | 729093d | 2017-10-16 10:33:26 -0700 | [diff] [blame] | 625 | return UNKNOWN_ERROR; |
| 626 | } |
| 627 | } |
| 628 | |
Yao Chen | a80e5c0 | 2018-09-04 13:55:29 -0700 | [diff] [blame] | 629 | status_t StatsService::cmd_print_stats(int out, const Vector<String8>& args) { |
Tej Singh | 41b3f9a | 2018-04-03 17:06:35 -0700 | [diff] [blame] | 630 | int argCount = args.size(); |
| 631 | bool proto = false; |
| 632 | if (!std::strcmp("--proto", args[argCount-1].c_str())) { |
| 633 | proto = true; |
| 634 | argCount -= 1; |
David Chen | 1d7b0cd | 2017-11-15 14:20:04 -0800 | [diff] [blame] | 635 | } |
Yao Chen | b356151 | 2017-11-21 18:07:17 -0800 | [diff] [blame] | 636 | StatsdStats& statsdStats = StatsdStats::getInstance(); |
Tej Singh | 41b3f9a | 2018-04-03 17:06:35 -0700 | [diff] [blame] | 637 | if (proto) { |
| 638 | vector<uint8_t> data; |
| 639 | statsdStats.dumpStats(&data, false); // does not reset statsdStats. |
| 640 | for (size_t i = 0; i < data.size(); i ++) { |
Yao Chen | a80e5c0 | 2018-09-04 13:55:29 -0700 | [diff] [blame] | 641 | dprintf(out, "%c", data[i]); |
Tej Singh | 41b3f9a | 2018-04-03 17:06:35 -0700 | [diff] [blame] | 642 | } |
| 643 | |
| 644 | } else { |
| 645 | vector<ConfigKey> configs = mConfigManager->GetAllConfigKeys(); |
| 646 | for (const ConfigKey& key : configs) { |
Yao Chen | a80e5c0 | 2018-09-04 13:55:29 -0700 | [diff] [blame] | 647 | dprintf(out, "Config %s uses %zu bytes\n", key.ToString().c_str(), |
Tej Singh | 41b3f9a | 2018-04-03 17:06:35 -0700 | [diff] [blame] | 648 | mProcessor->GetMetricsSize(key)); |
| 649 | } |
| 650 | statsdStats.dumpStats(out); |
| 651 | } |
David Chen | 1d7b0cd | 2017-11-15 14:20:04 -0800 | [diff] [blame] | 652 | return NO_ERROR; |
| 653 | } |
| 654 | |
Yao Chen | a80e5c0 | 2018-09-04 13:55:29 -0700 | [diff] [blame] | 655 | status_t StatsService::cmd_print_uid_map(int out, const Vector<String8>& args) { |
Yao Chen | d10f7b1 | 2017-12-18 12:53:50 -0800 | [diff] [blame] | 656 | if (args.size() > 1) { |
| 657 | string pkg; |
| 658 | pkg.assign(args[1].c_str(), args[1].size()); |
| 659 | auto uids = mUidMap->getAppUid(pkg); |
Yao Chen | a80e5c0 | 2018-09-04 13:55:29 -0700 | [diff] [blame] | 660 | dprintf(out, "%s -> [ ", pkg.c_str()); |
Yao Chen | d10f7b1 | 2017-12-18 12:53:50 -0800 | [diff] [blame] | 661 | for (const auto& uid : uids) { |
Yao Chen | a80e5c0 | 2018-09-04 13:55:29 -0700 | [diff] [blame] | 662 | dprintf(out, "%d ", uid); |
Yao Chen | d10f7b1 | 2017-12-18 12:53:50 -0800 | [diff] [blame] | 663 | } |
Yao Chen | a80e5c0 | 2018-09-04 13:55:29 -0700 | [diff] [blame] | 664 | dprintf(out, "]\n"); |
Yao Chen | d10f7b1 | 2017-12-18 12:53:50 -0800 | [diff] [blame] | 665 | } else { |
| 666 | mUidMap->printUidMap(out); |
| 667 | } |
Joe Onorato | 9fc9edf | 2017-10-15 20:08:52 -0700 | [diff] [blame] | 668 | return NO_ERROR; |
David Chen | 0656b7a | 2017-09-13 15:53:39 -0700 | [diff] [blame] | 669 | } |
| 670 | |
Yao Chen | a80e5c0 | 2018-09-04 13:55:29 -0700 | [diff] [blame] | 671 | status_t StatsService::cmd_write_data_to_disk(int out) { |
| 672 | dprintf(out, "Writing data to disk\n"); |
Yangster-mac | 892f3d3 | 2018-05-02 14:16:48 -0700 | [diff] [blame] | 673 | mProcessor->WriteDataToDisk(ADB_DUMP); |
yro | 947fbce | 2017-11-15 22:50:23 -0800 | [diff] [blame] | 674 | return NO_ERROR; |
| 675 | } |
| 676 | |
Yao Chen | a80e5c0 | 2018-09-04 13:55:29 -0700 | [diff] [blame] | 677 | status_t StatsService::cmd_log_app_breadcrumb(int out, const Vector<String8>& args) { |
Bookatz | b223c4e | 2018-02-01 15:35:04 -0800 | [diff] [blame] | 678 | bool good = false; |
| 679 | int32_t uid; |
| 680 | int32_t label; |
| 681 | int32_t state; |
| 682 | const int argCount = args.size(); |
| 683 | if (argCount == 3) { |
| 684 | // Automatically pick the UID |
| 685 | uid = IPCThreadState::self()->getCallingUid(); |
| 686 | label = atoi(args[1].c_str()); |
| 687 | state = atoi(args[2].c_str()); |
| 688 | good = true; |
| 689 | } else if (argCount == 4) { |
Bookatz | d238657 | 2018-12-14 15:53:14 -0800 | [diff] [blame] | 690 | good = getUidFromArgs(args, 1, uid); |
| 691 | if (!good) { |
Yao Chen | a80e5c0 | 2018-09-04 13:55:29 -0700 | [diff] [blame] | 692 | dprintf(out, |
Bookatz | d238657 | 2018-12-14 15:53:14 -0800 | [diff] [blame] | 693 | "Invalid UID. Note that selecting a UID for writing AppBreadcrumb can only be " |
| 694 | "done for other UIDs on eng or userdebug builds.\n"); |
Bookatz | b223c4e | 2018-02-01 15:35:04 -0800 | [diff] [blame] | 695 | } |
Bookatz | d238657 | 2018-12-14 15:53:14 -0800 | [diff] [blame] | 696 | label = atoi(args[2].c_str()); |
| 697 | state = atoi(args[3].c_str()); |
Bookatz | b223c4e | 2018-02-01 15:35:04 -0800 | [diff] [blame] | 698 | } |
| 699 | if (good) { |
Yao Chen | a80e5c0 | 2018-09-04 13:55:29 -0700 | [diff] [blame] | 700 | dprintf(out, "Logging AppBreadcrumbReported(%d, %d, %d) to statslog.\n", uid, label, state); |
David Chen | 0b5c90c | 2018-01-25 16:51:49 -0800 | [diff] [blame] | 701 | android::util::stats_write(android::util::APP_BREADCRUMB_REPORTED, uid, label, state); |
Bookatz | b223c4e | 2018-02-01 15:35:04 -0800 | [diff] [blame] | 702 | } else { |
| 703 | print_cmd_help(out); |
| 704 | return UNKNOWN_ERROR; |
| 705 | } |
| 706 | return NO_ERROR; |
| 707 | } |
| 708 | |
Yao Chen | a80e5c0 | 2018-09-04 13:55:29 -0700 | [diff] [blame] | 709 | status_t StatsService::cmd_print_pulled_metrics(int out, const Vector<String8>& args) { |
David Chen | 1481fe1 | 2017-10-16 13:16:34 -0700 | [diff] [blame] | 710 | int s = atoi(args[1].c_str()); |
Chenjie Yu | 5305e1d | 2017-10-31 13:49:36 -0700 | [diff] [blame] | 711 | vector<shared_ptr<LogEvent> > stats; |
Chenjie Yu | 0bd73db | 2018-12-16 07:37:04 -0800 | [diff] [blame] | 712 | if (mPullerManager->Pull(s, &stats)) { |
Chenjie Yu | 5305e1d | 2017-10-31 13:49:36 -0700 | [diff] [blame] | 713 | for (const auto& it : stats) { |
Yao Chen | a80e5c0 | 2018-09-04 13:55:29 -0700 | [diff] [blame] | 714 | dprintf(out, "Pull from %d: %s\n", s, it->ToString().c_str()); |
Chenjie Yu | 5305e1d | 2017-10-31 13:49:36 -0700 | [diff] [blame] | 715 | } |
Yao Chen | a80e5c0 | 2018-09-04 13:55:29 -0700 | [diff] [blame] | 716 | dprintf(out, "Pull from %d: Received %zu elements\n", s, stats.size()); |
Chenjie Yu | 5305e1d | 2017-10-31 13:49:36 -0700 | [diff] [blame] | 717 | return NO_ERROR; |
David Chen | 1481fe1 | 2017-10-16 13:16:34 -0700 | [diff] [blame] | 718 | } |
Chenjie Yu | 5305e1d | 2017-10-31 13:49:36 -0700 | [diff] [blame] | 719 | return UNKNOWN_ERROR; |
David Chen | 1481fe1 | 2017-10-16 13:16:34 -0700 | [diff] [blame] | 720 | } |
| 721 | |
Yao Chen | a80e5c0 | 2018-09-04 13:55:29 -0700 | [diff] [blame] | 722 | status_t StatsService::cmd_remove_all_configs(int out) { |
| 723 | dprintf(out, "Removing all configs...\n"); |
yro | 74fed97 | 2017-11-27 14:42:42 -0800 | [diff] [blame] | 724 | VLOG("StatsService::cmd_remove_all_configs was called"); |
| 725 | mConfigManager->RemoveAllConfigs(); |
yro | 947fbce | 2017-11-15 22:50:23 -0800 | [diff] [blame] | 726 | StorageManager::deleteAllFiles(STATS_SERVICE_DIR); |
yro | 87d983c | 2017-11-14 21:31:43 -0800 | [diff] [blame] | 727 | return NO_ERROR; |
| 728 | } |
| 729 | |
Yao Chen | a80e5c0 | 2018-09-04 13:55:29 -0700 | [diff] [blame] | 730 | status_t StatsService::cmd_dump_memory_info(int out) { |
| 731 | dprintf(out, "meminfo not available.\n"); |
Yao Chen | 8d9989b | 2017-11-18 18:54:50 -0800 | [diff] [blame] | 732 | return NO_ERROR; |
| 733 | } |
| 734 | |
Yao Chen | a80e5c0 | 2018-09-04 13:55:29 -0700 | [diff] [blame] | 735 | status_t StatsService::cmd_clear_puller_cache(int out) { |
Chenjie Yu | fa22d65 | 2018-02-05 14:37:48 -0800 | [diff] [blame] | 736 | IPCThreadState* ipc = IPCThreadState::self(); |
Yangster-mac | 932ecec | 2018-02-01 10:23:52 -0800 | [diff] [blame] | 737 | VLOG("StatsService::cmd_clear_puller_cache with Pid %i, Uid %i", |
| 738 | ipc->getCallingPid(), ipc->getCallingUid()); |
Chenjie Yu | fa22d65 | 2018-02-05 14:37:48 -0800 | [diff] [blame] | 739 | if (checkCallingPermission(String16(kPermissionDump))) { |
Chenjie Yu | e221920 | 2018-06-08 10:07:51 -0700 | [diff] [blame] | 740 | int cleared = mPullerManager->ForceClearPullerCache(); |
Yao Chen | a80e5c0 | 2018-09-04 13:55:29 -0700 | [diff] [blame] | 741 | dprintf(out, "Puller removed %d cached data!\n", cleared); |
Chenjie Yu | fa22d65 | 2018-02-05 14:37:48 -0800 | [diff] [blame] | 742 | return NO_ERROR; |
| 743 | } else { |
| 744 | return PERMISSION_DENIED; |
| 745 | } |
Chenjie Yu | e72252b | 2018-02-01 13:19:35 -0800 | [diff] [blame] | 746 | } |
| 747 | |
Yao Chen | a80e5c0 | 2018-09-04 13:55:29 -0700 | [diff] [blame] | 748 | status_t StatsService::cmd_print_logs(int out, const Vector<String8>& args) { |
Yao Chen | 876889c | 2018-05-02 11:16:16 -0700 | [diff] [blame] | 749 | IPCThreadState* ipc = IPCThreadState::self(); |
| 750 | VLOG("StatsService::cmd_print_logs with Pid %i, Uid %i", ipc->getCallingPid(), |
| 751 | ipc->getCallingUid()); |
| 752 | if (checkCallingPermission(String16(kPermissionDump))) { |
| 753 | bool enabled = true; |
| 754 | if (args.size() >= 2) { |
| 755 | enabled = atoi(args[1].c_str()) != 0; |
| 756 | } |
| 757 | mProcessor->setPrintLogs(enabled); |
| 758 | return NO_ERROR; |
| 759 | } else { |
| 760 | return PERMISSION_DENIED; |
| 761 | } |
| 762 | } |
| 763 | |
Bookatz | d238657 | 2018-12-14 15:53:14 -0800 | [diff] [blame] | 764 | bool StatsService::getUidFromArgs(const Vector<String8>& args, size_t uidArgIndex, int32_t& uid) { |
| 765 | const char* s = args[uidArgIndex].c_str(); |
| 766 | if (*s == '\0') { |
| 767 | return false; |
| 768 | } |
| 769 | char* endc = NULL; |
| 770 | int64_t longUid = strtol(s, &endc, 0); |
| 771 | if (*endc != '\0') { |
| 772 | return false; |
| 773 | } |
| 774 | int32_t goodUid = static_cast<int32_t>(longUid); |
| 775 | if (longUid < 0 || static_cast<uint64_t>(longUid) != static_cast<uid_t>(goodUid)) { |
| 776 | return false; // It was not of uid_t type. |
| 777 | } |
| 778 | uid = goodUid; |
| 779 | |
| 780 | int32_t callingUid = IPCThreadState::self()->getCallingUid(); |
| 781 | return mEngBuild // UserDebug/EngBuild are allowed to impersonate uids. |
| 782 | || (callingUid == goodUid) // Anyone can 'impersonate' themselves. |
| 783 | || (callingUid == AID_ROOT && goodUid == AID_SHELL); // ROOT can impersonate SHELL. |
| 784 | } |
| 785 | |
Dianne Hackborn | 3accca0 | 2013-09-20 09:32:11 -0700 | [diff] [blame] | 786 | Status StatsService::informAllUidData(const vector<int32_t>& uid, const vector<int64_t>& version, |
dwchen | 730403e | 2018-10-29 11:41:56 -0700 | [diff] [blame] | 787 | const vector<String16>& version_string, |
| 788 | const vector<String16>& app, |
| 789 | const vector<String16>& installer) { |
Jeff Sharkey | 6b64925 | 2018-04-16 09:50:22 -0600 | [diff] [blame] | 790 | ENFORCE_UID(AID_SYSTEM); |
| 791 | |
yro | 74fed97 | 2017-11-27 14:42:42 -0800 | [diff] [blame] | 792 | VLOG("StatsService::informAllUidData was called"); |
dwchen | 730403e | 2018-10-29 11:41:56 -0700 | [diff] [blame] | 793 | mUidMap->updateMap(getElapsedRealtimeNs(), uid, version, version_string, app, installer); |
yro | 74fed97 | 2017-11-27 14:42:42 -0800 | [diff] [blame] | 794 | VLOG("StatsService::informAllUidData succeeded"); |
David Chen | de70169 | 2017-10-05 13:16:02 -0700 | [diff] [blame] | 795 | |
| 796 | return Status::ok(); |
| 797 | } |
| 798 | |
dwchen | 730403e | 2018-10-29 11:41:56 -0700 | [diff] [blame] | 799 | Status StatsService::informOnePackage(const String16& app, int32_t uid, int64_t version, |
| 800 | const String16& version_string, const String16& installer) { |
Jeff Sharkey | 6b64925 | 2018-04-16 09:50:22 -0600 | [diff] [blame] | 801 | ENFORCE_UID(AID_SYSTEM); |
David Chen | de70169 | 2017-10-05 13:16:02 -0700 | [diff] [blame] | 802 | |
Jeff Sharkey | 6b64925 | 2018-04-16 09:50:22 -0600 | [diff] [blame] | 803 | VLOG("StatsService::informOnePackage was called"); |
dwchen | 730403e | 2018-10-29 11:41:56 -0700 | [diff] [blame] | 804 | mUidMap->updateApp(getElapsedRealtimeNs(), app, uid, version, version_string, installer); |
David Chen | de70169 | 2017-10-05 13:16:02 -0700 | [diff] [blame] | 805 | return Status::ok(); |
| 806 | } |
| 807 | |
| 808 | Status StatsService::informOnePackageRemoved(const String16& app, int32_t uid) { |
Jeff Sharkey | 6b64925 | 2018-04-16 09:50:22 -0600 | [diff] [blame] | 809 | ENFORCE_UID(AID_SYSTEM); |
David Chen | de70169 | 2017-10-05 13:16:02 -0700 | [diff] [blame] | 810 | |
Jeff Sharkey | 6b64925 | 2018-04-16 09:50:22 -0600 | [diff] [blame] | 811 | VLOG("StatsService::informOnePackageRemoved was called"); |
David Chen | bd12527 | 2018-04-04 19:02:50 -0700 | [diff] [blame] | 812 | mUidMap->removeApp(getElapsedRealtimeNs(), app, uid); |
yro | 0192402 | 2018-02-20 18:20:49 -0800 | [diff] [blame] | 813 | mConfigManager->RemoveConfigs(uid); |
David Chen | de70169 | 2017-10-05 13:16:02 -0700 | [diff] [blame] | 814 | return Status::ok(); |
| 815 | } |
| 816 | |
Yao Chen | ef99c4f | 2017-09-22 16:26:54 -0700 | [diff] [blame] | 817 | Status StatsService::informAnomalyAlarmFired() { |
Jeff Sharkey | 6b64925 | 2018-04-16 09:50:22 -0600 | [diff] [blame] | 818 | ENFORCE_UID(AID_SYSTEM); |
| 819 | |
yro | 74fed97 | 2017-11-27 14:42:42 -0800 | [diff] [blame] | 820 | VLOG("StatsService::informAnomalyAlarmFired was called"); |
Yangster-mac | b142cc8 | 2018-03-30 15:22:08 -0700 | [diff] [blame] | 821 | int64_t currentTimeSec = getElapsedRealtimeSec(); |
Yangster-mac | 932ecec | 2018-02-01 10:23:52 -0800 | [diff] [blame] | 822 | std::unordered_set<sp<const InternalAlarm>, SpHash<InternalAlarm>> alarmSet = |
| 823 | mAnomalyAlarmMonitor->popSoonerThan(static_cast<uint32_t>(currentTimeSec)); |
| 824 | if (alarmSet.size() > 0) { |
Bookatz | 66fe061 | 2018-02-07 18:51:48 -0800 | [diff] [blame] | 825 | VLOG("Found an anomaly alarm that fired."); |
Yangster-mac | 932ecec | 2018-02-01 10:23:52 -0800 | [diff] [blame] | 826 | mProcessor->onAnomalyAlarmFired(currentTimeSec * NS_PER_SEC, alarmSet); |
Bookatz | 66fe061 | 2018-02-07 18:51:48 -0800 | [diff] [blame] | 827 | } else { |
| 828 | VLOG("Cannot find an anomaly alarm that fired. Perhaps it was recently cancelled."); |
| 829 | } |
Bookatz | 1b0b114 | 2017-09-08 11:58:42 -0700 | [diff] [blame] | 830 | return Status::ok(); |
| 831 | } |
| 832 | |
Yangster-mac | 932ecec | 2018-02-01 10:23:52 -0800 | [diff] [blame] | 833 | Status StatsService::informAlarmForSubscriberTriggeringFired() { |
Jeff Sharkey | 6b64925 | 2018-04-16 09:50:22 -0600 | [diff] [blame] | 834 | ENFORCE_UID(AID_SYSTEM); |
| 835 | |
Yangster-mac | 932ecec | 2018-02-01 10:23:52 -0800 | [diff] [blame] | 836 | VLOG("StatsService::informAlarmForSubscriberTriggeringFired was called"); |
Yangster-mac | b142cc8 | 2018-03-30 15:22:08 -0700 | [diff] [blame] | 837 | int64_t currentTimeSec = getElapsedRealtimeSec(); |
Yangster-mac | 932ecec | 2018-02-01 10:23:52 -0800 | [diff] [blame] | 838 | std::unordered_set<sp<const InternalAlarm>, SpHash<InternalAlarm>> alarmSet = |
| 839 | mPeriodicAlarmMonitor->popSoonerThan(static_cast<uint32_t>(currentTimeSec)); |
| 840 | if (alarmSet.size() > 0) { |
| 841 | VLOG("Found periodic alarm fired."); |
| 842 | mProcessor->onPeriodicAlarmFired(currentTimeSec * NS_PER_SEC, alarmSet); |
| 843 | } else { |
| 844 | ALOGW("Cannot find an periodic alarm that fired. Perhaps it was recently cancelled."); |
| 845 | } |
| 846 | return Status::ok(); |
| 847 | } |
| 848 | |
Yao Chen | ef99c4f | 2017-09-22 16:26:54 -0700 | [diff] [blame] | 849 | Status StatsService::informPollAlarmFired() { |
Jeff Sharkey | 6b64925 | 2018-04-16 09:50:22 -0600 | [diff] [blame] | 850 | ENFORCE_UID(AID_SYSTEM); |
| 851 | |
yro | 74fed97 | 2017-11-27 14:42:42 -0800 | [diff] [blame] | 852 | VLOG("StatsService::informPollAlarmFired was called"); |
Yangster-mac | 15f6bbc | 2018-04-08 11:52:26 -0700 | [diff] [blame] | 853 | mProcessor->informPullAlarmFired(getElapsedRealtimeNs()); |
yro | 74fed97 | 2017-11-27 14:42:42 -0800 | [diff] [blame] | 854 | VLOG("StatsService::informPollAlarmFired succeeded"); |
Bookatz | 1b0b114 | 2017-09-08 11:58:42 -0700 | [diff] [blame] | 855 | return Status::ok(); |
| 856 | } |
| 857 | |
Yao Chen | ef99c4f | 2017-09-22 16:26:54 -0700 | [diff] [blame] | 858 | Status StatsService::systemRunning() { |
Jeff Sharkey | 6b64925 | 2018-04-16 09:50:22 -0600 | [diff] [blame] | 859 | ENFORCE_UID(AID_SYSTEM); |
Joe Onorato | 5dcbc6c | 2017-08-29 15:13:58 -0700 | [diff] [blame] | 860 | |
| 861 | // When system_server is up and running, schedule the dropbox task to run. |
yro | 74fed97 | 2017-11-27 14:42:42 -0800 | [diff] [blame] | 862 | VLOG("StatsService::systemRunning"); |
Bookatz | b487b55 | 2017-09-18 11:26:01 -0700 | [diff] [blame] | 863 | sayHiToStatsCompanion(); |
Joe Onorato | 5dcbc6c | 2017-08-29 15:13:58 -0700 | [diff] [blame] | 864 | return Status::ok(); |
| 865 | } |
| 866 | |
Yangster-mac | 892f3d3 | 2018-05-02 14:16:48 -0700 | [diff] [blame] | 867 | Status StatsService::informDeviceShutdown() { |
Jeff Sharkey | 6b64925 | 2018-04-16 09:50:22 -0600 | [diff] [blame] | 868 | ENFORCE_UID(AID_SYSTEM); |
Chenjie Yu | e36018b | 2018-04-16 15:18:30 -0700 | [diff] [blame] | 869 | VLOG("StatsService::informDeviceShutdown"); |
Yangster-mac | 892f3d3 | 2018-05-02 14:16:48 -0700 | [diff] [blame] | 870 | mProcessor->WriteDataToDisk(DEVICE_SHUTDOWN); |
Chenjie Yu | c7939cb | 2019-02-04 17:25:45 -0800 | [diff] [blame^] | 871 | mProcessor->WriteMetricsActivationToDisk(getElapsedRealtimeNs()); |
yro | 947fbce | 2017-11-15 22:50:23 -0800 | [diff] [blame] | 872 | return Status::ok(); |
| 873 | } |
| 874 | |
Yao Chen | ef99c4f | 2017-09-22 16:26:54 -0700 | [diff] [blame] | 875 | void StatsService::sayHiToStatsCompanion() { |
Bookatz | b487b55 | 2017-09-18 11:26:01 -0700 | [diff] [blame] | 876 | sp<IStatsCompanionService> statsCompanion = getStatsCompanionService(); |
| 877 | if (statsCompanion != nullptr) { |
yro | 74fed97 | 2017-11-27 14:42:42 -0800 | [diff] [blame] | 878 | VLOG("Telling statsCompanion that statsd is ready"); |
Bookatz | b487b55 | 2017-09-18 11:26:01 -0700 | [diff] [blame] | 879 | statsCompanion->statsdReady(); |
| 880 | } else { |
yro | 74fed97 | 2017-11-27 14:42:42 -0800 | [diff] [blame] | 881 | VLOG("Could not access statsCompanion"); |
Bookatz | b487b55 | 2017-09-18 11:26:01 -0700 | [diff] [blame] | 882 | } |
| 883 | } |
| 884 | |
Yao Chen | ef99c4f | 2017-09-22 16:26:54 -0700 | [diff] [blame] | 885 | Status StatsService::statsCompanionReady() { |
Jeff Sharkey | 6b64925 | 2018-04-16 09:50:22 -0600 | [diff] [blame] | 886 | ENFORCE_UID(AID_SYSTEM); |
| 887 | |
yro | 74fed97 | 2017-11-27 14:42:42 -0800 | [diff] [blame] | 888 | VLOG("StatsService::statsCompanionReady was called"); |
Bookatz | b487b55 | 2017-09-18 11:26:01 -0700 | [diff] [blame] | 889 | sp<IStatsCompanionService> statsCompanion = getStatsCompanionService(); |
| 890 | if (statsCompanion == nullptr) { |
Yao Chen | ef99c4f | 2017-09-22 16:26:54 -0700 | [diff] [blame] | 891 | return Status::fromExceptionCode( |
| 892 | Status::EX_NULL_POINTER, |
| 893 | "statscompanion unavailable despite it contacting statsd!"); |
Bookatz | b487b55 | 2017-09-18 11:26:01 -0700 | [diff] [blame] | 894 | } |
yro | 74fed97 | 2017-11-27 14:42:42 -0800 | [diff] [blame] | 895 | VLOG("StatsService::statsCompanionReady linking to statsCompanion."); |
Chenjie Yu | aa5b201 | 2018-03-21 13:53:15 -0700 | [diff] [blame] | 896 | IInterface::asBinder(statsCompanion)->linkToDeath(this); |
Chenjie Yu | e221920 | 2018-06-08 10:07:51 -0700 | [diff] [blame] | 897 | mPullerManager->SetStatsCompanionService(statsCompanion); |
Yangster-mac | 932ecec | 2018-02-01 10:23:52 -0800 | [diff] [blame] | 898 | mAnomalyAlarmMonitor->setStatsCompanionService(statsCompanion); |
| 899 | mPeriodicAlarmMonitor->setStatsCompanionService(statsCompanion); |
Bookatz | c697797 | 2018-01-16 16:55:05 -0800 | [diff] [blame] | 900 | SubscriberReporter::getInstance().setStatsCompanionService(statsCompanion); |
Bookatz | b487b55 | 2017-09-18 11:26:01 -0700 | [diff] [blame] | 901 | return Status::ok(); |
| 902 | } |
| 903 | |
Joe Onorato | 9fc9edf | 2017-10-15 20:08:52 -0700 | [diff] [blame] | 904 | void StatsService::Startup() { |
| 905 | mConfigManager->Startup(); |
Chenjie Yu | c7939cb | 2019-02-04 17:25:45 -0800 | [diff] [blame^] | 906 | mProcessor->LoadMetricsActivationFromDisk(); |
Bookatz | 906a35c | 2017-09-20 15:26:44 -0700 | [diff] [blame] | 907 | } |
| 908 | |
Yangster-mac | 97e7d20 | 2018-10-09 11:05:39 -0700 | [diff] [blame] | 909 | void StatsService::Terminate() { |
| 910 | ALOGI("StatsService::Terminating"); |
| 911 | if (mProcessor != nullptr) { |
| 912 | mProcessor->WriteDataToDisk(TERMINATION_SIGNAL_RECEIVED); |
| 913 | } |
| 914 | } |
| 915 | |
Yao Chen | 3ff3a49 | 2018-08-06 16:17:37 -0700 | [diff] [blame] | 916 | void StatsService::OnLogEvent(LogEvent* event) { |
| 917 | mProcessor->OnLogEvent(event); |
Yao Chen | a80e5c0 | 2018-09-04 13:55:29 -0700 | [diff] [blame] | 918 | if (mShellSubscriber != nullptr) { |
| 919 | mShellSubscriber->onLogEvent(*event); |
| 920 | } |
Bookatz | 906a35c | 2017-09-20 15:26:44 -0700 | [diff] [blame] | 921 | } |
| 922 | |
Jeff Sharkey | 6b64925 | 2018-04-16 09:50:22 -0600 | [diff] [blame] | 923 | Status StatsService::getData(int64_t key, const String16& packageName, vector<uint8_t>* output) { |
| 924 | ENFORCE_DUMP_AND_USAGE_STATS(packageName); |
| 925 | |
David Chen | adaf8b3 | 2017-11-03 15:42:08 -0700 | [diff] [blame] | 926 | IPCThreadState* ipc = IPCThreadState::self(); |
yro | 74fed97 | 2017-11-27 14:42:42 -0800 | [diff] [blame] | 927 | VLOG("StatsService::getData with Pid %i, Uid %i", ipc->getCallingPid(), ipc->getCallingUid()); |
Bookatz | 4f71629 | 2018-04-10 17:15:12 -0700 | [diff] [blame] | 928 | ConfigKey configKey(ipc->getCallingUid(), key); |
David Chen | 56ae0d9 | 2018-05-11 16:00:22 -0700 | [diff] [blame] | 929 | mProcessor->onDumpReport(configKey, getElapsedRealtimeNs(), false /* include_current_bucket*/, |
Bookatz | ff71cad | 2018-09-20 17:17:49 -0700 | [diff] [blame] | 930 | true /* erase_data */, GET_DATA_CALLED, output); |
Bookatz | 4f71629 | 2018-04-10 17:15:12 -0700 | [diff] [blame] | 931 | return Status::ok(); |
yro | 31eb67b | 2017-10-24 13:33:21 -0700 | [diff] [blame] | 932 | } |
| 933 | |
Jeff Sharkey | 6b64925 | 2018-04-16 09:50:22 -0600 | [diff] [blame] | 934 | Status StatsService::getMetadata(const String16& packageName, vector<uint8_t>* output) { |
| 935 | ENFORCE_DUMP_AND_USAGE_STATS(packageName); |
| 936 | |
David Chen | 2e8f380 | 2017-11-22 10:56:48 -0800 | [diff] [blame] | 937 | IPCThreadState* ipc = IPCThreadState::self(); |
| 938 | VLOG("StatsService::getMetadata with Pid %i, Uid %i", ipc->getCallingPid(), |
| 939 | ipc->getCallingUid()); |
Bookatz | 4f71629 | 2018-04-10 17:15:12 -0700 | [diff] [blame] | 940 | StatsdStats::getInstance().dumpStats(output, false); // Don't reset the counters. |
| 941 | return Status::ok(); |
David Chen | 2e8f380 | 2017-11-22 10:56:48 -0800 | [diff] [blame] | 942 | } |
| 943 | |
Jeff Sharkey | 6b64925 | 2018-04-16 09:50:22 -0600 | [diff] [blame] | 944 | Status StatsService::addConfiguration(int64_t key, const vector <uint8_t>& config, |
| 945 | const String16& packageName) { |
| 946 | ENFORCE_DUMP_AND_USAGE_STATS(packageName); |
| 947 | |
David Chen | adaf8b3 | 2017-11-03 15:42:08 -0700 | [diff] [blame] | 948 | IPCThreadState* ipc = IPCThreadState::self(); |
Bookatz | 4f71629 | 2018-04-10 17:15:12 -0700 | [diff] [blame] | 949 | if (addConfigurationChecked(ipc->getCallingUid(), key, config)) { |
David Chen | 661f791 | 2018-01-22 17:46:24 -0800 | [diff] [blame] | 950 | return Status::ok(); |
| 951 | } else { |
Bookatz | 4f71629 | 2018-04-10 17:15:12 -0700 | [diff] [blame] | 952 | ALOGE("Could not parse malformatted StatsdConfig"); |
| 953 | return Status::fromExceptionCode(binder::Status::EX_ILLEGAL_ARGUMENT, |
| 954 | "config does not correspond to a StatsdConfig proto"); |
David Chen | 661f791 | 2018-01-22 17:46:24 -0800 | [diff] [blame] | 955 | } |
| 956 | } |
| 957 | |
David Chen | 9fdd403 | 2018-03-20 14:38:56 -0700 | [diff] [blame] | 958 | bool StatsService::addConfigurationChecked(int uid, int64_t key, const vector<uint8_t>& config) { |
| 959 | ConfigKey configKey(uid, key); |
| 960 | StatsdConfig cfg; |
| 961 | if (config.size() > 0) { // If the config is empty, skip parsing. |
| 962 | if (!cfg.ParseFromArray(&config[0], config.size())) { |
| 963 | return false; |
| 964 | } |
| 965 | } |
| 966 | mConfigManager->UpdateConfig(configKey, cfg); |
| 967 | return true; |
| 968 | } |
| 969 | |
Jeff Sharkey | 6b64925 | 2018-04-16 09:50:22 -0600 | [diff] [blame] | 970 | Status StatsService::removeDataFetchOperation(int64_t key, const String16& packageName) { |
| 971 | ENFORCE_DUMP_AND_USAGE_STATS(packageName); |
| 972 | |
Bookatz | 4f71629 | 2018-04-10 17:15:12 -0700 | [diff] [blame] | 973 | IPCThreadState* ipc = IPCThreadState::self(); |
| 974 | ConfigKey configKey(ipc->getCallingUid(), key); |
| 975 | mConfigManager->RemoveConfigReceiver(configKey); |
| 976 | return Status::ok(); |
David Chen | 661f791 | 2018-01-22 17:46:24 -0800 | [diff] [blame] | 977 | } |
| 978 | |
Jeff Sharkey | 6b64925 | 2018-04-16 09:50:22 -0600 | [diff] [blame] | 979 | Status StatsService::setDataFetchOperation(int64_t key, |
| 980 | const sp<android::IBinder>& intentSender, |
| 981 | const String16& packageName) { |
| 982 | ENFORCE_DUMP_AND_USAGE_STATS(packageName); |
| 983 | |
Bookatz | 4f71629 | 2018-04-10 17:15:12 -0700 | [diff] [blame] | 984 | IPCThreadState* ipc = IPCThreadState::self(); |
| 985 | ConfigKey configKey(ipc->getCallingUid(), key); |
| 986 | mConfigManager->SetConfigReceiver(configKey, intentSender); |
David Chen | 4894490 | 2018-05-03 10:29:11 -0700 | [diff] [blame] | 987 | if (StorageManager::hasConfigMetricsReport(configKey)) { |
| 988 | VLOG("StatsService::setDataFetchOperation marking configKey %s to dump reports on disk", |
| 989 | configKey.ToString().c_str()); |
| 990 | mProcessor->noteOnDiskData(configKey); |
| 991 | } |
Bookatz | 4f71629 | 2018-04-10 17:15:12 -0700 | [diff] [blame] | 992 | return Status::ok(); |
yro | 31eb67b | 2017-10-24 13:33:21 -0700 | [diff] [blame] | 993 | } |
| 994 | |
Tej Singh | 2c9ef2a | 2019-01-22 11:33:51 -0800 | [diff] [blame] | 995 | Status StatsService::setActiveConfigsChangedOperation(const sp<android::IBinder>& intentSender, |
| 996 | const String16& packageName, |
| 997 | vector<int64_t>* output) { |
| 998 | ENFORCE_DUMP_AND_USAGE_STATS(packageName); |
| 999 | |
| 1000 | IPCThreadState* ipc = IPCThreadState::self(); |
| 1001 | mConfigManager->SetActiveConfigsChangedReceiver(ipc->getCallingUid(), intentSender); |
| 1002 | //TODO: Return the list of configs that are already active |
| 1003 | return Status::ok(); |
| 1004 | } |
| 1005 | |
| 1006 | Status StatsService::removeActiveConfigsChangedOperation(const String16& packageName) { |
| 1007 | ENFORCE_DUMP_AND_USAGE_STATS(packageName); |
| 1008 | |
| 1009 | IPCThreadState* ipc = IPCThreadState::self(); |
| 1010 | mConfigManager->RemoveActiveConfigsChangedReceiver(ipc->getCallingUid()); |
| 1011 | return Status::ok(); |
| 1012 | } |
| 1013 | |
Jeff Sharkey | 6b64925 | 2018-04-16 09:50:22 -0600 | [diff] [blame] | 1014 | Status StatsService::removeConfiguration(int64_t key, const String16& packageName) { |
| 1015 | ENFORCE_DUMP_AND_USAGE_STATS(packageName); |
| 1016 | |
Bookatz | 4f71629 | 2018-04-10 17:15:12 -0700 | [diff] [blame] | 1017 | IPCThreadState* ipc = IPCThreadState::self(); |
| 1018 | ConfigKey configKey(ipc->getCallingUid(), key); |
| 1019 | mConfigManager->RemoveConfig(configKey); |
| 1020 | SubscriberReporter::getInstance().removeConfig(configKey); |
| 1021 | return Status::ok(); |
yro | 31eb67b | 2017-10-24 13:33:21 -0700 | [diff] [blame] | 1022 | } |
| 1023 | |
Bookatz | c697797 | 2018-01-16 16:55:05 -0800 | [diff] [blame] | 1024 | Status StatsService::setBroadcastSubscriber(int64_t configId, |
| 1025 | int64_t subscriberId, |
Jeff Sharkey | 6b64925 | 2018-04-16 09:50:22 -0600 | [diff] [blame] | 1026 | const sp<android::IBinder>& intentSender, |
| 1027 | const String16& packageName) { |
| 1028 | ENFORCE_DUMP_AND_USAGE_STATS(packageName); |
| 1029 | |
Bookatz | c697797 | 2018-01-16 16:55:05 -0800 | [diff] [blame] | 1030 | VLOG("StatsService::setBroadcastSubscriber called."); |
Bookatz | 4f71629 | 2018-04-10 17:15:12 -0700 | [diff] [blame] | 1031 | IPCThreadState* ipc = IPCThreadState::self(); |
| 1032 | ConfigKey configKey(ipc->getCallingUid(), configId); |
| 1033 | SubscriberReporter::getInstance() |
| 1034 | .setBroadcastSubscriber(configKey, subscriberId, intentSender); |
| 1035 | return Status::ok(); |
Bookatz | c697797 | 2018-01-16 16:55:05 -0800 | [diff] [blame] | 1036 | } |
| 1037 | |
| 1038 | Status StatsService::unsetBroadcastSubscriber(int64_t configId, |
Jeff Sharkey | 6b64925 | 2018-04-16 09:50:22 -0600 | [diff] [blame] | 1039 | int64_t subscriberId, |
| 1040 | const String16& packageName) { |
| 1041 | ENFORCE_DUMP_AND_USAGE_STATS(packageName); |
| 1042 | |
Bookatz | c697797 | 2018-01-16 16:55:05 -0800 | [diff] [blame] | 1043 | VLOG("StatsService::unsetBroadcastSubscriber called."); |
Bookatz | 4f71629 | 2018-04-10 17:15:12 -0700 | [diff] [blame] | 1044 | IPCThreadState* ipc = IPCThreadState::self(); |
| 1045 | ConfigKey configKey(ipc->getCallingUid(), configId); |
| 1046 | SubscriberReporter::getInstance() |
| 1047 | .unsetBroadcastSubscriber(configKey, subscriberId); |
| 1048 | return Status::ok(); |
Bookatz | c697797 | 2018-01-16 16:55:05 -0800 | [diff] [blame] | 1049 | } |
| 1050 | |
yro | be6d7f9 | 2018-05-04 13:02:53 -0700 | [diff] [blame] | 1051 | Status StatsService::sendAppBreadcrumbAtom(int32_t label, int32_t state) { |
| 1052 | // Permission check not necessary as it's meant for applications to write to |
| 1053 | // statsd. |
| 1054 | android::util::stats_write(util::APP_BREADCRUMB_REPORTED, |
| 1055 | IPCThreadState::self()->getCallingUid(), label, |
| 1056 | state); |
| 1057 | return Status::ok(); |
| 1058 | } |
| 1059 | |
Howard Ro | a46b658 | 2018-09-18 16:45:02 -0700 | [diff] [blame] | 1060 | hardware::Return<void> StatsService::reportSpeakerImpedance( |
| 1061 | const SpeakerImpedance& speakerImpedance) { |
| 1062 | LogEvent event(getWallClockSec() * NS_PER_SEC, getElapsedRealtimeNs(), speakerImpedance); |
| 1063 | mProcessor->OnLogEvent(&event); |
| 1064 | |
| 1065 | return hardware::Void(); |
| 1066 | } |
| 1067 | |
| 1068 | hardware::Return<void> StatsService::reportHardwareFailed(const HardwareFailed& hardwareFailed) { |
| 1069 | LogEvent event(getWallClockSec() * NS_PER_SEC, getElapsedRealtimeNs(), hardwareFailed); |
| 1070 | mProcessor->OnLogEvent(&event); |
| 1071 | |
| 1072 | return hardware::Void(); |
| 1073 | } |
| 1074 | |
| 1075 | hardware::Return<void> StatsService::reportPhysicalDropDetected( |
| 1076 | const PhysicalDropDetected& physicalDropDetected) { |
| 1077 | LogEvent event(getWallClockSec() * NS_PER_SEC, getElapsedRealtimeNs(), physicalDropDetected); |
| 1078 | mProcessor->OnLogEvent(&event); |
| 1079 | |
| 1080 | return hardware::Void(); |
| 1081 | } |
| 1082 | |
| 1083 | hardware::Return<void> StatsService::reportChargeCycles(const ChargeCycles& chargeCycles) { |
| 1084 | LogEvent event(getWallClockSec() * NS_PER_SEC, getElapsedRealtimeNs(), chargeCycles); |
| 1085 | mProcessor->OnLogEvent(&event); |
| 1086 | |
| 1087 | return hardware::Void(); |
| 1088 | } |
| 1089 | |
| 1090 | hardware::Return<void> StatsService::reportBatteryHealthSnapshot( |
| 1091 | const BatteryHealthSnapshotArgs& batteryHealthSnapshotArgs) { |
| 1092 | LogEvent event(getWallClockSec() * NS_PER_SEC, getElapsedRealtimeNs(), |
| 1093 | batteryHealthSnapshotArgs); |
| 1094 | mProcessor->OnLogEvent(&event); |
| 1095 | |
| 1096 | return hardware::Void(); |
| 1097 | } |
| 1098 | |
| 1099 | hardware::Return<void> StatsService::reportSlowIo(const SlowIo& slowIo) { |
| 1100 | LogEvent event(getWallClockSec() * NS_PER_SEC, getElapsedRealtimeNs(), slowIo); |
| 1101 | mProcessor->OnLogEvent(&event); |
| 1102 | |
| 1103 | return hardware::Void(); |
| 1104 | } |
| 1105 | |
| 1106 | hardware::Return<void> StatsService::reportBatteryCausedShutdown( |
| 1107 | const BatteryCausedShutdown& batteryCausedShutdown) { |
| 1108 | LogEvent event(getWallClockSec() * NS_PER_SEC, getElapsedRealtimeNs(), batteryCausedShutdown); |
| 1109 | mProcessor->OnLogEvent(&event); |
| 1110 | |
| 1111 | return hardware::Void(); |
| 1112 | } |
| 1113 | |
Maggie White | fc1aa59 | 2018-11-28 21:55:23 -0800 | [diff] [blame] | 1114 | hardware::Return<void> StatsService::reportUsbPortOverheatEvent( |
| 1115 | const UsbPortOverheatEvent& usbPortOverheatEvent) { |
| 1116 | LogEvent event(getWallClockSec() * NS_PER_SEC, getElapsedRealtimeNs(), usbPortOverheatEvent); |
| 1117 | mProcessor->OnLogEvent(&event); |
| 1118 | |
| 1119 | return hardware::Void(); |
| 1120 | } |
| 1121 | |
Carter Hsu | b8fd1e9 | 2019-01-11 15:24:45 +0800 | [diff] [blame] | 1122 | hardware::Return<void> StatsService::reportSpeechDspStat( |
| 1123 | const SpeechDspStat& speechDspStat) { |
| 1124 | LogEvent event(getWallClockSec() * NS_PER_SEC, getElapsedRealtimeNs(), speechDspStat); |
| 1125 | mProcessor->OnLogEvent(&event); |
| 1126 | |
| 1127 | return hardware::Void(); |
| 1128 | } |
| 1129 | |
Maggie White | 58174da | 2019-01-18 15:23:35 -0800 | [diff] [blame] | 1130 | hardware::Return<void> StatsService::reportVendorAtom(const VendorAtom& vendorAtom) { |
| 1131 | std::string reverseDomainName = (std::string) vendorAtom.reverseDomainName; |
| 1132 | if (vendorAtom.atomId < 100000 || vendorAtom.atomId >= 200000) { |
| 1133 | ALOGE("Atom ID %ld is not a valid vendor atom ID", (long) vendorAtom.atomId); |
| 1134 | return hardware::Void(); |
| 1135 | } |
| 1136 | if (reverseDomainName.length() > 50) { |
| 1137 | ALOGE("Vendor atom reverse domain name %s is too long.", reverseDomainName.c_str()); |
| 1138 | return hardware::Void(); |
| 1139 | } |
| 1140 | LogEvent event(getWallClockSec() * NS_PER_SEC, getElapsedRealtimeNs(), vendorAtom); |
| 1141 | mProcessor->OnLogEvent(&event); |
| 1142 | |
| 1143 | return hardware::Void(); |
| 1144 | } |
| 1145 | |
David Chen | 1d7b0cd | 2017-11-15 14:20:04 -0800 | [diff] [blame] | 1146 | void StatsService::binderDied(const wp <IBinder>& who) { |
Chenjie Yu | aa5b201 | 2018-03-21 13:53:15 -0700 | [diff] [blame] | 1147 | ALOGW("statscompanion service died"); |
Yangster-mac | 892f3d3 | 2018-05-02 14:16:48 -0700 | [diff] [blame] | 1148 | StatsdStats::getInstance().noteSystemServerRestart(getWallClockSec()); |
| 1149 | if (mProcessor != nullptr) { |
Howard Ro | e60992b | 2018-08-30 14:37:29 -0700 | [diff] [blame] | 1150 | ALOGW("Reset statsd upon system server restarts."); |
Yangster-mac | 892f3d3 | 2018-05-02 14:16:48 -0700 | [diff] [blame] | 1151 | mProcessor->WriteDataToDisk(STATSCOMPANION_DIED); |
| 1152 | mProcessor->resetConfigs(); |
| 1153 | } |
Chenjie Yu | aa5b201 | 2018-03-21 13:53:15 -0700 | [diff] [blame] | 1154 | mAnomalyAlarmMonitor->setStatsCompanionService(nullptr); |
| 1155 | mPeriodicAlarmMonitor->setStatsCompanionService(nullptr); |
| 1156 | SubscriberReporter::getInstance().setStatsCompanionService(nullptr); |
Chenjie Yu | e221920 | 2018-06-08 10:07:51 -0700 | [diff] [blame] | 1157 | mPullerManager->SetStatsCompanionService(nullptr); |
yro | 31eb67b | 2017-10-24 13:33:21 -0700 | [diff] [blame] | 1158 | } |
| 1159 | |
Yao Chen | ef99c4f | 2017-09-22 16:26:54 -0700 | [diff] [blame] | 1160 | } // namespace statsd |
| 1161 | } // namespace os |
| 1162 | } // namespace android |