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

Commit 2b9ffc00 authored by Matt Buckley's avatar Matt Buckley Committed by Android (Google) Code Review
Browse files

Merge "Refactor initial support check to use SupportInfo" into main

parents 667fb71c 8f997cbe
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -72,6 +72,7 @@ public:
    virtual HalResult<aidl::android::hardware::power::ChannelConfig> getSessionChannel(
            int tgid, int uid) override;
    virtual HalResult<void> closeSessionChannel(int tgid, int uid) override;
    virtual HalResult<aidl::android::hardware::power::SupportInfo> getSupportInfo() override;

private:
    std::mutex mConnectedHalMutex;
+3 −0
Original line number Diff line number Diff line
@@ -63,6 +63,7 @@ public:
    virtual HalResult<aidl::android::hardware::power::ChannelConfig> getSessionChannel(int tgid,
                                                                                       int uid) = 0;
    virtual HalResult<void> closeSessionChannel(int tgid, int uid) = 0;
    virtual HalResult<aidl::android::hardware::power::SupportInfo> getSupportInfo() = 0;
};

// Empty Power HAL wrapper that ignores all api calls.
@@ -85,6 +86,7 @@ public:
    HalResult<aidl::android::hardware::power::ChannelConfig> getSessionChannel(int tgid,
                                                                               int uid) override;
    HalResult<void> closeSessionChannel(int tgid, int uid) override;
    HalResult<aidl::android::hardware::power::SupportInfo> getSupportInfo() override;

protected:
    virtual const char* getUnsupportedMessage();
@@ -170,6 +172,7 @@ public:
    HalResult<aidl::android::hardware::power::ChannelConfig> getSessionChannel(int tgid,
                                                                               int uid) override;
    HalResult<void> closeSessionChannel(int tgid, int uid) override;
    HalResult<aidl::android::hardware::power::SupportInfo> getSupportInfo() override;

protected:
    const char* getUnsupportedMessage() override;
+5 −0
Original line number Diff line number Diff line
@@ -168,6 +168,11 @@ HalResult<void> PowerHalController::closeSessionChannel(int tgid, int uid) {
                                          "closeSessionChannel"));
}

HalResult<aidl::android::hardware::power::SupportInfo> PowerHalController::getSupportInfo() {
    std::shared_ptr<HalWrapper> handle = initHal();
    return CACHE_SUPPORT(6, processHalResult(handle->getSupportInfo(), "getSupportInfo"));
}

} // namespace power

} // namespace android
+12 −0
Original line number Diff line number Diff line
@@ -18,6 +18,7 @@
#include <aidl/android/hardware/power/Boost.h>
#include <aidl/android/hardware/power/IPowerHintSession.h>
#include <aidl/android/hardware/power/Mode.h>
#include <aidl/android/hardware/power/SupportInfo.h>
#include <powermanager/HalResult.h>
#include <powermanager/PowerHalWrapper.h>
#include <utils/Log.h>
@@ -73,6 +74,11 @@ HalResult<void> EmptyHalWrapper::closeSessionChannel(int, int) {
    return HalResult<void>::unsupported();
}

HalResult<Aidl::SupportInfo> EmptyHalWrapper::getSupportInfo() {
    ALOGV("Skipped getSupportInfo because %s", getUnsupportedMessage());
    return HalResult<Aidl::SupportInfo>::unsupported();
}

const char* EmptyHalWrapper::getUnsupportedMessage() {
    return "Power HAL is not supported";
}
@@ -280,6 +286,12 @@ HalResult<void> AidlHalWrapper::closeSessionChannel(int tgid, int uid) {
    return HalResult<void>::fromStatus(mHandle->closeSessionChannel(tgid, uid));
}

HalResult<Aidl::SupportInfo> AidlHalWrapper::getSupportInfo() {
    Aidl::SupportInfo support;
    auto result = mHandle->getSupportInfo(&support);
    return HalResult<Aidl::SupportInfo>::fromStatus(result, std::move(support));
}

const char* AidlHalWrapper::getUnsupportedMessage() {
    return "Power HAL doesn't support it";
}
+2 −0
Original line number Diff line number Diff line
@@ -54,6 +54,8 @@ public:
    MOCK_METHOD(HalResult<aidl::android::hardware::power::ChannelConfig>, getSessionChannel,
                (int tgid, int uid), (override));
    MOCK_METHOD(HalResult<void>, closeSessionChannel, (int tgid, int uid), (override));
    MOCK_METHOD(HalResult<aidl::android::hardware::power::SupportInfo>, getSupportInfo, (),
                (override));
};

} // namespace android::adpf::mock
 No newline at end of file