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

Commit 32a23b3b authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge changes from topic "storaged_health"

* changes:
  storaged: use health HAL to read StorageInfo.
  storaged: use health HAL to read DiskStats.
  storaged: storaged_t replace initHealthService with init.
  storaged: use get_health_service
parents ecb39c8f 845e35bd
Loading
Loading
Loading
Loading
+10 −2
Original line number Diff line number Diff line
@@ -65,6 +65,8 @@ cc_library_static {
        "binder/android/os/storaged/IStoragedPrivate.aidl",
    ],

    static_libs: ["libhealthhalutils"],

    logtags: ["EventLogTags.logtags"],

    proto: {
@@ -84,7 +86,10 @@ cc_binary {

    srcs: ["main.cpp"],

    static_libs: ["libstoraged"],
    static_libs: [
        "libhealthhalutils",
        "libstoraged",
    ],
}

/*
@@ -98,7 +103,10 @@ cc_test {

    srcs: ["tests/storaged_test.cpp"],

    static_libs: ["libstoraged"],
    static_libs: [
        "libhealthhalutils",
        "libstoraged",
    ],
}

// AIDL interface between storaged and framework.jar
+5 −3
Original line number Diff line number Diff line
@@ -81,7 +81,7 @@ class storaged_t : public android::hardware::health::V2_0::IHealthInfoCallback,
  private:
    time_t mTimer;
    storaged_config mConfig;
    disk_stats_monitor mDsm;
    unique_ptr<disk_stats_monitor> mDsm;
    uid_monitor mUidm;
    time_t mStarttime;
    sp<android::hardware::health::V2_0::IHealth> health;
@@ -96,8 +96,11 @@ class storaged_t : public android::hardware::health::V2_0::IHealthInfoCallback,
        return string("/data/misc_ce/") + to_string(user_id) +
               "/storaged/storaged.proto";
    }
    void init_health_service();

  public:
    storaged_t(void);
    void init(void);
    void event(void);
    void event_checked(void);
    void pause(void) {
@@ -130,7 +133,6 @@ public:
    void add_user_ce(userid_t user_id);
    void remove_user_ce(userid_t user_id);

    void init_health_service();
    virtual ::android::hardware::Return<void> healthInfoChanged(
        const ::android::hardware::health::V1_0::HealthInfo& info);
    void serviceDied(uint64_t cookie, const wp<::android::hidl::base::V1_0::IBase>& who);
+25 −16
Original line number Diff line number Diff line
@@ -19,6 +19,8 @@

#include <stdint.h>

#include <android/hardware/health/2.0/IHealth.h>

// number of attributes diskstats has
#define DISK_STATS_SIZE ( 11 )

@@ -160,6 +162,7 @@ private:
    const double mSigma;
    struct disk_perf mMean;
    struct disk_perf mStd;
    android::sp<android::hardware::health::V2_0::IHealth> mHealth;

    void update_mean();
    void update_std();
@@ -170,19 +173,25 @@ private:
    void update(struct disk_stats* stats);

public:
    disk_stats_monitor(uint32_t window_size = 5, double sigma = 1.0) :
        DISK_STATS_PATH(access(MMC_DISK_STATS_PATH, R_OK) ?
                            (access(SDA_DISK_STATS_PATH, R_OK) ?
                                nullptr :
                                SDA_DISK_STATS_PATH) :
                            MMC_DISK_STATS_PATH),
        mPrevious(), mAccumulate(), mAccumulate_pub(),
        mStall(false), mValid(false),
        mWindow(window_size), mSigma(sigma),
        mMean(), mStd() {}
    bool enabled() {
        return DISK_STATS_PATH != nullptr;
    }
  disk_stats_monitor(const android::sp<android::hardware::health::V2_0::IHealth>& healthService,
                     uint32_t window_size = 5, double sigma = 1.0)
      : DISK_STATS_PATH(
            healthService != nullptr
                ? nullptr
                : (access(MMC_DISK_STATS_PATH, R_OK) == 0
                       ? MMC_DISK_STATS_PATH
                       : (access(SDA_DISK_STATS_PATH, R_OK) == 0 ? SDA_DISK_STATS_PATH : nullptr))),
        mPrevious(),
        mAccumulate(),
        mAccumulate_pub(),
        mStall(false),
        mValid(false),
        mWindow(window_size),
        mSigma(sigma),
        mMean(),
        mStd(),
        mHealth(healthService) {}
  bool enabled() { return mHealth != nullptr || DISK_STATS_PATH != nullptr; }
  void update(void);
  void publish(void);
};
+20 −3
Original line number Diff line number Diff line
@@ -21,6 +21,7 @@

#include <chrono>

#include <android/hardware/health/2.0/IHealth.h>
#include <utils/Mutex.h>

#include "storaged.h"
@@ -66,8 +67,10 @@ protected:
    }
    void publish();
    storage_info_t* s_info;

  public:
    static storage_info_t* get_storage_info();
    static storage_info_t* get_storage_info(
        const sp<android::hardware::health::V2_0::IHealth>& healthService);
    virtual ~storage_info_t() {};
    virtual void report() {};
    void load_perf_history_proto(const IOPerfHistory& perf_history);
@@ -98,4 +101,18 @@ public:
    virtual void report();
};

class health_storage_info_t : public storage_info_t {
  private:
    using IHealth = hardware::health::V2_0::IHealth;
    using StorageInfo = hardware::health::V2_0::StorageInfo;

    sp<IHealth> mHealth;
    void set_values_from_hal_storage_info(const StorageInfo& halInfo);

  public:
    health_storage_info_t(const sp<IHealth>& service) : mHealth(service){};
    virtual ~health_storage_info_t() {}
    virtual void report();
};

#endif /* _STORAGED_INFO_H_ */
+1 −1
Original line number Diff line number Diff line
@@ -51,7 +51,7 @@ sp<storaged_t> storaged_sp;
void* storaged_main(void* /* unused */) {
    storaged_sp = new storaged_t();

    storaged_sp->init_health_service();
    storaged_sp->init();
    storaged_sp->report_storage_info();

    LOG_TO(SYSTEM, INFO) << "storaged: Start";
Loading