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:
parent
89e43efead
commit
a485a2c7c8
7 changed files with 6 additions and 135 deletions
|
@ -7,7 +7,6 @@ cc_library_headers {
|
|||
cc_library {
|
||||
name: "libdisppower-lenovo",
|
||||
srcs: [
|
||||
"disp-power/DisplayLowPower.cpp",
|
||||
"disp-power/InteractionHandler.cpp",
|
||||
],
|
||||
shared_libs: [
|
||||
|
|
|
@ -30,8 +30,6 @@
|
|||
#include <utils/Log.h>
|
||||
#include <utils/Trace.h>
|
||||
|
||||
#include "disp-power/DisplayLowPower.h"
|
||||
|
||||
namespace aidl {
|
||||
namespace google {
|
||||
namespace hardware {
|
||||
|
@ -43,9 +41,8 @@ constexpr char kPowerHalStateProp[] = "vendor.powerhal.state";
|
|||
constexpr char kPowerHalAudioProp[] = "vendor.powerhal.audio";
|
||||
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),
|
||||
mDisplayLowPower(dlpw),
|
||||
mInteractionHandler(nullptr),
|
||||
mVRModeOn(false),
|
||||
mSustainedPerfModeOn(false) {
|
||||
|
@ -91,12 +88,6 @@ ndk::ScopedAStatus Power::setMode(Mode type, bool enabled) {
|
|||
ATRACE_INT(toString(type).c_str(), enabled);
|
||||
switch (type) {
|
||||
case Mode::LOW_POWER:
|
||||
mDisplayLowPower->SetDisplayLowPower(enabled);
|
||||
if (enabled) {
|
||||
mHintManager->DoHint(toString(type));
|
||||
} else {
|
||||
mHintManager->EndHint(toString(type));
|
||||
}
|
||||
break;
|
||||
case Mode::SUSTAINED_PERFORMANCE:
|
||||
if (enabled && !mSustainedPerfModeOn) {
|
||||
|
|
|
@ -23,7 +23,6 @@
|
|||
#include <aidl/android/hardware/power/BnPower.h>
|
||||
#include <perfmgr/HintManager.h>
|
||||
|
||||
#include "disp-power/DisplayLowPower.h"
|
||||
#include "disp-power/InteractionHandler.h"
|
||||
|
||||
namespace aidl {
|
||||
|
@ -40,7 +39,7 @@ using ::android::perfmgr::HintManager;
|
|||
|
||||
class Power : public ::aidl::android::hardware::power::BnPower {
|
||||
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 isModeSupported(Mode type, bool *_aidl_return) override;
|
||||
ndk::ScopedAStatus setBoost(Boost type, int32_t durationMs) override;
|
||||
|
@ -49,7 +48,6 @@ class Power : public ::aidl::android::hardware::power::BnPower {
|
|||
|
||||
private:
|
||||
std::shared_ptr<HintManager> mHintManager;
|
||||
std::shared_ptr<DisplayLowPower> mDisplayLowPower;
|
||||
std::unique_ptr<InteractionHandler> mInteractionHandler;
|
||||
std::atomic<bool> mVRModeOn;
|
||||
std::atomic<bool> mSustainedPerfModeOn;
|
||||
|
|
|
@ -23,8 +23,6 @@
|
|||
#include <aidl/google/hardware/power/extension/pixel/BnPowerExt.h>
|
||||
#include <perfmgr/HintManager.h>
|
||||
|
||||
#include "disp-power/DisplayLowPower.h"
|
||||
|
||||
namespace aidl {
|
||||
namespace google {
|
||||
namespace hardware {
|
||||
|
@ -36,8 +34,8 @@ using ::android::perfmgr::HintManager;
|
|||
|
||||
class PowerExt : public ::aidl::google::hardware::power::extension::pixel::BnPowerExt {
|
||||
public:
|
||||
PowerExt(std::shared_ptr<HintManager> hm, std::shared_ptr<DisplayLowPower> dlpw)
|
||||
: mHintManager(hm), mDisplayLowPower(dlpw) {}
|
||||
PowerExt(std::shared_ptr<HintManager> hm)
|
||||
: mHintManager(hm) {}
|
||||
ndk::ScopedAStatus setMode(const std::string &mode, bool enabled) override;
|
||||
ndk::ScopedAStatus isModeSupported(const std::string &mode, bool *_aidl_return) 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:
|
||||
std::shared_ptr<HintManager> mHintManager;
|
||||
std::shared_ptr<DisplayLowPower> mDisplayLowPower;
|
||||
};
|
||||
|
||||
} // namespace pixel
|
||||
|
|
|
@ -25,7 +25,6 @@
|
|||
|
||||
#include "Power.h"
|
||||
#include "PowerExt.h"
|
||||
#include "disp-power/DisplayLowPower.h"
|
||||
|
||||
using aidl::google::hardware::power::impl::pixel::Power;
|
||||
using aidl::google::hardware::power::impl::pixel::PowerExt;
|
||||
|
@ -43,17 +42,15 @@ int main() {
|
|||
LOG(FATAL) << "Invalid config: " << kPowerHalConfigPath;
|
||||
}
|
||||
|
||||
std::shared_ptr<DisplayLowPower> dlpw = std::make_shared<DisplayLowPower>();
|
||||
|
||||
// single thread
|
||||
ABinderProcess_setThreadPoolMaxThreadCount(0);
|
||||
|
||||
// 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();
|
||||
|
||||
// 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
|
||||
CHECK(STATUS_OK == AIBinder_setExtension(pwBinder.get(), pwExt->asBinder().get()));
|
||||
|
@ -66,7 +63,6 @@ int main() {
|
|||
std::thread initThread([&]() {
|
||||
::android::base::WaitForProperty(kPowerHalInitProp, "1");
|
||||
hm->Start();
|
||||
dlpw->Init();
|
||||
});
|
||||
initThread.detach();
|
||||
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
}
|
|
@ -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;
|
||||
};
|
Loading…
Reference in a new issue