kunlun2: power-libperfmgr: Remove Google-specific display LPM control

Change-Id: If58f38b99bf6fbd73f6b6ab2144293c63e18b600
Signed-off-by: Jesse Chan <jc@lineageos.org>
Signed-off-by: SamarV-121 <samarvispute121@gmail.com>
This commit is contained in:
Jesse Chan 2020-06-13 12:06:26 +08:00 committed by GiaSen
parent 89e43efead
commit a485a2c7c8
7 changed files with 6 additions and 135 deletions

View file

@ -7,7 +7,6 @@ cc_library_headers {
cc_library { cc_library {
name: "libdisppower-lenovo", name: "libdisppower-lenovo",
srcs: [ srcs: [
"disp-power/DisplayLowPower.cpp",
"disp-power/InteractionHandler.cpp", "disp-power/InteractionHandler.cpp",
], ],
shared_libs: [ shared_libs: [

View file

@ -30,8 +30,6 @@
#include <utils/Log.h> #include <utils/Log.h>
#include <utils/Trace.h> #include <utils/Trace.h>
#include "disp-power/DisplayLowPower.h"
namespace aidl { namespace aidl {
namespace google { namespace google {
namespace hardware { namespace hardware {
@ -43,9 +41,8 @@ constexpr char kPowerHalStateProp[] = "vendor.powerhal.state";
constexpr char kPowerHalAudioProp[] = "vendor.powerhal.audio"; constexpr char kPowerHalAudioProp[] = "vendor.powerhal.audio";
constexpr char kPowerHalRenderingProp[] = "vendor.powerhal.rendering"; constexpr char kPowerHalRenderingProp[] = "vendor.powerhal.rendering";
Power::Power(std::shared_ptr<HintManager> hm, std::shared_ptr<DisplayLowPower> dlpw) Power::Power(std::shared_ptr<HintManager> hm)
: mHintManager(hm), : mHintManager(hm),
mDisplayLowPower(dlpw),
mInteractionHandler(nullptr), mInteractionHandler(nullptr),
mVRModeOn(false), mVRModeOn(false),
mSustainedPerfModeOn(false) { mSustainedPerfModeOn(false) {
@ -91,12 +88,6 @@ ndk::ScopedAStatus Power::setMode(Mode type, bool enabled) {
ATRACE_INT(toString(type).c_str(), enabled); ATRACE_INT(toString(type).c_str(), enabled);
switch (type) { switch (type) {
case Mode::LOW_POWER: case Mode::LOW_POWER:
mDisplayLowPower->SetDisplayLowPower(enabled);
if (enabled) {
mHintManager->DoHint(toString(type));
} else {
mHintManager->EndHint(toString(type));
}
break; break;
case Mode::SUSTAINED_PERFORMANCE: case Mode::SUSTAINED_PERFORMANCE:
if (enabled && !mSustainedPerfModeOn) { if (enabled && !mSustainedPerfModeOn) {

View file

@ -23,7 +23,6 @@
#include <aidl/android/hardware/power/BnPower.h> #include <aidl/android/hardware/power/BnPower.h>
#include <perfmgr/HintManager.h> #include <perfmgr/HintManager.h>
#include "disp-power/DisplayLowPower.h"
#include "disp-power/InteractionHandler.h" #include "disp-power/InteractionHandler.h"
namespace aidl { namespace aidl {
@ -40,7 +39,7 @@ using ::android::perfmgr::HintManager;
class Power : public ::aidl::android::hardware::power::BnPower { class Power : public ::aidl::android::hardware::power::BnPower {
public: public:
Power(std::shared_ptr<HintManager> hm, std::shared_ptr<DisplayLowPower> dlpw); Power(std::shared_ptr<HintManager> hm);
ndk::ScopedAStatus setMode(Mode type, bool enabled) override; ndk::ScopedAStatus setMode(Mode type, bool enabled) override;
ndk::ScopedAStatus isModeSupported(Mode type, bool *_aidl_return) override; ndk::ScopedAStatus isModeSupported(Mode type, bool *_aidl_return) override;
ndk::ScopedAStatus setBoost(Boost type, int32_t durationMs) override; ndk::ScopedAStatus setBoost(Boost type, int32_t durationMs) override;
@ -49,7 +48,6 @@ class Power : public ::aidl::android::hardware::power::BnPower {
private: private:
std::shared_ptr<HintManager> mHintManager; std::shared_ptr<HintManager> mHintManager;
std::shared_ptr<DisplayLowPower> mDisplayLowPower;
std::unique_ptr<InteractionHandler> mInteractionHandler; std::unique_ptr<InteractionHandler> mInteractionHandler;
std::atomic<bool> mVRModeOn; std::atomic<bool> mVRModeOn;
std::atomic<bool> mSustainedPerfModeOn; std::atomic<bool> mSustainedPerfModeOn;

View file

@ -23,8 +23,6 @@
#include <aidl/google/hardware/power/extension/pixel/BnPowerExt.h> #include <aidl/google/hardware/power/extension/pixel/BnPowerExt.h>
#include <perfmgr/HintManager.h> #include <perfmgr/HintManager.h>
#include "disp-power/DisplayLowPower.h"
namespace aidl { namespace aidl {
namespace google { namespace google {
namespace hardware { namespace hardware {
@ -36,8 +34,8 @@ using ::android::perfmgr::HintManager;
class PowerExt : public ::aidl::google::hardware::power::extension::pixel::BnPowerExt { class PowerExt : public ::aidl::google::hardware::power::extension::pixel::BnPowerExt {
public: public:
PowerExt(std::shared_ptr<HintManager> hm, std::shared_ptr<DisplayLowPower> dlpw) PowerExt(std::shared_ptr<HintManager> hm)
: mHintManager(hm), mDisplayLowPower(dlpw) {} : mHintManager(hm) {}
ndk::ScopedAStatus setMode(const std::string &mode, bool enabled) override; ndk::ScopedAStatus setMode(const std::string &mode, bool enabled) override;
ndk::ScopedAStatus isModeSupported(const std::string &mode, bool *_aidl_return) override; ndk::ScopedAStatus isModeSupported(const std::string &mode, bool *_aidl_return) override;
ndk::ScopedAStatus setBoost(const std::string &boost, int32_t durationMs) override; ndk::ScopedAStatus setBoost(const std::string &boost, int32_t durationMs) override;
@ -45,7 +43,6 @@ class PowerExt : public ::aidl::google::hardware::power::extension::pixel::BnPow
private: private:
std::shared_ptr<HintManager> mHintManager; std::shared_ptr<HintManager> mHintManager;
std::shared_ptr<DisplayLowPower> mDisplayLowPower;
}; };
} // namespace pixel } // namespace pixel

View file

@ -25,7 +25,6 @@
#include "Power.h" #include "Power.h"
#include "PowerExt.h" #include "PowerExt.h"
#include "disp-power/DisplayLowPower.h"
using aidl::google::hardware::power::impl::pixel::Power; using aidl::google::hardware::power::impl::pixel::Power;
using aidl::google::hardware::power::impl::pixel::PowerExt; using aidl::google::hardware::power::impl::pixel::PowerExt;
@ -43,17 +42,15 @@ int main() {
LOG(FATAL) << "Invalid config: " << kPowerHalConfigPath; LOG(FATAL) << "Invalid config: " << kPowerHalConfigPath;
} }
std::shared_ptr<DisplayLowPower> dlpw = std::make_shared<DisplayLowPower>();
// single thread // single thread
ABinderProcess_setThreadPoolMaxThreadCount(0); ABinderProcess_setThreadPoolMaxThreadCount(0);
// core service // core service
std::shared_ptr<Power> pw = ndk::SharedRefBase::make<Power>(hm, dlpw); std::shared_ptr<Power> pw = ndk::SharedRefBase::make<Power>(hm);
ndk::SpAIBinder pwBinder = pw->asBinder(); ndk::SpAIBinder pwBinder = pw->asBinder();
// extension service // extension service
std::shared_ptr<PowerExt> pwExt = ndk::SharedRefBase::make<PowerExt>(hm, dlpw); std::shared_ptr<PowerExt> pwExt = ndk::SharedRefBase::make<PowerExt>(hm);
// attach the extension to the same binder we will be registering // attach the extension to the same binder we will be registering
CHECK(STATUS_OK == AIBinder_setExtension(pwBinder.get(), pwExt->asBinder().get())); CHECK(STATUS_OK == AIBinder_setExtension(pwBinder.get(), pwExt->asBinder().get()));
@ -66,7 +63,6 @@ int main() {
std::thread initThread([&]() { std::thread initThread([&]() {
::android::base::WaitForProperty(kPowerHalInitProp, "1"); ::android::base::WaitForProperty(kPowerHalInitProp, "1");
hm->Start(); hm->Start();
dlpw->Init();
}); });
initThread.detach(); initThread.detach();

View file

@ -1,73 +0,0 @@
/*
* Copyright (C) 2020 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.power@-service.pixel-libperfmgr"
#include <errno.h>
#include <unistd.h>
#include <cutils/sockets.h>
#include <log/log.h>
#include "DisplayLowPower.h"
DisplayLowPower::DisplayLowPower() : mFossStatus(false) {}
void DisplayLowPower::Init() {
ConnectPpsDaemon();
}
void DisplayLowPower::SetDisplayLowPower(bool enable) {
SetFoss(enable);
}
void DisplayLowPower::ConnectPpsDaemon() {
constexpr const char kPpsDaemon[] = "pps";
mPpsSocket.reset(
socket_local_client(kPpsDaemon, ANDROID_SOCKET_NAMESPACE_RESERVED, SOCK_STREAM));
if (mPpsSocket.get() < 0) {
ALOGW("Connecting to PPS daemon failed (%s)", strerror(errno));
}
}
int DisplayLowPower::SendPpsCommand(const std::string_view cmd) {
if (TEMP_FAILURE_RETRY(write(mPpsSocket.get(), cmd.data(), cmd.size())) < 0) {
ALOGE("Failed to send pps command '%s' over socket (%s)", cmd.data(), strerror(errno));
return -1;
}
return 0;
}
void DisplayLowPower::SetFoss(bool enable) {
if (mPpsSocket.get() < 0 || mFossStatus == enable) {
return;
}
ALOGI("%s foss", (enable) ? "Enable" : "Disable");
std::string_view foss_cmd;
if (enable) {
foss_cmd = "foss:on";
} else {
foss_cmd = "foss:off";
}
if (!SendPpsCommand(foss_cmd)) {
mFossStatus = enable;
}
}

View file

@ -1,37 +0,0 @@
/*
* Copyright (C) 2020 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.
*/
#pragma once
#include <android-base/unique_fd.h>
#include <string_view>
class DisplayLowPower {
public:
DisplayLowPower();
~DisplayLowPower() {}
void Init();
void SetDisplayLowPower(bool enable);
private:
void ConnectPpsDaemon();
int SendPpsCommand(const std::string_view cmd);
void SetFoss(bool enable);
android::base::unique_fd mPpsSocket;
bool mFossStatus;
};