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

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

Merge changes from topic "storage_health_interface"

* changes:
  Add VTS tests for APIs that return storage info.
  Create libstoragehealthdefault
  Add methods to health HAL interface to report storage info
parents 6118ea4d 2120ecc3
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -17,6 +17,9 @@ hidl_interface {
    ],
    types: [
        "Result",
        "DiskStats",
        "StorageAttribute",
        "StorageInfo",
    ],
    gen_java: true,
}
+23 −0
Original line number Diff line number Diff line
@@ -137,4 +137,27 @@ interface IHealth {
     * @return value charge status, or UNKNOWN if not successful.
     */
    getChargeStatus() generates (Result result, BatteryStatus value);

    /**
     * Get storage info.
     *
     * @return result SUCCESS if successful,
     *                NOT_SUPPORTED if this property is not supported,
     *                UNKNOWN other errors.
     * @return value vector of StorageInfo structs, to be ignored if result is not
     *               SUCCESS.
     */
    getStorageInfo() generates (Result result, vec<StorageInfo> value);

    /**
     * Gets disk statistics (number of reads/writes processed, number of I/O
     * operations in flight etc).
     *
     * @return result SUCCESS if successful,
     *                NOT_SUPPORTED if this property is not supported,
     *                UNKNOWN other errors.
     * @return value vector of disk statistics, to be ignored if result is not SUCCESS.
     *               The mapping is index 0->sda, 1->sdb and so on.
     */
    getDiskStats() generates (Result result, vec<DiskStats> value);
};
+39 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2018 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
#define LOG_TAG "android.hardware.health@2.0-impl"
#include <android-base/logging.h>

@@ -160,6 +175,30 @@ Return<void> Health::debug(const hidl_handle& handle, const hidl_vec<hidl_string
    return Void();
}

Return<void> Health::getStorageInfo(getStorageInfo_cb _hidl_cb) {
    std::vector<struct StorageInfo> info;
    get_storage_info(info);
    hidl_vec<struct StorageInfo> info_vec(info);
    if (!info.size()) {
        _hidl_cb(Result::NOT_SUPPORTED, info_vec);
    } else {
        _hidl_cb(Result::SUCCESS, info_vec);
    }
    return Void();
}

Return<void> Health::getDiskStats(getDiskStats_cb _hidl_cb) {
    std::vector<struct DiskStats> stats;
    get_disk_stats(stats);
    hidl_vec<struct DiskStats> stats_vec(stats);
    if (!stats.size()) {
        _hidl_cb(Result::NOT_SUPPORTED, stats_vec);
    } else {
        _hidl_cb(Result::SUCCESS, stats_vec);
    }
    return Void();
}

void Health::serviceDied(uint64_t /* cookie */, const wp<IBase>& who) {
    (void)unregisterCallbackInternal(who.promote());
}
+8 −0
Original line number Diff line number Diff line
@@ -9,6 +9,12 @@
#include <healthd/BatteryMonitor.h>
#include <hidl/Status.h>

using android::hardware::health::V2_0::StorageInfo;
using android::hardware::health::V2_0::DiskStats;

void get_storage_info(std::vector<struct StorageInfo>& info);
void get_disk_stats(std::vector<struct DiskStats>& stats);

namespace android {
namespace hardware {
namespace health {
@@ -44,6 +50,8 @@ struct Health : public IHealth, hidl_death_recipient {
    Return<void> getCapacity(getCapacity_cb _hidl_cb) override;
    Return<void> getEnergyCounter(getEnergyCounter_cb _hidl_cb) override;
    Return<void> getChargeStatus(getChargeStatus_cb _hidl_cb) override;
    Return<void> getStorageInfo(getStorageInfo_cb _hidl_cb) override;
    Return<void> getDiskStats(getDiskStats_cb _hidl_cb) override;

    // Methods from ::android::hidl::base::V1_0::IBase follow.
    Return<void> debug(const hidl_handle& fd, const hidl_vec<hidl_string>& args) override;
+11 −0
Original line number Diff line number Diff line
// Copyright 2018 The Android Open Source Project

cc_library_static {
    srcs: ["StorageHealthDefault.cpp"],
    name: "libhealthstoragedefault",
    vendor_available: true,
    cflags: ["-Werror"],
    shared_libs: [
        "android.hardware.health@2.0",
    ],
}
Loading