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

Commit 676ff7d5 authored by Tej Singh's avatar Tej Singh Committed by Automerger Merge Worker
Browse files

Merge "Split buckets on boot complete" into rvc-dev am: affc08a3 am: 34632794 am: b4f9a759

Change-Id: I9351f6bc5c4db11241fa5c8db4621d602e390eae
parents f93b0993 b4f9a759
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -104,7 +104,7 @@ cc_defaults {
        "src/subscriber/IncidentdReporter.cpp",
        "src/subscriber/SubscriberReporter.cpp",
        "src/uid_data.proto",
        "src/utils/NamedLatch.cpp",
        "src/utils/MultiConditionTrigger.cpp",
    ],

    local_include_dirs: [
@@ -366,7 +366,7 @@ cc_test {
        "tests/StatsService_test.cpp",
        "tests/storage/StorageManager_test.cpp",
        "tests/UidMap_test.cpp",
        "tests/utils/NamedLatch_test.cpp",
        "tests/utils/MultiConditionTrigger_test.cpp",
    ],

    static_libs: [
+14 −6
Original line number Diff line number Diff line
@@ -1055,8 +1055,8 @@ int64_t StatsLogProcessor::getLastReportTimeNs(const ConfigKey& key) {
void StatsLogProcessor::notifyAppUpgrade(const int64_t& eventTimeNs, const string& apk,
                                         const int uid, const int64_t version) {
    std::lock_guard<std::mutex> lock(mMetricsMutex);
    ALOGW("Received app upgrade");
    for (auto it : mMetricsManagers) {
    VLOG("Received app upgrade");
    for (const auto& it : mMetricsManagers) {
        it.second->notifyAppUpgrade(eventTimeNs, apk, uid, version);
    }
}
@@ -1064,20 +1064,28 @@ void StatsLogProcessor::notifyAppUpgrade(const int64_t& eventTimeNs, const strin
void StatsLogProcessor::notifyAppRemoved(const int64_t& eventTimeNs, const string& apk,
                                         const int uid) {
    std::lock_guard<std::mutex> lock(mMetricsMutex);
    ALOGW("Received app removed");
    for (auto it : mMetricsManagers) {
    VLOG("Received app removed");
    for (const auto& it : mMetricsManagers) {
        it.second->notifyAppRemoved(eventTimeNs, apk, uid);
    }
}

void StatsLogProcessor::onUidMapReceived(const int64_t& eventTimeNs) {
    std::lock_guard<std::mutex> lock(mMetricsMutex);
    ALOGW("Received uid map");
    for (auto it : mMetricsManagers) {
    VLOG("Received uid map");
    for (const auto& it : mMetricsManagers) {
        it.second->onUidMapReceived(eventTimeNs);
    }
}

void StatsLogProcessor::onStatsdInitCompleted(const int64_t& elapsedTimeNs) {
    std::lock_guard<std::mutex> lock(mMetricsMutex);
    VLOG("Received boot completed signal");
    for (const auto& it : mMetricsManagers) {
        it.second->onStatsdInitCompleted(elapsedTimeNs);
    }
}

void StatsLogProcessor::noteOnDiskData(const ConfigKey& key) {
    std::lock_guard<std::mutex> lock(mMetricsMutex);
    mOnDiskDataConfigs.insert(key);
+5 −0
Original line number Diff line number Diff line
@@ -120,6 +120,11 @@ public:
    /* Notify all MetricsManagers of uid map snapshots received */
    void onUidMapReceived(const int64_t& eventTimeNs) override;

    /* Notify all metrics managers of boot completed
     * This will force a bucket split when the boot is finished.
     */
    void onStatsdInitCompleted(const int64_t& elapsedTimeNs);

    // Reset all configs.
    void resetConfigs();

+5 −10
Original line number Diff line number Diff line
@@ -118,7 +118,8 @@ StatsService::StatsService(const sp<Looper>& handlerLooper, shared_ptr<LogEventQ
                  }
              })),
      mEventQueue(queue),
      mBootCompleteLatch({kBootCompleteTag, kUidMapReceivedTag, kAllPullersRegisteredTag}),
      mBootCompleteTrigger({kBootCompleteTag, kUidMapReceivedTag, kAllPullersRegisteredTag},
                           [this]() { mProcessor->onStatsdInitCompleted(getElapsedRealtimeNs()); }),
      mStatsCompanionServiceDeathRecipient(
              AIBinder_DeathRecipient_new(StatsService::statsCompanionServiceDied)) {
    mUidMap = UidMap::getInstance();
@@ -165,12 +166,6 @@ StatsService::StatsService(const sp<Looper>& handlerLooper, shared_ptr<LogEventQ
        std::thread pushedEventThread([this] { readLogs(); });
        pushedEventThread.detach();
    }

    std::thread bootCompletedThread([this] {
        mBootCompleteLatch.wait();
        VLOG("In the boot completed thread");
    });
    bootCompletedThread.detach();
}

StatsService::~StatsService() {
@@ -946,7 +941,7 @@ Status StatsService::informAllUidData(const ScopedFileDescriptor& fd) {
                       packageNames,
                       installers);

    mBootCompleteLatch.countDown(kUidMapReceivedTag);
    mBootCompleteTrigger.markComplete(kUidMapReceivedTag);
    VLOG("StatsService::informAllUidData UidData proto parsed successfully.");
    return Status::ok();
}
@@ -1066,7 +1061,7 @@ Status StatsService::bootCompleted() {
    ENFORCE_UID(AID_SYSTEM);

    VLOG("StatsService::bootCompleted was called");
    mBootCompleteLatch.countDown(kBootCompleteTag);
    mBootCompleteTrigger.markComplete(kBootCompleteTag);
    return Status::ok();
}

@@ -1226,7 +1221,7 @@ Status StatsService::allPullersFromBootRegistered() {
    ENFORCE_UID(AID_SYSTEM);

    VLOG("StatsService::allPullersFromBootRegistered was called");
    mBootCompleteLatch.countDown(kAllPullersRegisteredTag);
    mBootCompleteTrigger.markComplete(kAllPullersRegisteredTag);
    return Status::ok();
}

+5 −2
Original line number Diff line number Diff line
@@ -33,7 +33,7 @@
#include "packages/UidMap.h"
#include "shell/ShellSubscriber.h"
#include "statscompanion_util.h"
#include "utils/NamedLatch.h"
#include "utils/MultiConditionTrigger.h"

using namespace android;
using namespace android::os;
@@ -381,7 +381,7 @@ private:
    mutable mutex mShellSubscriberMutex;
    std::shared_ptr<LogEventQueue> mEventQueue;

    NamedLatch mBootCompleteLatch;
    MultiConditionTrigger mBootCompleteTrigger;
    static const inline string kBootCompleteTag = "BOOT_COMPLETE";
    static const inline string kUidMapReceivedTag = "UID_MAP";
    static const inline string kAllPullersRegisteredTag = "PULLERS_REGISTERED";
@@ -394,11 +394,14 @@ private:
    FRIEND_TEST(StatsServiceTest, TestAddConfig_invalid);
    FRIEND_TEST(StatsServiceTest, TestGetUidFromArgs);
    FRIEND_TEST(PartialBucketE2eTest, TestCountMetricNoSplitOnNewApp);
    FRIEND_TEST(PartialBucketE2eTest, TestCountMetricSplitOnBoot);
    FRIEND_TEST(PartialBucketE2eTest, TestCountMetricSplitOnUpgrade);
    FRIEND_TEST(PartialBucketE2eTest, TestCountMetricSplitOnRemoval);
    FRIEND_TEST(PartialBucketE2eTest, TestCountMetricWithoutSplit);
    FRIEND_TEST(PartialBucketE2eTest, TestValueMetricOnBootWithoutMinPartialBucket);
    FRIEND_TEST(PartialBucketE2eTest, TestValueMetricWithoutMinPartialBucket);
    FRIEND_TEST(PartialBucketE2eTest, TestValueMetricWithMinPartialBucket);
    FRIEND_TEST(PartialBucketE2eTest, TestGaugeMetricOnBootWithoutMinPartialBucket);
    FRIEND_TEST(PartialBucketE2eTest, TestGaugeMetricWithoutMinPartialBucket);
    FRIEND_TEST(PartialBucketE2eTest, TestGaugeMetricWithMinPartialBucket);
};
Loading