summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author TreeHugger Robot <treehugger-gerrit@google.com> 2017-09-21 01:45:20 +0000
committer Android (Google) Code Review <android-gerrit@google.com> 2017-09-21 01:45:20 +0000
commit5a993e9fb071e29892bd86c0e32bdd25f8bd6e3c (patch)
tree5c065441a1dfb184a851ca2c01ecaef35ee8d73a
parente98252d2d79759bcd4c84cf0ac0ab614eb78434a (diff)
parent906a35c814817c8bd503c3f4df8af9a2f622169d (diff)
Merge "Statsd namespace is defined and used"
-rw-r--r--cmds/statsd/src/AnomalyMonitor.cpp10
-rw-r--r--cmds/statsd/src/AnomalyMonitor.h3
-rw-r--r--cmds/statsd/src/DropboxReader.cpp9
-rw-r--r--cmds/statsd/src/DropboxReader.h9
-rw-r--r--cmds/statsd/src/DropboxWriter.cpp10
-rw-r--r--cmds/statsd/src/DropboxWriter.h9
-rw-r--r--cmds/statsd/src/LogEntryPrinter.cpp8
-rw-r--r--cmds/statsd/src/LogEntryPrinter.h8
-rw-r--r--cmds/statsd/src/LogReader.cpp7
-rw-r--r--cmds/statsd/src/LogReader.h9
-rw-r--r--cmds/statsd/src/StatsLogProcessor.cpp10
-rw-r--r--cmds/statsd/src/StatsLogProcessor.h9
-rw-r--r--cmds/statsd/src/StatsService.cpp78
-rw-r--r--cmds/statsd/src/StatsService.h15
-rw-r--r--cmds/statsd/src/main.cpp1
15 files changed, 142 insertions, 53 deletions
diff --git a/cmds/statsd/src/AnomalyMonitor.cpp b/cmds/statsd/src/AnomalyMonitor.cpp
index 8fd52499b204..2d3454a831f9 100644
--- a/cmds/statsd/src/AnomalyMonitor.cpp
+++ b/cmds/statsd/src/AnomalyMonitor.cpp
@@ -17,11 +17,13 @@
#define LOG_TAG "AnomalyMonitor"
#define DEBUG true
-#include <AnomalyMonitor.h>
+#include "AnomalyMonitor.h"
#include <cutils/log.h>
-using namespace android::os::statsd;
+namespace android {
+namespace os {
+namespace statsd {
AnomalyMonitor::AnomalyMonitor(uint32_t minDiffToUpdateRegisteredAlarmTimeSec)
: mRegisteredAlarmTimeSec(0),
@@ -100,3 +102,7 @@ void AnomalyMonitor::updateRegisteredAlarmTime_l(uint32_t timestampSec) {
int64_t AnomalyMonitor::secToMs(uint32_t timeSec) {
return ((int64_t) timeSec) * 1000;
}
+
+} // namespace statsd
+} // namespace os
+} // namespace android
diff --git a/cmds/statsd/src/AnomalyMonitor.h b/cmds/statsd/src/AnomalyMonitor.h
index 3ee5354b8542..e89afa8a6497 100644
--- a/cmds/statsd/src/AnomalyMonitor.h
+++ b/cmds/statsd/src/AnomalyMonitor.h
@@ -25,7 +25,8 @@
#include <vector>
using namespace android;
-using namespace android::os;
+
+using android::os::IStatsCompanionService;
namespace android {
namespace os {
diff --git a/cmds/statsd/src/DropboxReader.cpp b/cmds/statsd/src/DropboxReader.cpp
index cda2f431e435..307e7712e5aa 100644
--- a/cmds/statsd/src/DropboxReader.cpp
+++ b/cmds/statsd/src/DropboxReader.cpp
@@ -23,11 +23,14 @@ using android::sp;
using android::String16;
using android::binder::Status;
using android::base::unique_fd;
-using android::os::statsd::EventMetricData;
using android::os::DropBoxManager;
using android::ZipUtils;
using std::vector;
+namespace android {
+namespace os {
+namespace statsd {
+
status_t DropboxReader::readStatsLogs(FILE* out, const string& tag, long msec) {
sp<DropBoxManager> dropbox = new DropBoxManager();
StatsLogReport logReport;
@@ -117,3 +120,7 @@ void DropboxReader::printLog(FILE* out, const StatsLogReport& logReport) {
}
fprintf(out, "\n");
}
+
+} // namespace statsd
+} // namespace os
+} // namespace android
diff --git a/cmds/statsd/src/DropboxReader.h b/cmds/statsd/src/DropboxReader.h
index f7d5a8205f57..b7f8739c9ad6 100644
--- a/cmds/statsd/src/DropboxReader.h
+++ b/cmds/statsd/src/DropboxReader.h
@@ -23,10 +23,13 @@
#include <stdio.h>
using android::base::unique_fd;
-using android::os::statsd::StatsLogReport;
using android::status_t;
using std::string;
+namespace android {
+namespace os {
+namespace statsd {
+
class DropboxReader {
public:
// msec is the start timestamp.
@@ -42,4 +45,8 @@ private:
};
};
+} // namespace statsd
+} // namespace os
+} // namespace android
+
#endif //DROPBOX_READER_H
diff --git a/cmds/statsd/src/DropboxWriter.cpp b/cmds/statsd/src/DropboxWriter.cpp
index 01a9eac317d8..b9d48fa362d5 100644
--- a/cmds/statsd/src/DropboxWriter.cpp
+++ b/cmds/statsd/src/DropboxWriter.cpp
@@ -18,12 +18,16 @@
#include "DropboxWriter.h"
-using android::os::DropBoxManager;
using android::binder::Status;
+using android::os::DropBoxManager;
using android::sp;
using android::String16;
using std::vector;
+namespace android {
+namespace os {
+namespace statsd {
+
DropboxWriter::DropboxWriter(const string& tag)
: mTag(tag), mLogReport(), mBufferSize(0) {
}
@@ -57,3 +61,7 @@ void DropboxWriter::flush() {
mLogReport.Clear();
mBufferSize = 0;
}
+
+} // namespace statsd
+} // namespace os
+} // namespace android
diff --git a/cmds/statsd/src/DropboxWriter.h b/cmds/statsd/src/DropboxWriter.h
index 31b3f2764bb9..59629fb65b22 100644
--- a/cmds/statsd/src/DropboxWriter.h
+++ b/cmds/statsd/src/DropboxWriter.h
@@ -20,7 +20,10 @@
#include <frameworks/base/cmds/statsd/src/stats_log.pb.h>
using std::string;
-using android::os::statsd::StatsLogReport;
+
+namespace android {
+namespace os {
+namespace statsd {
class DropboxWriter {
public:
@@ -62,4 +65,8 @@ private:
};
+} // namespace statsd
+} // namespace os
+} // namespace android
+
#endif //DROPBOX_WRITER_H
diff --git a/cmds/statsd/src/LogEntryPrinter.cpp b/cmds/statsd/src/LogEntryPrinter.cpp
index ba07308086ca..c877b0545795 100644
--- a/cmds/statsd/src/LogEntryPrinter.cpp
+++ b/cmds/statsd/src/LogEntryPrinter.cpp
@@ -22,6 +22,10 @@
using namespace android;
+namespace android {
+namespace os {
+namespace statsd {
+
LogEntryPrinter::LogEntryPrinter(int out)
:m_out(out)
{
@@ -59,3 +63,7 @@ LogEntryPrinter::OnLogEvent(const log_msg& msg)
}
}
+} // namespace statsd
+} // namespace os
+} // namespace android
+
diff --git a/cmds/statsd/src/LogEntryPrinter.h b/cmds/statsd/src/LogEntryPrinter.h
index 61ffddca0916..ed720dcd17ac 100644
--- a/cmds/statsd/src/LogEntryPrinter.h
+++ b/cmds/statsd/src/LogEntryPrinter.h
@@ -23,6 +23,10 @@
#include <stdio.h>
+namespace android {
+namespace os {
+namespace statsd {
+
/**
* Decodes the log entry and prints it to the supplied file descriptor.
*/
@@ -51,4 +55,8 @@ private:
AndroidLogFormat* m_format;
};
+} // namespace statsd
+} // namespace os
+} // namespace android
+
#endif // LOG_ENTRY_PRINTER_H
diff --git a/cmds/statsd/src/LogReader.cpp b/cmds/statsd/src/LogReader.cpp
index 2a9e5005499c..c9164f914cd2 100644
--- a/cmds/statsd/src/LogReader.cpp
+++ b/cmds/statsd/src/LogReader.cpp
@@ -26,6 +26,10 @@
using namespace android;
using namespace std;
+namespace android {
+namespace os {
+namespace statsd {
+
#define SNOOZE_INITIAL_MS 100
#define SNOOZE_MAX_MS (10 * 60 * 1000) // Ten minutes
@@ -141,3 +145,6 @@ LogReader::connect_and_read()
return lineCount;
}
+} // namespace statsd
+} // namespace os
+} // namespace android
diff --git a/cmds/statsd/src/LogReader.h b/cmds/statsd/src/LogReader.h
index 08a17a31aa18..4c2afe8ba43f 100644
--- a/cmds/statsd/src/LogReader.h
+++ b/cmds/statsd/src/LogReader.h
@@ -18,11 +18,14 @@
#define LOGREADER_H
#include <log/log_read.h>
-
#include <utils/RefBase.h>
#include <vector>
+namespace android {
+namespace os {
+namespace statsd {
+
/**
* Callback for LogReader
*/
@@ -78,4 +81,8 @@ private:
int connect_and_read();
};
+} // namespace statsd
+} // namespace os
+} // namespace android
+
#endif // LOGREADER_H
diff --git a/cmds/statsd/src/StatsLogProcessor.cpp b/cmds/statsd/src/StatsLogProcessor.cpp
index c2fffd8a2d84..1ae23ef8af13 100644
--- a/cmds/statsd/src/StatsLogProcessor.cpp
+++ b/cmds/statsd/src/StatsLogProcessor.cpp
@@ -21,8 +21,10 @@
#include <parse_util.h>
using namespace android;
-using android::os::statsd::EventMetricData;
-using android::os::statsd::StatsLogReport;
+
+namespace android {
+namespace os {
+namespace statsd {
StatsLogProcessor::StatsLogProcessor() : m_dropbox_writer("all-logs")
{
@@ -71,3 +73,7 @@ StatsLogProcessor::UpdateConfig(const int config_source, StatsdConfig config)
m_configs[config_source] = config;
ALOGD("Updated configuration for source %i", config_source);
}
+
+} // namespace statsd
+} // namespace os
+} // namespace android
diff --git a/cmds/statsd/src/StatsLogProcessor.h b/cmds/statsd/src/StatsLogProcessor.h
index 5df84245a406..a6d182cac47a 100644
--- a/cmds/statsd/src/StatsLogProcessor.h
+++ b/cmds/statsd/src/StatsLogProcessor.h
@@ -20,7 +20,9 @@
#include <unordered_map>
-using android::os::statsd::StatsdConfig;
+namespace android {
+namespace os {
+namespace statsd {
class StatsLogProcessor : public LogListener
{
@@ -51,4 +53,9 @@ private:
*/
std::unordered_map<int, StatsdConfig> m_configs;
};
+
+} // namespace statsd
+} // namespace os
+} // namespace android
+
#endif //STATS_LOG_PROCESSOR_H
diff --git a/cmds/statsd/src/StatsService.cpp b/cmds/statsd/src/StatsService.cpp
index 976fc26a2b8c..965c9b7192de 100644
--- a/cmds/statsd/src/StatsService.cpp
+++ b/cmds/statsd/src/StatsService.cpp
@@ -34,9 +34,11 @@
#include <stdlib.h>
using namespace android;
-using android::os::statsd::StatsdConfig;
-// ================================================================================
+namespace android {
+namespace os {
+namespace statsd {
+
StatsService::StatsService(const sp<Looper>& handlerLooper)
: mAnomalyMonitor(new AnomalyMonitor(2)) // TODO: Change this based on the config
{
@@ -211,23 +213,6 @@ StatsService::systemRunning()
return Status::ok();
}
-status_t
-StatsService::doPrintStatsLog(FILE* out, const Vector<String8>& args) {
- long msec = 0;
-
- if (args.size() > 2) {
- msec = strtol(args[2].string(), NULL, 10);
- }
- return DropboxReader::readStatsLogs(out, args[1].string(), msec);
-}
-
-void
-StatsService::printCmdHelp(FILE* out) {
- fprintf(out, "Usage:\n");
- fprintf(out, "\t print-stats-log [tag_required] [timestamp_nsec_optional]\n");
- fprintf(out, "\t config\t Loads a new config from command-line (must be proto in wire-encoded format).\n");
-}
-
void
StatsService::sayHiToStatsCompanion()
{
@@ -241,6 +226,22 @@ StatsService::sayHiToStatsCompanion()
}
}
+sp<IStatsCompanionService>
+StatsService::getStatsCompanionService() {
+ sp<IStatsCompanionService> statsCompanion = nullptr;
+ // Get statscompanion service from service manager
+ const sp<IServiceManager> sm(defaultServiceManager());
+ if (sm != nullptr) {
+ const String16 name("statscompanion");
+ statsCompanion = interface_cast<IStatsCompanionService>(sm->checkService(name));
+ if (statsCompanion == nullptr) {
+ ALOGW("statscompanion service unavailable!");
+ return nullptr;
+ }
+ }
+ return statsCompanion;
+}
+
Status
StatsService::statsCompanionReady()
{
@@ -263,24 +264,29 @@ StatsService::statsCompanionReady()
return Status::ok();
}
-sp<IStatsCompanionService>
-StatsService::getStatsCompanionService() {
- sp<IStatsCompanionService> statsCompanion = nullptr;
- // Get statscompanion service from service manager
- const sp<IServiceManager> sm(defaultServiceManager());
- if (sm != nullptr) {
- const String16 name("statscompanion");
- statsCompanion = interface_cast<IStatsCompanionService>(sm->checkService(name));
- if (statsCompanion == nullptr) {
- ALOGW("statscompanion service unavailable!");
- return nullptr;
- }
- }
- return statsCompanion;
-}
-
void
StatsdDeathRecipient::binderDied(const wp<IBinder>& who) {
ALOGW("statscompanion service died");
mAnmlyMntr->setStatsCompanionService(nullptr);
-} \ No newline at end of file
+}
+
+status_t
+StatsService::doPrintStatsLog(FILE* out, const Vector<String8>& args) {
+ long msec = 0;
+
+ if (args.size() > 2) {
+ msec = strtol(args[2].string(), NULL, 10);
+ }
+ return DropboxReader::readStatsLogs(out, args[1].string(), msec);
+}
+
+void
+StatsService::printCmdHelp(FILE* out) {
+ fprintf(out, "Usage:\n");
+ fprintf(out, "\t print-stats-log [tag_required] [timestamp_nsec_optional]\n");
+ fprintf(out, "\t config\t Loads a new config from command-line (must be proto in wire-encoded format).\n");
+}
+
+} // namespace statsd
+} // namespace os
+} // namespace android
diff --git a/cmds/statsd/src/StatsService.h b/cmds/statsd/src/StatsService.h
index 467c2bda8f9f..57276d2425e9 100644
--- a/cmds/statsd/src/StatsService.h
+++ b/cmds/statsd/src/StatsService.h
@@ -34,12 +34,12 @@ using namespace android;
using namespace android::base;
using namespace android::binder;
using namespace android::os;
-using namespace android::os::statsd;
using namespace std;
-using android::os::statsd::StatsdConfig;
+namespace android {
+namespace os {
+namespace statsd {
-// ================================================================================
class StatsService : public BnStatsManager {
public:
StatsService(const sp<Looper>& handlerLooper);
@@ -69,15 +69,14 @@ public:
private:
sp<StatsLogProcessor> m_processor; // Reference to the processor for updating configs.
+ const sp<AnomalyMonitor> mAnomalyMonitor; // TODO: Move this to a more logical file/class
+
status_t doPrintStatsLog(FILE* out, const Vector<String8>& args);
void printCmdHelp(FILE* out);
status_t doLoadConfig(FILE* in);
- const sp<AnomalyMonitor> mAnomalyMonitor; // TODO: Move this to a more logical file/class
-
- private:
/** Fetches the StatsCompanionService. */
sp<IStatsCompanionService> getStatsCompanionService();
};
@@ -95,4 +94,8 @@ private:
const sp<AnomalyMonitor> mAnmlyMntr;
};
+} // namespace statsd
+} // namespace os
+} // namespace android
+
#endif // STATS_SERVICE_H
diff --git a/cmds/statsd/src/main.cpp b/cmds/statsd/src/main.cpp
index 161b6304ea80..c1dad4f1ed3f 100644
--- a/cmds/statsd/src/main.cpp
+++ b/cmds/statsd/src/main.cpp
@@ -36,6 +36,7 @@
#include <unistd.h>
using namespace android;
+using namespace android::os::statsd;
// ================================================================================
/**