Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit ef99c4fa authored by Yao Chen's avatar Yao Chen
Browse files

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
parent aee8eff3
Loading
Loading
Loading
Loading
+14 −0
Original line number Diff line number Diff line
BasedOnStyle: Google
AllowShortIfStatementsOnASingleLine: true
AllowShortFunctionsOnASingleLine: false
AllowShortLoopsOnASingleLine: true
BinPackArguments: true
BinPackParameters: true
ColumnLimit: 100
CommentPragmas: NOLINT:.*
ContinuationIndentWidth: 8
DerivePointerAlignment: false
IndentWidth: 4
PointerAlignment: Left
TabWidth: 4
AccessModifierOffset: -4
+6 −7
Original line number Diff line number Diff line
@@ -26,8 +26,7 @@ namespace os {
namespace statsd {

AnomalyMonitor::AnomalyMonitor(uint32_t minDiffToUpdateRegisteredAlarmTimeSec)
        : mRegisteredAlarmTimeSec(0),
          mMinUpdateTimeSec(minDiffToUpdateRegisteredAlarmTimeSec) {
    : mRegisteredAlarmTimeSec(0), mMinUpdateTimeSec(minDiffToUpdateRegisteredAlarmTimeSec) {
}

AnomalyMonitor::~AnomalyMonitor() {
+7 −7
Original line number Diff line number Diff line
@@ -17,8 +17,8 @@
#ifndef ANOMALY_MONITOR_H
#define ANOMALY_MONITOR_H

#include <indexed_priority_queue.h>
#include <android/os/IStatsCompanionService.h>
#include <indexed_priority_queue.h>
#include <utils/RefBase.h>

#include <queue>
+13 −15
Original line number Diff line number Diff line
@@ -13,18 +13,18 @@
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
#include <android/os/DropBoxManager.h>
#include <android-base/file.h>
#include <android/os/DropBoxManager.h>
#include <androidfw/ZipUtils.h>

#include "DropboxReader.h"

using android::sp;
using android::String16;
using android::binder::Status;
using android::ZipUtils;
using android::base::unique_fd;
using android::binder::Status;
using android::os::DropBoxManager;
using android::ZipUtils;
using android::sp;
using std::vector;

namespace android {
@@ -39,8 +39,7 @@ status_t DropboxReader::readStatsLogs(FILE* out, const string& tag, long msec) {
    // instead of while(true), put a hard limit 1000. Dropbox won't have more than 1000 files.
    for (int i = 0; i < 1000; i++) {
        DropBoxManager::Entry entry;
        Status status = dropbox->getNextEntry(String16(tag.c_str()),
                timestamp, &entry);
        Status status = dropbox->getNextEntry(String16(tag.c_str()), timestamp, &entry);
        if (!status.isOk()) {
            ALOGD("No more entries, or failed to read. We can't tell unfortunately.");
            return android::OK;
@@ -76,8 +75,7 @@ bool DropboxReader::parseFromGzipFile(const unique_fd& fd, StatsLogReport& logRe
    long compressedLen;
    long uncompressedLen;
    unsigned long crc32;
    scanResult = ZipUtils::examineGzip(file, &method, &uncompressedLen,
            &compressedLen, &crc32);
    scanResult = ZipUtils::examineGzip(file, &method, &uncompressedLen, &compressedLen, &crc32);
    if (scanResult && method == kCompressDeflated) {
        vector<uint8_t> buf(uncompressedLen);
        if (ZipUtils::inflateToBuffer(file, &buf[0], uncompressedLen, compressedLen)) {
@@ -107,8 +105,8 @@ bool DropboxReader::parseFromFile(const unique_fd& fd, StatsLogReport& logReport
}

void DropboxReader::printLog(FILE* out, const StatsLogReport& logReport) {
    fprintf(out, "start_time_msec=%lld, end_time_msec=%lld, ",
            logReport.start_report_millis(), logReport.end_report_millis());
    fprintf(out, "start_time_msec=%lld, end_time_msec=%lld, ", logReport.start_report_millis(),
            logReport.end_report_millis());
    for (int i = 0; i < logReport.event_metrics().data_size(); i++) {
        EventMetricData eventMetricData = logReport.event_metrics().data(i);
        for (int j = 0; j < eventMetricData.key_value_pair_size(); j++) {
+7 −9
Original line number Diff line number Diff line
@@ -18,18 +18,17 @@

#include "DropboxWriter.h"

using android::String16;
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) {
DropboxWriter::DropboxWriter(const string& tag) : mTag(tag), mLogReport(), mBufferSize(0) {
}

void DropboxWriter::addStatsLogReport(const StatsLogReport& log) {
@@ -52,8 +51,7 @@ void DropboxWriter::flush() {
    vector<uint8_t> buffer(numBytes);
    sp<DropBoxManager> dropbox = new DropBoxManager();
    mLogReport.SerializeToArray(&buffer[0], numBytes);
    Status status = dropbox->addData(String16(mTag.c_str()), &buffer[0],
            numBytes, 0 /* no flag */);
    Status status = dropbox->addData(String16(mTag.c_str()), &buffer[0], numBytes, 0 /* no flag */);
    if (!status.isOk()) {
        ALOGE("failed to write to dropbox");
        // TODO: What to do if flush fails??
Loading