clang-format existing code in statsd.

Added .clang-format, because there isn't an official .clang-format file for Android framework code.

before we upload changes, do:

clang-format -style=file -i [file list]

to format the files that you touched.

Test: formatting only. NO code changes.
Change-Id: I90e87f1ee6618da8ea9bc2221c609c415a4046a8
diff --git a/cmds/statsd/src/StatsService.cpp b/cmds/statsd/src/StatsService.cpp
index 965c9b7..a28f085 100644
--- a/cmds/statsd/src/StatsService.cpp
+++ b/cmds/statsd/src/StatsService.cpp
@@ -29,9 +29,9 @@
 #include <utils/Looper.h>
 #include <utils/String16.h>
 
-#include <unistd.h>
 #include <stdio.h>
 #include <stdlib.h>
+#include <unistd.h>
 
 using namespace android;
 
@@ -40,17 +40,15 @@
 namespace statsd {
 
 StatsService::StatsService(const sp<Looper>& handlerLooper)
-        : mAnomalyMonitor(new AnomalyMonitor(2)) // TODO: Change this based on the config
+    : mAnomalyMonitor(new AnomalyMonitor(2))  // TODO: Change this based on the config
 {
     ALOGD("stats service constructed");
 }
 
-StatsService::~StatsService()
-{
+StatsService::~StatsService() {
 }
 
-status_t
-StatsService::setProcessor(const sp<StatsLogProcessor>& main_processor) {
+status_t StatsService::setProcessor(const sp<StatsLogProcessor>& main_processor) {
     m_processor = main_processor;
     ALOGD("stats service set to processor %p", m_processor.get());
     return NO_ERROR;
@@ -58,9 +56,8 @@
 
 // Implement our own because the default binder implementation isn't
 // properly handling SHELL_COMMAND_TRANSACTION
-status_t
-StatsService::onTransact(uint32_t code, const Parcel& data, Parcel* reply, uint32_t flags)
-{
+status_t StatsService::onTransact(uint32_t code, const Parcel& data, Parcel* reply,
+                                  uint32_t flags) {
     status_t err;
 
     switch (code) {
@@ -73,10 +70,9 @@
             for (int i = 0; i < argc && data.dataAvail() > 0; i++) {
                 args.add(String8(data.readString16()));
             }
-            sp<IShellCallback> shellCallback = IShellCallback::asInterface(
-                    data.readStrongBinder());
-            sp<IResultReceiver> resultReceiver = IResultReceiver::asInterface(
-                    data.readStrongBinder());
+            sp<IShellCallback> shellCallback = IShellCallback::asInterface(data.readStrongBinder());
+            sp<IResultReceiver> resultReceiver =
+                    IResultReceiver::asInterface(data.readStrongBinder());
 
             FILE* fin = fdopen(in, "r");
             FILE* fout = fdopen(out, "w");
@@ -104,15 +100,11 @@
 
             return NO_ERROR;
         }
-        default: {
-            return BnStatsManager::onTransact(code, data, reply, flags);
-        }
+        default: { return BnStatsManager::onTransact(code, data, reply, flags); }
     }
 }
 
-status_t
-StatsService::dump(int fd, const Vector<String16>& args)
-{
+status_t StatsService::dump(int fd, const Vector<String16>& args) {
     FILE* out = fdopen(fd, "w");
     if (out == NULL) {
         return NO_MEMORY;  // the fd is already open
@@ -121,7 +113,7 @@
     fprintf(out, "StatsService::dump:");
     ALOGD("StatsService::dump:");
     const int N = args.size();
-    for (int i=0; i<N; i++) {
+    for (int i = 0; i < N; i++) {
         fprintf(out, " %s", String8(args[i]).string());
         ALOGD("   %s", String8(args[i]).string());
     }
@@ -131,9 +123,7 @@
     return NO_ERROR;
 }
 
-status_t
-StatsService::command(FILE* in, FILE* out, FILE* err, Vector<String8>& args)
-{
+status_t StatsService::command(FILE* in, FILE* out, FILE* err, Vector<String8>& args) {
     if (args.size() > 0) {
         if (!args[0].compare(String8("print-stats-log")) && args.size() > 1) {
             return doPrintStatsLog(out, args);
@@ -147,9 +137,7 @@
     return NO_ERROR;
 }
 
-status_t
-StatsService::doLoadConfig(FILE* in)
-{
+status_t StatsService::doLoadConfig(FILE* in) {
     string content;
     if (!android::base::ReadFdToString(fileno(in), &content)) {
         return UNKNOWN_ERROR;
@@ -165,14 +153,12 @@
     }
 }
 
-Status
-StatsService::informAnomalyAlarmFired()
-{
+Status StatsService::informAnomalyAlarmFired() {
     if (DEBUG) ALOGD("StatsService::informAnomalyAlarmFired was called");
 
     if (IPCThreadState::self()->getCallingUid() != AID_SYSTEM) {
         return Status::fromExceptionCode(Status::EX_SECURITY,
-                "Only system uid can call informAnomalyAlarmFired");
+                                         "Only system uid can call informAnomalyAlarmFired");
     }
 
     if (DEBUG) ALOGD("StatsService::informAnomalyAlarmFired succeeded");
@@ -181,14 +167,12 @@
     return Status::ok();
 }
 
-Status
-StatsService::informPollAlarmFired()
-{
+Status StatsService::informPollAlarmFired() {
     if (DEBUG) ALOGD("StatsService::informPollAlarmFired was called");
 
     if (IPCThreadState::self()->getCallingUid() != AID_SYSTEM) {
         return Status::fromExceptionCode(Status::EX_SECURITY,
-                "Only system uid can call informPollAlarmFired");
+                                         "Only system uid can call informPollAlarmFired");
     }
 
     if (DEBUG) ALOGD("StatsService::informPollAlarmFired succeeded");
@@ -197,12 +181,10 @@
     return Status::ok();
 }
 
-Status
-StatsService::systemRunning()
-{
+Status StatsService::systemRunning() {
     if (IPCThreadState::self()->getCallingUid() != AID_SYSTEM) {
         return Status::fromExceptionCode(Status::EX_SECURITY,
-                "Only system uid can call systemRunning");
+                                         "Only system uid can call systemRunning");
     }
 
     // When system_server is up and running, schedule the dropbox task to run.
@@ -213,10 +195,9 @@
     return Status::ok();
 }
 
-void
-StatsService::sayHiToStatsCompanion()
-{
-    // TODO: This method needs to be private. It is temporarily public and unsecured for testing purposes.
+void StatsService::sayHiToStatsCompanion() {
+    // TODO: This method needs to be private. It is temporarily public and unsecured for testing
+    // purposes.
     sp<IStatsCompanionService> statsCompanion = getStatsCompanionService();
     if (statsCompanion != nullptr) {
         if (DEBUG) ALOGD("Telling statsCompanion that statsd is ready");
@@ -226,8 +207,7 @@
     }
 }
 
-sp<IStatsCompanionService>
-StatsService::getStatsCompanionService() {
+sp<IStatsCompanionService> StatsService::getStatsCompanionService() {
     sp<IStatsCompanionService> statsCompanion = nullptr;
     // Get statscompanion service from service manager
     const sp<IServiceManager> sm(defaultServiceManager());
@@ -242,9 +222,7 @@
     return statsCompanion;
 }
 
-Status
-StatsService::statsCompanionReady()
-{
+Status StatsService::statsCompanionReady() {
     if (DEBUG) ALOGD("StatsService::statsCompanionReady was called");
 
     if (IPCThreadState::self()->getCallingUid() != AID_SYSTEM) {
@@ -254,8 +232,9 @@
 
     sp<IStatsCompanionService> statsCompanion = getStatsCompanionService();
     if (statsCompanion == nullptr) {
-        return Status::fromExceptionCode(Status::EX_NULL_POINTER,
-                                         "statscompanion unavailable despite it contacting statsd!");
+        return Status::fromExceptionCode(
+                Status::EX_NULL_POINTER,
+                "statscompanion unavailable despite it contacting statsd!");
     }
     if (DEBUG) ALOGD("StatsService::statsCompanionReady linking to statsCompanion.");
     IInterface::asBinder(statsCompanion)->linkToDeath(new StatsdDeathRecipient(mAnomalyMonitor));
@@ -264,14 +243,12 @@
     return Status::ok();
 }
 
-void
-StatsdDeathRecipient::binderDied(const wp<IBinder>& who) {
+void StatsdDeathRecipient::binderDied(const wp<IBinder>& who) {
     ALOGW("statscompanion service died");
     mAnmlyMntr->setStatsCompanionService(nullptr);
 }
 
-status_t
-StatsService::doPrintStatsLog(FILE* out, const Vector<String8>& args) {
+status_t StatsService::doPrintStatsLog(FILE* out, const Vector<String8>& args) {
     long msec = 0;
 
     if (args.size() > 2) {
@@ -280,13 +257,14 @@
     return DropboxReader::readStatsLogs(out, args[1].string(), msec);
 }
 
-void
-StatsService::printCmdHelp(FILE* out) {
+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");
+    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
+}  // namespace statsd
+}  // namespace os
+}  // namespace android