Compare commits

..

No commits in common. "fifteen/stable" and "fourteen/dynamic" have entirely different histories.

24 changed files with 290 additions and 335 deletions

View file

@ -79,10 +79,6 @@ BOARD_HAS_QCA_FM_SOC := "cherokee"
# HIDL
DEVICE_MANIFEST_FILE := $(COMMON_PATH)/manifest.xml
DEVICE_MATRIX_FILE := $(COMMON_PATH)/compatibility_matrix.xml
DEVICE_FRAMEWORK_COMPATIBILITY_MATRIX_FILE += \
hardware/qcom-caf/common/vendor_framework_compatibility_matrix.xml \
$(COMMON_PATH)/framework_compatibility_matrix.xml \
vendor/lineage/config/device_framework_matrix.xml
# Partitions
BOARD_BOOTIMAGE_PARTITION_SIZE := 67108864
@ -131,7 +127,6 @@ BOARD_ROOT_EXTRA_SYMLINKS := \
/vendor/firmware_mnt:/firmware
# Recovery
TARGET_RECOVERY_PIXEL_FORMAT := BGRA_8888
TARGET_RECOVERY_FSTAB := $(COMMON_PATH)/rootdir/etc/fstab.qcom
# Releasetools

View file

@ -61,10 +61,7 @@ fi
function blob_fixup() {
case "${1}" in
vendor/etc/seccomp_policy/vendor.qti.hardware.dsp.policy)
echo 'madvise: 1' >> "${2}"
;;
vendor/lib/libwvhidl.so)
"${PATCHELF}" --replace-needed "libcrypto.so" "libcrypto-v33.so" "${2}"
echo 'madvise: 1' >> ${2}
;;
esac
}

View file

@ -1,100 +0,0 @@
<compatibility-matrix version="2.0" type="framework">
<hal format="hidl" optional="true">
<name>android.hardware.light</name>
<version>2.0</version>
<interface>
<name>ILight</name>
<instance>default</instance>
</interface>
</hal>
<hal format="hidl" optional="true">
<name>android.hardware.vibrator</name>
<version>1.0</version>
<interface>
<name>IVibrator</name>
<instance>default</instance>
</interface>
</hal>
<hal format="hidl">
<name>com.qualcomm.qti.ant</name>
<transport>hwbinder</transport>
<version>1.0</version>
<interface>
<name>IAntHci</name>
<instance>default</instance>
</interface>
</hal>
<hal format="hidl" optional="true">
<name>vendor.qti.imsrtpservice</name>
<version>2.0-1</version>
<version>3.0</version>
<interface>
<name>IRTPService</name>
<instance>imsrtpservice</instance>
</interface>
</hal>
<hal format="aidl" optional="true">
<name>android.hardware.wifi</name>
<interface>
<name>IWifi</name>
<instance>default</instance>
</interface>
</hal>
<hal format="aidl" optional="true">
<name>android.hardware.cas</name>
<interface>
<name>IMediaCasService</name>
<instance>default</instance>
</interface>
</hal>
<hal format="aidl" optional="true">
<name>android.hardware.drm</name>
<interface>
<name>IDrmFactory</name>
<instance>clearkey</instance>
</interface>
</hal>
<hal format="aidl" optional="true">
<name>android.hardware.power</name>
<interface>
<name>IPower</name>
<instance>default</instance>
</interface>
</hal>
<hal format="hidl" optional="true">
<name>android.hardware.usb</name>
<version>1.0-3</version>
<interface>
<name>IUsb</name>
<instance>default</instance>
</interface>
</hal>
<hal format="aidl" optional="true">
<name>android.hardware.vibrator</name>
<interface>
<name>IVibrator</name>
<instance>default</instance>
</interface>
</hal>
<hal format="aidl" optional="true">
<name>android.hardware.wifi</name>
<interface>
<name>IWifi</name>
<instance>default</instance>
</interface>
</hal>
<hal format="aidl" optional="true">
<name>android.hardware.wifi.hostapd</name>
<interface>
<name>IHostapd</name>
<instance>default</instance>
</interface>
</hal>
<hal format="aidl" optional="true">
<name>android.hardware.wifi.supplicant</name>
<interface>
<name>ISupplicant</name>
<instance>default</instance>
</interface>
</hal>
</compatibility-matrix>

View file

@ -1,4 +1,4 @@
<manifest version="1.0" type="device" target-level="5">
<manifest version="1.0" type="device" target-level="4">
<hal format="hidl">
<name>android.hardware.audio</name>
<transport>hwbinder</transport>
@ -19,6 +19,16 @@
</interface>
<fqname>@6.0::IEffectsFactory/default</fqname>
</hal>
<hal format="hidl">
<name>android.hardware.biometrics.fingerprint</name>
<transport>hwbinder</transport>
<version>2.1</version>
<interface>
<name>IBiometricsFingerprint</name>
<instance>default</instance>
</interface>
<fqname>@2.1::IBiometricsFingerprint/default</fqname>
</hal>
<hal format="hidl">
<name>android.hardware.bluetooth</name>
<transport>hwbinder</transport>

View file

@ -399,6 +399,14 @@
The default is false. -->
<bool name="config_lidControlsSleep">true</bool>
<!-- List of biometric sensors on the device, in decreasing strength. Consumed by AuthService
when registering authenticators with BiometricService. Format must be ID:Modality:Strength,
where: IDs are unique per device, Modality as defined in BiometricAuthenticator.java,
and Strength as defined in Authenticators.java -->
<string-array name="config_biometric_sensors" translatable="false" >
<item>0:2:15</item> <!-- ID0:Fingerprint:Strong -->
</string-array>
<!-- SQLite -->
<string name="db_default_journal_mode">MEMORY</string>
<string name="db_default_sync_mode">OFF</string>
@ -419,6 +427,9 @@
2: gestures only for back, home and overview -->
<integer name="config_navBarInteractionMode">2</integer>
<!-- Specify if the fingerprint hardware support gestures-->
<bool name="config_fingerprintSupportsGestures">true</bool>
<!-- Enable system navigation keys. -->
<bool name="config_supportSystemNavigationKeys">true</bool>

View file

@ -13,11 +13,16 @@
# See the License for the specific language governing permissions and
# limitations under the License.
#
ifneq (,$(findstring hardware/google/interfaces, $(PRODUCT_SOONG_NAMESPACES)))
ifneq (,$(findstring hardware/google/pixel, $(PRODUCT_SOONG_NAMESPACES)))
LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
LOCAL_MODULE_RELATIVE_PATH := hw
LOCAL_SHARED_LIBRARIES := \
android.hardware.power-V2-ndk \
libbase \
@ -29,6 +34,7 @@ LOCAL_SHARED_LIBRARIES := \
libprocessgroup \
libutils \
pixel-power-ext-V1-ndk
LOCAL_SRC_FILES := \
service.cpp \
InteractionHandler.cpp \
@ -36,19 +42,25 @@ LOCAL_SRC_FILES := \
PowerExt.cpp \
PowerHintSession.cpp \
PowerSessionManager.cpp
LOCAL_CFLAGS := -Wno-unused-parameter -Wno-unused-variable
ifneq ($(TARGET_POWERHAL_MODE_EXT),)
LOCAL_CFLAGS += -DMODE_EXT
LOCAL_SRC_FILES += ../../../../$(TARGET_POWERHAL_MODE_EXT)
endif
ifneq ($(TARGET_TAP_TO_WAKE_NODE),)
LOCAL_CFLAGS += -DTAP_TO_WAKE_NODE=\"$(TARGET_TAP_TO_WAKE_NODE)\"
endif
LOCAL_MODULE := android.hardware.power-service.xiaomi-libperfmgr
LOCAL_INIT_RC := android.hardware.power-service.xiaomi-libperfmgr.rc
LOCAL_MODULE := android.hardware.power-service.lenovo-sdm710-libperfmgr
LOCAL_INIT_RC := android.hardware.power-service.lenovo-sdm710-libperfmgr.rc
LOCAL_MODULE_TAGS := optional
LOCAL_VENDOR_MODULE := true
LOCAL_VINTF_FRAGMENTS := android.hardware.power-service.xiaomi.xml
LOCAL_VINTF_FRAGMENTS := android.hardware.power-service.lenovo-sdm710.xml
include $(BUILD_EXECUTABLE)
endif
endif

View file

@ -13,9 +13,12 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#define ATRACE_TAG (ATRACE_TAG_POWER | ATRACE_TAG_HAL)
#define LOG_TAG "powerhal-libperfmgr"
#include "InteractionHandler.h"
#include <android-base/properties.h>
#include <fcntl.h>
#include <perfmgr/HintManager.h>
@ -25,18 +28,24 @@
#include <unistd.h>
#include <utils/Log.h>
#include <utils/Trace.h>
#include <array>
#include <memory>
#define MAX_LENGTH 64
#define MSINSEC 1000L
#define NSINMS 1000000L
namespace aidl {
namespace google {
namespace hardware {
namespace power {
namespace impl {
namespace pixel {
namespace {
static const bool kDisplayIdleSupport =
::android::base::GetBoolProperty("vendor.powerhal.disp.idle_support", true);
static const std::array<const char *, 2> kDispIdlePath = {"/sys/class/drm/card0/device/idle_state",
@ -49,12 +58,14 @@ static const uint32_t kMaxDurationMs =
::android::base::GetUintProperty("vendor.powerhal.interaction.max", /*default*/ 5650U);
static const uint32_t kDurationOffsetMs =
::android::base::GetUintProperty("vendor.powerhal.interaction.offset", /*default*/ 650U);
static size_t CalcTimespecDiffMs(struct timespec start, struct timespec end) {
size_t diff_in_ms = 0;
diff_in_ms += (end.tv_sec - start.tv_sec) * MSINSEC;
diff_in_ms += (end.tv_nsec - start.tv_nsec) / NSINMS;
return diff_in_ms;
}
static int FbIdleOpen(void) {
int fd;
for (const auto &path : kDispIdlePath) {
@ -65,58 +76,77 @@ static int FbIdleOpen(void) {
ALOGE("Unable to open fb idle state path (%d)", errno);
return -1;
}
} // namespace
using ::android::perfmgr::HintManager;
InteractionHandler::InteractionHandler()
: mState(INTERACTION_STATE_UNINITIALIZED), mDurationMs(0) {}
InteractionHandler::~InteractionHandler() {
Exit();
}
bool InteractionHandler::Init() {
std::lock_guard<std::mutex> lk(mLock);
if (mState != INTERACTION_STATE_UNINITIALIZED)
return true;
int fd = FbIdleOpen();
if (fd < 0)
return false;
mIdleFd = fd;
mEventFd = eventfd(0, EFD_NONBLOCK);
if (mEventFd < 0) {
ALOGE("Unable to create event fd (%d)", errno);
close(mIdleFd);
return false;
}
mState = INTERACTION_STATE_IDLE;
mThread = std::unique_ptr<std::thread>(new std::thread(&InteractionHandler::Routine, this));
return true;
}
void InteractionHandler::Exit() {
std::unique_lock<std::mutex> lk(mLock);
if (mState == INTERACTION_STATE_UNINITIALIZED)
return;
AbortWaitLocked();
mState = INTERACTION_STATE_UNINITIALIZED;
lk.unlock();
mCond.notify_all();
mThread->join();
close(mEventFd);
close(mIdleFd);
}
void InteractionHandler::PerfLock() {
ALOGV("%s: acquiring perf lock", __func__);
if (!HintManager::GetInstance()->DoHint("INTERACTION")) {
ALOGE("%s: do hint INTERACTION failed", __func__);
}
}
void InteractionHandler::PerfRel() {
ALOGV("%s: releasing perf lock", __func__);
if (!HintManager::GetInstance()->EndHint("INTERACTION")) {
ALOGE("%s: end hint INTERACTION failed", __func__);
}
}
void InteractionHandler::Acquire(int32_t duration) {
ATRACE_CALL();
std::lock_guard<std::mutex> lk(mLock);
int inputDuration = duration + kDurationOffsetMs;
int finalDuration;
if (inputDuration > kMaxDurationMs)
@ -125,6 +155,7 @@ void InteractionHandler::Acquire(int32_t duration) {
finalDuration = inputDuration;
else
finalDuration = kMinDurationMs;
// Fallback to do boost directly
// 1) override property is set OR
// 2) InteractionHandler not initialized
@ -132,6 +163,7 @@ void InteractionHandler::Acquire(int32_t duration) {
HintManager::GetInstance()->DoHint("INTERACTION", std::chrono::milliseconds(finalDuration));
return;
}
struct timespec cur_timespec;
clock_gettime(CLOCK_MONOTONIC, &cur_timespec);
if (mState != INTERACTION_STATE_IDLE && finalDuration <= mDurationMs) {
@ -146,14 +178,18 @@ void InteractionHandler::Acquire(int32_t duration) {
}
mLastTimespec = cur_timespec;
mDurationMs = finalDuration;
ALOGV("%s: input: %d final duration: %d", __func__, duration, finalDuration);
if (mState == INTERACTION_STATE_WAITING)
AbortWaitLocked();
else if (mState == INTERACTION_STATE_IDLE)
PerfLock();
mState = INTERACTION_STATE_INTERACTION;
mCond.notify_one();
}
void InteractionHandler::Release() {
std::lock_guard<std::mutex> lk(mLock);
if (mState == INTERACTION_STATE_WAITING) {
@ -164,9 +200,11 @@ void InteractionHandler::Release() {
// clear any wait aborts pending in event fd
uint64_t val;
ssize_t ret = read(mEventFd, &val, sizeof(val));
ALOGW_IF(ret < 0, "%s: failed to clear eventfd (%zd, %d)", __func__, ret, errno);
}
}
// should be called while locked
void InteractionHandler::AbortWaitLocked() {
uint64_t val = 1;
@ -174,16 +212,21 @@ void InteractionHandler::AbortWaitLocked() {
if (ret != sizeof(val))
ALOGW("Unable to write to event fd (%zd)", ret);
}
void InteractionHandler::WaitForIdle(int32_t wait_ms, int32_t timeout_ms) {
char data[MAX_LENGTH];
ssize_t ret;
struct pollfd pfd[2];
ATRACE_CALL();
ALOGV("%s: wait:%d timeout:%d", __func__, wait_ms, timeout_ms);
pfd[0].fd = mEventFd;
pfd[0].events = POLLIN;
pfd[1].fd = mIdleFd;
pfd[1].events = POLLPRI | POLLERR;
ret = poll(pfd, 1, wait_ms);
if (ret > 0) {
ALOGV("%s: wait aborted", __func__);
@ -192,15 +235,18 @@ void InteractionHandler::WaitForIdle(int32_t wait_ms, int32_t timeout_ms) {
ALOGE("%s: error in poll while waiting", __func__);
return;
}
ret = pread(mIdleFd, data, sizeof(data), 0);
if (!ret) {
ALOGE("%s: Unexpected EOF!", __func__);
return;
}
if (!strncmp(data, "idle", 4)) {
ALOGV("%s: already idle", __func__);
return;
}
ret = poll(pfd, 2, timeout_ms);
if (ret < 0)
ALOGE("%s: Error on waiting for idle (%zd)", __func__, ret);
@ -211,9 +257,11 @@ void InteractionHandler::WaitForIdle(int32_t wait_ms, int32_t timeout_ms) {
else if (pfd[1].revents)
ALOGV("%s: idle detected", __func__);
}
void InteractionHandler::Routine() {
pthread_setname_np(pthread_self(), "DispIdle");
std::unique_lock<std::mutex> lk(mLock, std::defer_lock);
while (true) {
lk.lock();
mCond.wait(lk, [&] { return mState != INTERACTION_STATE_IDLE; });
@ -221,10 +269,12 @@ void InteractionHandler::Routine() {
return;
mState = INTERACTION_STATE_WAITING;
lk.unlock();
WaitForIdle(kWaitMs, mDurationMs);
Release();
}
}
} // namespace pixel
} // namespace impl
} // namespace power

View file

@ -13,24 +13,29 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#pragma once
#include <condition_variable>
#include <memory>
#include <mutex>
#include <string>
#include <thread>
namespace aidl {
namespace google {
namespace hardware {
namespace power {
namespace impl {
namespace pixel {
enum InteractionState {
INTERACTION_STATE_UNINITIALIZED,
INTERACTION_STATE_IDLE,
INTERACTION_STATE_INTERACTION,
INTERACTION_STATE_WAITING,
};
class InteractionHandler {
public:
InteractionHandler();
@ -38,13 +43,16 @@ class InteractionHandler {
bool Init();
void Exit();
void Acquire(int32_t duration);
private:
void Release();
void WaitForIdle(int32_t wait_ms, int32_t timeout_ms);
void AbortWaitLocked();
void Routine();
void PerfLock();
void PerfRel();
enum InteractionState mState;
int mIdleFd;
int mEventFd;
@ -54,6 +62,7 @@ class InteractionHandler {
std::mutex mLock;
std::condition_variable mCond;
};
} // namespace pixel
} // namespace impl
} // namespace power

View file

@ -13,8 +13,11 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#define LOG_TAG "powerhal-libperfmgr"
#include "Power.h"
#include <android-base/file.h>
#include <android-base/logging.h>
#include <android-base/properties.h>
@ -22,29 +25,37 @@
#include <android-base/strings.h>
#include <perfmgr/HintManager.h>
#include <utils/Log.h>
#include <mutex>
#include "PowerHintSession.h"
#include "PowerSessionManager.h"
namespace aidl {
namespace google {
namespace hardware {
namespace power {
namespace impl {
namespace pixel {
using ::aidl::google::hardware::power::impl::pixel::PowerHintSession;
using ::android::perfmgr::HintManager;
#ifdef MODE_EXT
extern bool isDeviceSpecificModeSupported(Mode type, bool* _aidl_return);
extern bool setDeviceSpecificMode(Mode type, bool enabled);
#endif
constexpr char kPowerHalStateProp[] = "vendor.powerhal.state";
constexpr char kPowerHalAudioProp[] = "vendor.powerhal.audio";
constexpr char kPowerHalRenderingProp[] = "vendor.powerhal.rendering";
Power::Power()
: mInteractionHandler(nullptr),
mSustainedPerfModeOn(false) {
mInteractionHandler = std::make_unique<InteractionHandler>();
mInteractionHandler->Init();
std::string state = ::android::base::GetProperty(kPowerHalStateProp, "");
if (state == "SUSTAINED_PERFORMANCE") {
LOG(INFO) << "Initialize with SUSTAINED_PERFORMANCE on";
@ -53,17 +64,20 @@ Power::Power()
} else {
LOG(INFO) << "Initialize PowerHAL";
}
state = ::android::base::GetProperty(kPowerHalAudioProp, "");
if (state == "AUDIO_STREAMING_LOW_LATENCY") {
LOG(INFO) << "Initialize with AUDIO_LOW_LATENCY on";
HintManager::GetInstance()->DoHint(state);
}
state = ::android::base::GetProperty(kPowerHalRenderingProp, "");
if (state == "EXPENSIVE_RENDERING") {
LOG(INFO) << "Initialize with EXPENSIVE_RENDERING on";
HintManager::GetInstance()->DoHint("EXPENSIVE_RENDERING");
}
}
ndk::ScopedAStatus Power::setMode(Mode type, bool enabled) {
LOG(DEBUG) << "Power setMode: " << toString(type) << " to: " << enabled;
if (HintManager::GetInstance()->GetAdpfProfile() &&
@ -116,14 +130,17 @@ ndk::ScopedAStatus Power::setMode(Mode type, bool enabled) {
}
break;
}
return ndk::ScopedAStatus::ok();
}
ndk::ScopedAStatus Power::isModeSupported(Mode type, bool *_aidl_return) {
#ifdef MODE_EXT
if (isDeviceSpecificModeSupported(type, _aidl_return)) {
return ndk::ScopedAStatus::ok();
}
#endif
bool supported = HintManager::GetInstance()->IsHintSupported(toString(type));
#ifdef TAP_TO_WAKE_NODE
if (type == Mode::DOUBLE_TAP_TO_WAKE) {
@ -134,6 +151,7 @@ ndk::ScopedAStatus Power::isModeSupported(Mode type, bool *_aidl_return) {
*_aidl_return = supported;
return ndk::ScopedAStatus::ok();
}
ndk::ScopedAStatus Power::setBoost(Boost type, int32_t durationMs) {
LOG(DEBUG) << "Power setBoost: " << toString(type) << " duration: " << durationMs;
if (HintManager::GetInstance()->GetAdpfProfile() &&
@ -167,17 +185,21 @@ ndk::ScopedAStatus Power::setBoost(Boost type, int32_t durationMs) {
}
break;
}
return ndk::ScopedAStatus::ok();
}
ndk::ScopedAStatus Power::isBoostSupported(Boost type, bool *_aidl_return) {
bool supported = HintManager::GetInstance()->IsHintSupported(toString(type));
LOG(INFO) << "Power boost " << toString(type) << " isBoostSupported: " << supported;
*_aidl_return = supported;
return ndk::ScopedAStatus::ok();
}
constexpr const char *boolToString(bool b) {
return b ? "true" : "false";
}
binder_status_t Power::dump(int fd, const char **, uint32_t) {
std::string buf(::android::base::StringPrintf(
"HintManager Running: %s\n"
@ -193,6 +215,7 @@ binder_status_t Power::dump(int fd, const char **, uint32_t) {
fsync(fd);
return STATUS_OK;
}
ndk::ScopedAStatus Power::createHintSession(int32_t tgid, int32_t uid,
const std::vector<int32_t> &threadIds,
int64_t durationNanos,
@ -212,6 +235,7 @@ ndk::ScopedAStatus Power::createHintSession(int32_t tgid, int32_t uid,
*_aidl_return = session;
return ndk::ScopedAStatus::ok();
}
ndk::ScopedAStatus Power::getHintSessionPreferredRate(int64_t *outNanoseconds) {
*outNanoseconds = HintManager::GetInstance()->GetAdpfProfile()
? HintManager::GetInstance()->GetAdpfProfile()->mReportingRateLimitNs
@ -219,8 +243,10 @@ ndk::ScopedAStatus Power::getHintSessionPreferredRate(int64_t *outNanoseconds) {
if (*outNanoseconds <= 0) {
return ndk::ScopedAStatus::fromExceptionCode(EX_UNSUPPORTED_OPERATION);
}
return ndk::ScopedAStatus::ok();
}
} // namespace pixel
} // namespace impl
} // namespace power

View file

@ -13,21 +13,28 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#pragma once
#include <aidl/android/hardware/power/BnPower.h>
#include <atomic>
#include <memory>
#include <thread>
#include "InteractionHandler.h"
namespace aidl {
namespace google {
namespace hardware {
namespace power {
namespace impl {
namespace pixel {
using ::aidl::android::hardware::power::Boost;
using ::aidl::android::hardware::power::IPowerHintSession;
using ::aidl::android::hardware::power::Mode;
class Power : public ::aidl::android::hardware::power::BnPower {
public:
Power();
@ -41,10 +48,12 @@ class Power : public ::aidl::android::hardware::power::BnPower {
std::shared_ptr<IPowerHintSession> *_aidl_return) override;
ndk::ScopedAStatus getHintSessionPreferredRate(int64_t *outNanoseconds) override;
binder_status_t dump(int fd, const char **args, uint32_t numArgs) override;
private:
std::unique_ptr<InteractionHandler> mInteractionHandler;
std::atomic<bool> mSustainedPerfModeOn;
};
} // namespace pixel
} // namespace impl
} // namespace power

View file

@ -13,8 +13,11 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#define LOG_TAG "android.hardware.power-service.xiaomi.ext-libperfmgr"
#define LOG_TAG "android.hardware.power-service.lenovo-sdm710-libperfmgr"
#include "PowerExt.h"
#include <android-base/file.h>
#include <android-base/logging.h>
#include <android-base/properties.h>
@ -22,17 +25,23 @@
#include <android-base/strings.h>
#include <perfmgr/HintManager.h>
#include <utils/Log.h>
#include <mutex>
#include "PowerSessionManager.h"
namespace aidl {
namespace google {
namespace hardware {
namespace power {
namespace impl {
namespace pixel {
using ::android::perfmgr::HintManager;
ndk::ScopedAStatus PowerExt::setMode(const std::string &mode, bool enabled) {
LOG(DEBUG) << "PowerExt setMode: " << mode << " to: " << enabled;
if (enabled) {
HintManager::GetInstance()->DoHint(mode);
} else {
@ -42,20 +51,24 @@ ndk::ScopedAStatus PowerExt::setMode(const std::string &mode, bool enabled) {
HintManager::GetInstance()->GetAdpfProfile()->mReportingRateLimitNs > 0) {
PowerSessionManager::getInstance()->updateHintMode(mode, enabled);
}
return ndk::ScopedAStatus::ok();
}
ndk::ScopedAStatus PowerExt::isModeSupported(const std::string &mode, bool *_aidl_return) {
bool supported = HintManager::GetInstance()->IsHintSupported(mode);
LOG(INFO) << "PowerExt mode " << mode << " isModeSupported: " << supported;
*_aidl_return = supported;
return ndk::ScopedAStatus::ok();
}
ndk::ScopedAStatus PowerExt::setBoost(const std::string &boost, int32_t durationMs) {
LOG(DEBUG) << "PowerExt setBoost: " << boost << " duration: " << durationMs;
if (HintManager::GetInstance()->GetAdpfProfile() &&
HintManager::GetInstance()->GetAdpfProfile()->mReportingRateLimitNs > 0) {
PowerSessionManager::getInstance()->updateHintBoost(boost, durationMs);
}
if (durationMs > 0) {
HintManager::GetInstance()->DoHint(boost, std::chrono::milliseconds(durationMs));
} else if (durationMs == 0) {
@ -63,14 +76,17 @@ ndk::ScopedAStatus PowerExt::setBoost(const std::string &boost, int32_t duration
} else {
HintManager::GetInstance()->EndHint(boost);
}
return ndk::ScopedAStatus::ok();
}
ndk::ScopedAStatus PowerExt::isBoostSupported(const std::string &boost, bool *_aidl_return) {
bool supported = HintManager::GetInstance()->IsHintSupported(boost);
LOG(INFO) << "PowerExt boost " << boost << " isBoostSupported: " << supported;
*_aidl_return = supported;
return ndk::ScopedAStatus::ok();
}
} // namespace pixel
} // namespace impl
} // namespace power

View file

@ -13,18 +13,23 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#pragma once
#include <atomic>
#include <memory>
#include <thread>
#include <aidl/google/hardware/power/extension/pixel/BnPowerExt.h>
#include <perfmgr/HintManager.h>
namespace aidl {
namespace google {
namespace hardware {
namespace power {
namespace impl {
namespace pixel {
class PowerExt : public ::aidl::google::hardware::power::extension::pixel::BnPowerExt {
public:
PowerExt() {}
@ -32,8 +37,10 @@ class PowerExt : public ::aidl::google::hardware::power::extension::pixel::BnPow
ndk::ScopedAStatus isModeSupported(const std::string &mode, bool *_aidl_return) override;
ndk::ScopedAStatus setBoost(const std::string &boost, int32_t durationMs) override;
ndk::ScopedAStatus isBoostSupported(const std::string &boost, bool *_aidl_return) override;
private:
};
} // namespace pixel
} // namespace impl
} // namespace power

View file

@ -13,9 +13,12 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#define LOG_TAG "powerhal-libperfmgr"
#define ATRACE_TAG (ATRACE_TAG_POWER | ATRACE_TAG_HAL)
#include "PowerHintSession.h"
#include <android-base/logging.h>
#include <android-base/parsedouble.h>
#include <android-base/properties.h>
@ -25,24 +28,32 @@
#include <sys/syscall.h>
#include <time.h>
#include <utils/Trace.h>
#include <atomic>
#include "PowerSessionManager.h"
namespace aidl {
namespace google {
namespace hardware {
namespace power {
namespace impl {
namespace pixel {
using ::android::base::StringPrintf;
using ::android::perfmgr::AdpfConfig;
using ::android::perfmgr::HintManager;
using std::chrono::duration_cast;
using std::chrono::nanoseconds;
namespace {
static inline int64_t ns_to_100us(int64_t ns) {
return ns / 100000;
}
} // namespace
int64_t PowerHintSession::convertWorkDurationToBoostByPid(
const std::vector<WorkDuration> &actualDurations) {
std::shared_ptr<AdpfConfig> adpfConfig = HintManager::GetInstance()->GetAdpfProfile();
@ -90,6 +101,7 @@ int64_t PowerHintSession::convertWorkDurationToBoostByPid(
int64_t dOut =
static_cast<int64_t>((derivative_sum > 0 ? adpfConfig->mPidDo : adpfConfig->mPidDu) *
derivative_sum / dt / (length - d_start));
int64_t output = pOut + iOut + dOut;
if (ATRACE_ENABLED()) {
traceSessionVal("pid.err", err_sum / (length - p_start));
@ -102,6 +114,7 @@ int64_t PowerHintSession::convertWorkDurationToBoostByPid(
}
return output;
}
PowerHintSession::PowerHintSession(int32_t tgid, int32_t uid, const std::vector<int32_t> &threadIds,
int64_t durationNanos) {
mDescriptor = new AppHintDesc(tgid, uid, threadIds);
@ -120,6 +133,7 @@ PowerHintSession::PowerHintSession(int32_t tgid, int32_t uid, const std::vector<
setSessionUclampMin(HintManager::GetInstance()->GetAdpfProfile()->mUclampMinInit);
ALOGV("PowerHintSession created: %s", mDescriptor->toString().c_str());
}
PowerHintSession::~PowerHintSession() {
close();
ALOGV("PowerHintSession deleted: %s", mDescriptor->toString().c_str());
@ -130,13 +144,16 @@ PowerHintSession::~PowerHintSession() {
}
delete mDescriptor;
}
void PowerHintSession::traceSessionVal(char const *identifier, int64_t val) const {
ATRACE_INT(StringPrintf("adpf.%s-%s", mIdString.c_str(), identifier).c_str(), val);
}
bool PowerHintSession::isAppSession() {
// Check if uid is in range reserved for applications
return mDescriptor->uid >= AID_APP_START;
}
void PowerHintSession::updateUniveralBoostMode() {
if (!isAppSession()) {
return;
@ -150,6 +167,7 @@ void PowerHintSession::updateUniveralBoostMode() {
ATRACE_END();
}
}
void PowerHintSession::tryToSendPowerHint(std::string hint) {
if (!mSupportedHints[hint].has_value()) {
mSupportedHints[hint] = HintManager::GetInstance()->IsHintSupported(hint);
@ -158,6 +176,7 @@ void PowerHintSession::tryToSendPowerHint(std::string hint) {
HintManager::GetInstance()->DoHint(hint);
}
}
int PowerHintSession::setSessionUclampMin(int32_t min) {
{
std::lock_guard<std::mutex> guard(mSessionLock);
@ -167,20 +186,24 @@ int PowerHintSession::setSessionUclampMin(int32_t min) {
mStaleTimerHandler->updateTimer();
}
PowerSessionManager::getInstance()->setUclampMin(this, min);
if (ATRACE_ENABLED()) {
traceSessionVal("min", min);
}
return 0;
}
int PowerHintSession::getUclampMin() {
return mDescriptor->current_min;
}
void PowerHintSession::dumpToStream(std::ostream &stream) {
stream << "ID.Min.Act.Timeout(" << mIdString;
stream << ", " << mDescriptor->current_min;
stream << ", " << mDescriptor->is_active;
stream << ", " << isTimeout() << ")";
}
ndk::ScopedAStatus PowerHintSession::pause() {
if (mSessionClosed) {
ALOGE("Error: session is dead");
@ -197,6 +220,7 @@ ndk::ScopedAStatus PowerHintSession::pause() {
updateUniveralBoostMode();
return ndk::ScopedAStatus::ok();
}
ndk::ScopedAStatus PowerHintSession::resume() {
if (mSessionClosed) {
ALOGE("Error: session is dead");
@ -213,6 +237,7 @@ ndk::ScopedAStatus PowerHintSession::resume() {
updateUniveralBoostMode();
return ndk::ScopedAStatus::ok();
}
ndk::ScopedAStatus PowerHintSession::close() {
bool sessionClosedExpectedToBe = false;
if (!mSessionClosed.compare_exchange_strong(sessionClosedExpectedToBe, true)) {
@ -226,6 +251,7 @@ ndk::ScopedAStatus PowerHintSession::close() {
updateUniveralBoostMode();
return ndk::ScopedAStatus::ok();
}
ndk::ScopedAStatus PowerHintSession::updateTargetWorkDuration(int64_t targetDurationNanos) {
if (mSessionClosed) {
ALOGE("Error: session is dead");
@ -238,12 +264,15 @@ ndk::ScopedAStatus PowerHintSession::updateTargetWorkDuration(int64_t targetDura
targetDurationNanos =
targetDurationNanos * HintManager::GetInstance()->GetAdpfProfile()->mTargetTimeFactor;
ALOGV("update target duration: %" PRId64 " ns", targetDurationNanos);
mDescriptor->duration = std::chrono::nanoseconds(targetDurationNanos);
if (ATRACE_ENABLED()) {
traceSessionVal("target", mDescriptor->duration.count());
}
return ndk::ScopedAStatus::ok();
}
ndk::ScopedAStatus PowerHintSession::reportActualWorkDuration(
const std::vector<WorkDuration> &actualDurations) {
if (mSessionClosed) {
@ -274,6 +303,7 @@ ndk::ScopedAStatus PowerHintSession::reportActualWorkDuration(
actualDurations.back().durationNanos - mDescriptor->duration.count() > 0);
traceSessionVal("session_hint", -1);
}
mLastUpdatedTime.store(std::chrono::steady_clock::now());
if (isFirstFrame) {
if (isAppSession()) {
@ -281,18 +311,22 @@ ndk::ScopedAStatus PowerHintSession::reportActualWorkDuration(
}
updateUniveralBoostMode();
}
if (!adpfConfig->mPidOn) {
setSessionUclampMin(adpfConfig->mUclampMinHigh);
return ndk::ScopedAStatus::ok();
}
int64_t output = convertWorkDurationToBoostByPid(actualDurations);
/* apply to all the threads in the group */
int next_min = std::min(static_cast<int>(adpfConfig->mUclampMinHigh),
mDescriptor->current_min + static_cast<int>(output));
next_min = std::max(static_cast<int>(adpfConfig->mUclampMinLow), next_min);
setSessionUclampMin(next_min);
return ndk::ScopedAStatus::ok();
}
std::string AppHintDesc::toString() const {
std::string out =
StringPrintf("session %" PRIxPTR "\n", reinterpret_cast<uintptr_t>(this) & 0xffff);
@ -300,6 +334,7 @@ std::string AppHintDesc::toString() const {
out.append(StringPrintf(" duration: %" PRId64 " ns\n", durationNanos));
out.append(StringPrintf(" uclamp.min: %d \n", current_min));
out.append(StringPrintf(" uid: %d, tgid: %d\n", uid, tgid));
out.append(" threadIds: [");
bool first = true;
for (int tid : threadIds) {
@ -312,9 +347,11 @@ std::string AppHintDesc::toString() const {
out.append("]\n");
return out;
}
bool PowerHintSession::isActive() {
return mDescriptor->is_active.load();
}
bool PowerHintSession::isTimeout() {
auto now = std::chrono::steady_clock::now();
time_point<steady_clock> staleTime =
@ -324,9 +361,11 @@ bool PowerHintSession::isTimeout() {
HintManager::GetInstance()->GetAdpfProfile()->mStaleTimeFactor));
return now >= staleTime;
}
const std::vector<int> &PowerHintSession::getTidList() const {
return mDescriptor->threadIds;
}
void PowerHintSession::setStale() {
// Reset to default uclamp value.
PowerSessionManager::getInstance()->setUclampMin(this, 0);
@ -336,6 +375,7 @@ void PowerHintSession::setStale() {
traceSessionVal("min", 0);
}
}
void PowerHintSession::StaleTimerHandler::updateTimer() {
auto now = std::chrono::steady_clock::now();
nanoseconds staleDuration = std::chrono::nanoseconds(
@ -353,6 +393,7 @@ void PowerHintSession::StaleTimerHandler::updateTimer() {
mSession->traceSessionVal("timer.stale", 0);
}
}
void PowerHintSession::StaleTimerHandler::handleMessage(const Message &) {
std::lock_guard<std::mutex> guard(mClosedLock);
if (mIsSessionDead) {
@ -377,11 +418,13 @@ void PowerHintSession::StaleTimerHandler::handleMessage(const Message &) {
mSession->traceSessionVal("timer.stale", next > 0 ? 0 : 1);
}
}
void PowerHintSession::StaleTimerHandler::setSessionDead() {
std::lock_guard<std::mutex> guard(mClosedLock);
mIsSessionDead = true;
PowerHintMonitor::getInstance()->getLooper()->removeMessages(mSession->mStaleTimerHandler);
}
} // namespace pixel
} // namespace impl
} // namespace power

View file

@ -13,19 +13,24 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#pragma once
#include <aidl/android/hardware/power/BnPowerHintSession.h>
#include <aidl/android/hardware/power/WorkDuration.h>
#include <utils/Looper.h>
#include <utils/Thread.h>
#include <mutex>
#include <unordered_map>
namespace aidl {
namespace google {
namespace hardware {
namespace power {
namespace impl {
namespace pixel {
using aidl::android::hardware::power::BnPowerHintSession;
using aidl::android::hardware::power::WorkDuration;
using ::android::Message;
@ -35,6 +40,7 @@ using std::chrono::milliseconds;
using std::chrono::nanoseconds;
using std::chrono::steady_clock;
using std::chrono::time_point;
struct AppHintDesc {
AppHintDesc(int32_t tgid, int32_t uid, std::vector<int> threadIds)
: tgid(tgid),
@ -59,6 +65,7 @@ struct AppHintDesc {
int64_t integral_error;
int64_t previous_error;
};
class PowerHintSession : public BnPowerHintSession {
public:
explicit PowerHintSession(int32_t tgid, int32_t uid, const std::vector<int32_t> &threadIds,
@ -78,7 +85,9 @@ class PowerHintSession : public BnPowerHintSession {
const std::vector<int> &getTidList() const;
int getUclampMin();
void dumpToStream(std::ostream &stream);
time_point<steady_clock> getStaleTime();
private:
class StaleTimerHandler : public MessageHandler {
public:
@ -86,6 +95,7 @@ class PowerHintSession : public BnPowerHintSession {
void updateTimer();
void handleMessage(const Message &message) override;
void setSessionDead();
private:
PowerHintSession *mSession;
std::mutex mClosedLock;
@ -93,6 +103,7 @@ class PowerHintSession : public BnPowerHintSession {
std::atomic<time_point<steady_clock>> mStaleTime;
bool mIsSessionDead;
};
private:
void updateUniveralBoostMode();
int setSessionUclampMin(int32_t min);
@ -109,6 +120,7 @@ class PowerHintSession : public BnPowerHintSession {
// To cache the status of whether ADPF hints are supported.
std::unordered_map<std::string, std::optional<bool>> mSupportedHints;
};
} // namespace pixel
} // namespace impl
} // namespace power

View file

@ -13,23 +13,29 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#define LOG_TAG "powerhal-libperfmgr"
#define ATRACE_TAG (ATRACE_TAG_POWER | ATRACE_TAG_HAL)
#include "PowerSessionManager.h"
#include <android-base/file.h>
#include <log/log.h>
#include <perfmgr/HintManager.h>
#include <processgroup/processgroup.h>
#include <sys/syscall.h>
#include <utils/Trace.h>
namespace aidl {
namespace google {
namespace hardware {
namespace power {
namespace impl {
namespace pixel {
using ::android::perfmgr::AdpfConfig;
using ::android::perfmgr::HintManager;
namespace {
/* there is no glibc or bionic wrapper */
struct sched_attr {
@ -44,6 +50,7 @@ struct sched_attr {
__u32 sched_util_min;
__u32 sched_util_max;
};
static int sched_setattr(int pid, struct sched_attr *attr, unsigned int flags) {
if (!HintManager::GetInstance()->GetAdpfProfile()->mUclampMinOn) {
ALOGV("PowerSessionManager:%s: skip", __func__);
@ -51,20 +58,25 @@ static int sched_setattr(int pid, struct sched_attr *attr, unsigned int flags) {
}
return syscall(__NR_sched_setattr, pid, attr, flags);
}
static void set_uclamp_min(int tid, int min) {
static constexpr int32_t kMaxUclampValue = 1024;
min = std::max(0, min);
min = std::min(min, kMaxUclampValue);
sched_attr attr = {};
attr.size = sizeof(attr);
attr.sched_flags = (SCHED_FLAG_KEEP_ALL | SCHED_FLAG_UTIL_CLAMP_MIN);
attr.sched_util_min = min;
int ret = sched_setattr(tid, &attr, 0);
if (ret) {
ALOGW("sched_setattr failed for thread %d, err=%d", tid, errno);
}
}
} // namespace
void PowerSessionManager::updateHintMode(const std::string &mode, bool enabled) {
ALOGV("PowerSessionManager::updateHintMode: mode: %s, enabled: %d", mode.c_str(), enabled);
if (enabled && mode.compare(0, 8, "REFRESH_") == 0) {
@ -80,14 +92,17 @@ void PowerSessionManager::updateHintMode(const std::string &mode, bool enabled)
HintManager::GetInstance()->SetAdpfProfile(mode);
}
}
void PowerSessionManager::updateHintBoost(const std::string &boost, int32_t durationMs) {
ATRACE_CALL();
ALOGV("PowerSessionManager::updateHintBoost: boost: %s, durationMs: %d", boost.c_str(),
durationMs);
}
int PowerSessionManager::getDisplayRefreshRate() {
return mDisplayRefreshRate;
}
void PowerSessionManager::addPowerSession(PowerHintSession *session) {
std::lock_guard<std::mutex> guard(mLock);
for (auto t : session->getTidList()) {
@ -108,6 +123,7 @@ void PowerSessionManager::addPowerSession(PowerHintSession *session) {
}
mSessions.insert(session);
}
void PowerSessionManager::removePowerSession(PowerHintSession *session) {
std::lock_guard<std::mutex> guard(mLock);
for (auto t : session->getTidList()) {
@ -126,10 +142,12 @@ void PowerSessionManager::removePowerSession(PowerHintSession *session) {
}
mSessions.erase(session);
}
void PowerSessionManager::setUclampMin(PowerHintSession *session, int val) {
std::lock_guard<std::mutex> guard(mLock);
setUclampMinLocked(session, val);
}
void PowerSessionManager::setUclampMinLocked(PowerHintSession *session, int val) {
for (auto t : session->getTidList()) {
// Get thex max uclamp.min across sessions which include the tid.
@ -142,6 +160,7 @@ void PowerSessionManager::setUclampMinLocked(PowerHintSession *session, int val)
set_uclamp_min(t, std::max(val, tidMax));
}
}
std::optional<bool> PowerSessionManager::isAnyAppSessionActive() {
std::lock_guard<std::mutex> guard(mLock);
bool active = false;
@ -157,8 +176,10 @@ std::optional<bool> PowerSessionManager::isAnyAppSessionActive() {
} else {
mActive = active;
}
return active;
}
void PowerSessionManager::handleMessage(const Message &) {
auto active = isAnyAppSessionActive();
if (!active.has_value()) {
@ -170,6 +191,7 @@ void PowerSessionManager::handleMessage(const Message &) {
enableSystemTopAppBoost();
}
}
void PowerSessionManager::dumpToFd(int fd) {
std::ostringstream dump_buf;
std::lock_guard<std::mutex> guard(mLock);
@ -191,33 +213,39 @@ void PowerSessionManager::dumpToFd(int fd) {
ALOGE("Failed to dump one of session list to fd:%d", fd);
}
}
void PowerSessionManager::enableSystemTopAppBoost() {
if (HintManager::GetInstance()->IsHintSupported(kDisableBoostHintName)) {
ALOGV("PowerSessionManager::enableSystemTopAppBoost!!");
HintManager::GetInstance()->EndHint(kDisableBoostHintName);
}
}
void PowerSessionManager::disableSystemTopAppBoost() {
if (HintManager::GetInstance()->IsHintSupported(kDisableBoostHintName)) {
ALOGV("PowerSessionManager::disableSystemTopAppBoost!!");
HintManager::GetInstance()->DoHint(kDisableBoostHintName);
}
}
// =========== PowerHintMonitor implementation start from here ===========
void PowerHintMonitor::start() {
if (!isRunning()) {
run("PowerHintMonitor", ::android::PRIORITY_HIGHEST);
}
}
bool PowerHintMonitor::threadLoop() {
while (true) {
mLooper->pollOnce(-1);
}
return true;
}
sp<Looper> PowerHintMonitor::getLooper() {
return mLooper;
}
} // namespace pixel
} // namespace impl
} // namespace power

View file

@ -13,26 +13,34 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#pragma once
#include <android-base/properties.h>
#include <perfmgr/HintManager.h>
#include <utils/Looper.h>
#include <mutex>
#include <optional>
#include <unordered_set>
#include "PowerHintSession.h"
namespace aidl {
namespace google {
namespace hardware {
namespace power {
namespace impl {
namespace pixel {
using ::android::Looper;
using ::android::Message;
using ::android::MessageHandler;
using ::android::Thread;
using ::android::perfmgr::HintManager;
constexpr char kPowerHalAdpfDisableTopAppBoost[] = "vendor.powerhal.adpf.disable.hint";
class PowerSessionManager : public MessageHandler {
public:
// current hint info
@ -46,16 +54,19 @@ class PowerSessionManager : public MessageHandler {
void setUclampMinLocked(PowerHintSession *session, int min);
void handleMessage(const Message &message) override;
void dumpToFd(int fd);
// Singleton
static sp<PowerSessionManager> getInstance() {
static sp<PowerSessionManager> instance = new PowerSessionManager();
return instance;
}
private:
std::optional<bool> isAnyAppSessionActive();
void disableSystemTopAppBoost();
void enableSystemTopAppBoost();
const std::string kDisableBoostHintName;
std::unordered_set<PowerHintSession *> mSessions; // protected by mLock
std::unordered_map<int, int> mTidRefCountMap; // protected by mLock
std::unordered_map<int, std::unordered_set<PowerHintSession *>> mTidSessionListMap;
@ -74,6 +85,7 @@ class PowerSessionManager : public MessageHandler {
PowerSessionManager(PowerSessionManager const &) = delete;
void operator=(PowerSessionManager const &) = delete;
};
class PowerHintMonitor : public Thread {
public:
void start();
@ -86,11 +98,13 @@ class PowerHintMonitor : public Thread {
}
PowerHintMonitor(PowerHintMonitor const &) = delete;
void operator=(PowerHintMonitor const &) = delete;
private:
sp<Looper> mLooper;
// Singleton
PowerHintMonitor() : Thread(false), mLooper(new Looper(true)) {}
};
} // namespace pixel
} // namespace impl
} // namespace power

View file

@ -1,25 +1,32 @@
service vendor.power-hal-aidl /vendor/bin/hw/android.hardware.power-service.xiaomi-libperfmgr
service vendor.power-hal-aidl /vendor/bin/hw/android.hardware.power-service.lenovo-sdm710-libperfmgr
class hal
user root
group system
priority -20
on late-fs
start vendor.power-hal-aidl
# Restart powerHAL when framework died
on property:init.svc.zygote=restarting && property:vendor.powerhal.state=*
setprop vendor.powerhal.state ""
setprop vendor.powerhal.audio ""
setprop vendor.powerhal.rendering ""
restart vendor.power-hal-aidl
# Clean up after b/163539793 resolved
on property:vendor.powerhal.dalvik.vm.dex2oat-threads=*
setprop dalvik.vm.dex2oat-threads ${vendor.powerhal.dalvik.vm.dex2oat-threads}
setprop dalvik.vm.restore-dex2oat-threads ${vendor.powerhal.dalvik.vm.dex2oat-threads}
on property:vendor.powerhal.dalvik.vm.dex2oat-cpu-set=*
setprop dalvik.vm.dex2oat-cpu-set ${vendor.powerhal.dalvik.vm.dex2oat-cpu-set}
setprop dalvik.vm.restore-dex2oat-cpu-set ${vendor.powerhal.dalvik.vm.dex2oat-cpu-set}
# Restart powerHAL when debug property set
on property:ro.debuggable=1 && property:vendor.powerhal.config.debug=*
restart vendor.power-hal-aidl
on property:persist.vendor.powerhal.config.debug=*
setprop vendor.powerhal.config.debug ${persist.vendor.powerhal.config.debug}

View file

@ -13,55 +13,71 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#define LOG_TAG "powerhal-libperfmgr"
#include <android-base/logging.h>
#include <android-base/properties.h>
#include <android/binder_ibinder_platform.h>
#include <android/binder_manager.h>
#include <android/binder_process.h>
#include <perfmgr/HintManager.h>
#include <thread>
#include "Power.h"
#include "PowerExt.h"
#include "PowerSessionManager.h"
using aidl::google::hardware::power::impl::pixel::Power;
using aidl::google::hardware::power::impl::pixel::PowerExt;
using aidl::google::hardware::power::impl::pixel::PowerHintMonitor;
using aidl::google::hardware::power::impl::pixel::PowerSessionManager;
using ::android::perfmgr::HintManager;
constexpr std::string_view kPowerHalInitProp("vendor.powerhal.init");
int main() {
// Parse config but do not start the looper
std::shared_ptr<HintManager> hm = std::shared_ptr<HintManager>(HintManager::GetInstance());
std::shared_ptr<HintManager> hm = HintManager::GetInstance();
if (!hm) {
LOG(FATAL) << "HintManager Init failed";
}
// single thread
ABinderProcess_setThreadPoolMaxThreadCount(0);
// core service
std::shared_ptr<Power> pw = ndk::SharedRefBase::make<Power>();
ndk::SpAIBinder pwBinder = pw->asBinder();
AIBinder_setMinSchedulerPolicy(pwBinder.get(), SCHED_NORMAL, -20);
// extension service
std::shared_ptr<PowerExt> pwExt = ndk::SharedRefBase::make<PowerExt>();
auto pwExtBinder = pwExt->asBinder();
AIBinder_setMinSchedulerPolicy(pwExtBinder.get(), SCHED_NORMAL, -20);
// attach the extension to the same binder we will be registering
CHECK(STATUS_OK == AIBinder_setExtension(pwBinder.get(), pwExt->asBinder().get()));
const std::string instance = std::string() + Power::descriptor + "/default";
binder_status_t status = AServiceManager_addService(pw->asBinder().get(), instance.c_str());
CHECK(status == STATUS_OK);
LOG(INFO) << "Xiaomi Power HAL AIDL Service with Extension is started.";
LOG(INFO) << "Lenovo Power HAL AIDL Service with Extension is started.";
if (HintManager::GetInstance()->GetAdpfProfile()) {
PowerHintMonitor::getInstance()->start();
}
std::thread initThread([&]() {
::android::base::WaitForProperty(kPowerHalInitProp.data(), "1");
HintManager::GetInstance()->Start();
});
initThread.detach();
ABinderProcess_joinThreadPool();
// should not reach
LOG(ERROR) << "Xiaomi Power HAL AIDL Service with Extension just died.";
LOG(ERROR) << "Lenovo Power HAL AIDL Service with Extension just died.";
return EXIT_FAILURE;
}

View file

@ -1,50 +0,0 @@
# Copyright (c) 2009-2012, 2014-2015, The Linux Foundation. All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
# * Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
# * Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in the
# documentation and/or other materials provided with the distribution.
# * Neither the name of The Linux Foundation nor
# the names of its contributors may be used to endorse or promote
# products derived from this software without specific prior written
# permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
# IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
# NON-INFRINGEMENT ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
# OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#
#import /init.recovery.qcom_decrypt.rc
on fs
wait /dev/block/platform/soc/${ro.boot.bootdevice}
symlink /dev/block/platform/soc/${ro.boot.bootdevice} /dev/block/bootdevice
export ANDROID_ROOT /system_root
on early-init
# Enable double-tap to wake
write /sys/devices/virtual/touch/tp_dev/gesture_on 1
on init
# Workaround for setting AVB version
setprop sys.usb.configfs 1
setprop ro.boot.avb_version 1.0
setprop ro.boot.vbmeta.avb_version ${ro.boot.avb_version}
setprop vendor.gatekeeper.disable_spu true
#on boot
# setprop sys.usb.config adb
# start health-hal-2-1
# chown system system /sys/class/touch/tp_dev/gesture_on
# chown 0660 /sys/class/touch/tp_dev/gesture_on

View file

@ -1,124 +0,0 @@
# Copyright (c) 2011-2016, The Linux Foundation. All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
# * Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
# * Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in the
# documentation and/or other materials provided with the distribution.
# * Neither the name of The Linux Foundation nor
# the names of its contributors may be used to endorse or promote
# products derived from this software without specific prior written
# permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
# IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
# NON-INFRINGEMENT ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
# OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#
on boot
write /sys/class/android_usb/android0/iSerial ${ro.serialno}
mount configfs none /config
mkdir /config/usb_gadget/g1 0770
mkdir /config/usb_gadget/g2 0770
mkdir /config/usb_gadget/g1/strings/0x409 0770
mkdir /config/usb_gadget/g2/strings/0x409 0770
write /config/usb_gadget/g1/bcdUSB 0x0200
write /config/usb_gadget/g2/bcdUSB 0x0200
write /config/usb_gadget/g1/os_desc/use 1
write /config/usb_gadget/g1/strings/0x409/serialnumber ${ro.serialno}
write /config/usb_gadget/g2/strings/0x409/serialnumber ${ro.serialno}
write /config/usb_gadget/g1/strings/0x409/manufacturer ${ro.product.manufacturer}
write /config/usb_gadget/g2/strings/0x409/manufacturer ${ro.product.manufacturer}
write /config/usb_gadget/g1/strings/0x409/product ${ro.product.model}
write /config/usb_gadget/g2/strings/0x409/product ${ro.product.model}
mkdir /config/usb_gadget/g1/functions/mass_storage.0
mkdir /config/usb_gadget/g1/functions/mtp.gs0
mkdir /config/usb_gadget/g1/functions/ptp.gs1
mkdir /config/usb_gadget/g1/functions/accessory.gs2
mkdir /config/usb_gadget/g1/functions/audio_source.gs3
mkdir /config/usb_gadget/g1/functions/midi.gs5
mkdir /config/usb_gadget/g1/functions/ffs.adb
mkdir /config/usb_gadget/g1/functions/diag.diag
mkdir /config/usb_gadget/g1/functions/diag.diag_mdm
mkdir /config/usb_gadget/g1/functions/cser.dun.0
mkdir /config/usb_gadget/g1/functions/cser.nmea.1
mkdir /config/usb_gadget/g1/functions/cser.dun.2
mkdir /config/usb_gadget/g1/functions/gsi.rmnet
mkdir /config/usb_gadget/g1/functions/gsi.rndis
mkdir /config/usb_gadget/g1/functions/gsi.dpl
mkdir /config/usb_gadget/g1/functions/qdss.qdss
mkdir /config/usb_gadget/g1/functions/qdss.qdss_mdm
mkdir /config/usb_gadget/g1/functions/rndis_bam.rndis
mkdir /config/usb_gadget/g1/functions/rndis.rndis
mkdir /config/usb_gadget/g1/functions/rmnet_bam.rmnet
mkdir /config/usb_gadget/g1/functions/rmnet_bam.dpl
mkdir /config/usb_gadget/g1/functions/rmnet_bam.rmnet_bam_dmux
mkdir /config/usb_gadget/g1/functions/rmnet_bam.dpl_bam_dmux
mkdir /config/usb_gadget/g1/functions/ncm.0
mkdir /config/usb_gadget/g1/functions/ccid.ccid
mkdir /config/usb_gadget/g1/functions/uac2.0
mkdir /config/usb_gadget/g1/functions/uvc.0
mkdir /config/usb_gadget/g1/configs/b.1 0770
mkdir /config/usb_gadget/g2/configs/b.1 0770
mkdir /config/usb_gadget/g1/configs/b.1/strings/0x409 0770
mkdir /config/usb_gadget/g2/configs/b.1/strings/0x409 0770
write /config/usb_gadget/g1/os_desc/b_vendor_code 0x1
write /config/usb_gadget/g1/os_desc/qw_sign "MSFT100"
symlink /config/usb_gadget/g1/configs/b.1 /config/usb_gadget/g1/os_desc/b.1
mkdir /dev/usb-ffs 0775 shell system
mkdir /dev/usb-ffs/adb 0770 shell system
mount functionfs adb /dev/usb-ffs/adb uid=2000,gid=1000,rmode=0770,fmode=0660
write /sys/class/android_usb/android0/f_ffs/aliases adb
setprop vendor.usb.controller ${sys.usb.controller}
on property:sys.usb.config=none
write /config/usb_gadget/g1/UDC "none"
stop adbd
setprop sys.usb.ffs.ready 0
write /config/usb_gadget/g1/bDeviceClass 0
write /config/usb_gadget/g1/bDeviceSubClass 0
write /config/usb_gadget/g1/bDeviceProtocol 0
setprop sys.usb.state ${sys.usb.config}
on property:sys.usb.config=mtp,adb
start adbd
on property:sys.usb.ffs.ready=1 && property:sys.usb.config=mtp,adb
write /config/usb_gadget/g1/configs/b.1/strings/0x409/configuration "mtp_adb"
rm /config/usb_gadget/g1/configs/b.1/f1
rm /config/usb_gadget/g1/configs/b.1/f2
rm /config/usb_gadget/g1/configs/b.1/f3
rm /config/usb_gadget/g1/configs/b.1/f4
rm /config/usb_gadget/g1/configs/b.1/f5
write /config/usb_gadget/g1/idVendor 0x05C6
write /config/usb_gadget/g1/idProduct 0x9039
symlink /config/usb_gadget/g1/functions/mtp.gs0 /config/usb_gadget/g1/configs/b.1/f1
symlink /config/usb_gadget/g1/functions/ffs.adb /config/usb_gadget/g1/configs/b.1/f2
write /config/usb_gadget/g1/UDC ${sys.usb.controller}
setprop sys.usb.state ${sys.usb.config}
on property:sys.usb.config=sideload
start adbd
on property:sys.usb.ffs.ready=1 && property:sys.usb.config=sideload
write /config/usb_gadget/g1/configs/b.1/strings/0x409/configuration "adb"
rm /config/usb_gadget/g1/configs/b.1/f1
rm /config/usb_gadget/g1/configs/b.1/f2
rm /config/usb_gadget/g1/configs/b.1/f3
rm /config/usb_gadget/g1/configs/b.1/f4
rm /config/usb_gadget/g1/configs/b.1/f5
write /config/usb_gadget/g1/idVendor 0x18d1
write /config/usb_gadget/g1/idProduct 0x4ee7
symlink /config/usb_gadget/g1/functions/ffs.adb /config/usb_gadget/g1/configs/b.1/f1
write /config/usb_gadget/g1/UDC ${sys.usb.controller}
setprop sys.usb.state ${sys.usb.config}

View file

@ -62,23 +62,6 @@ PRODUCT_COPY_FILES += \
frameworks/native/data/etc/android.software.midi.xml:$(TARGET_COPY_OUT_VENDOR)/etc/permissions/android.software.midi.xml \
frameworks/native/data/etc/android.software.sip.voip.xml:$(TARGET_COPY_OUT_VENDOR)/etc/permissions/android.software.sip.voip.xml
# QPR3
PRODUCT_PACKAGES += \
libaudioroute \
libaudioroute.vendor \
libstagefrighthw \
libstagefright_softomx_plugin.vendor \
libprocessgroup.vendor \
libsqlite.vendor \
liblz4.vendor \
libssl.vendor \
libcurl.vendor \
libjsoncpp.vendor \
libsqlite.vendor \
libtinyxml \
libavservices_minijail.vendor \
libpng.vendor
# AID/fs configs
PRODUCT_PACKAGES += \
fs_config_files
@ -160,11 +143,6 @@ PRODUCT_PACKAGES += \
init.target.rc \
ueventd.qcom.rc
# Recovery init
PRODUCT_COPY_FILES += \
$(LOCAL_PATH)/rootdir/etc/init.recovery.qcom.rc:$(TARGET_RECOVERY_OUT)/root/init.recovery.qcom.rc \
$(LOCAL_PATH)/rootdir/etc/init.recovery.usb.rc:$(TARGET_RECOVERY_OUT)/root/init.recovery.usb.rc
# Codec2
PRODUCT_PACKAGES += \
libcodec2_vndk.vendor \
@ -219,10 +197,6 @@ PRODUCT_PACKAGES += \
android.hardware.drm@1.3.vendor \
android.hardware.drm-service.clearkey
# CBS_init
PRODUCT_PACKAGES += \
libcrypto-v33
# Fastbootd
PRODUCT_PACKAGES += \
fastbootd
@ -258,9 +232,7 @@ PRODUCT_PACKAGES += \
# Fingerprint
PRODUCT_PACKAGES += \
android.hardware.biometrics.fingerprint-service.xiaomi \
android.hardware.biometrics.fingerprint@2.1.vendor \
android.hardware.biometrics.fingerprint@2.1.vendor
# Dynamic Partitions
PRODUCT_BUILD_SUPER_PARTITION := false
@ -320,7 +292,7 @@ PRODUCT_PACKAGES += \
# Media
PRODUCT_PACKAGES += \
#android.hardware.media.omx@1.0-impl \
android.hardware.media.omx@1.0-impl \
android.hardware.media.omx@1.0-service \
libavservices_minijail \
libavservices_minijail.vendor \
@ -393,7 +365,7 @@ PRODUCT_PACKAGES += \
android.hardware.power@1.2 \
android.hardware.power@1.2.vendor \
android.hardware.power.stats@1.0-service.mock \
android.hardware.power-service.xiaomi-libperfmgr
android.hardware.power-service.lenovo-sdm710-libperfmgr
PRODUCT_COPY_FILES += \
$(LOCAL_PATH)/configs/powerhint.json:$(TARGET_COPY_OUT_VENDOR)/etc/powerhint.json
@ -464,7 +436,6 @@ PRODUCT_PACKAGES += \
# Soong namespaces
PRODUCT_SOONG_NAMESPACES += \
$(LOCAL_PATH) \
hardware/xiaomi \
hardware/google/interfaces \
hardware/google/pixel \
vendor/qcom/opensource/commonsys/system/bt/conf \
@ -480,8 +451,8 @@ PRODUCT_ALWAYS_PREOPT_EXTRACTED_APK := true
PRODUCT_PACKAGES += \
telephony-ext
#PRODUCT_BOOT_JARS += \
# telephony-ext
PRODUCT_BOOT_JARS += \
telephony-ext
PRODUCT_PACKAGES += \
qti-telephony-hidl-wrapper \
@ -495,8 +466,8 @@ PRODUCT_PACKAGES += \
# Thermal
PRODUCT_PACKAGES += \
android.hardware.thermal@2.0-service.mock
android.hardware.thermal@2.0-service.qti
PRODUCT_COPY_FILES += \
$(LOCAL_PATH)/configs/thermal-engine.conf:$(TARGET_COPY_OUT_VENDOR)/etc/thermal-engine.conf

View file

@ -13,13 +13,11 @@
# HALs
/vendor/bin/hw/android\.hardware\.light@2\.0-service\.lenovo_sdm710 u:object_r:hal_light_default_exec:s0
#/vendor/bin/hw/android\.hardware\.power@1\.3-service\.lenovo-libperfmgr u:object_r:hal_power_default_exec:s0
#/vendor/bin/hw/android\.hardware\.power-service\.lenovo-sdm710-libperfmgr u:object_r:hal_power_default_exec:s0
/vendor/bin/hw/android\.hardware\.power-service\.xiaomi-libperfmgr u:object_r:hal_power_default_exec:s0
/vendor/bin/hw/android\.hardware\.biometrics\.fingerprint-service\.xiaomi u:object_r:hal_fingerprint_default_exec:s0
/vendor/bin/hw/android\.hardware\.power@1\.3-service\.lenovo-libperfmgr u:object_r:hal_power_default_exec:s0
/vendor/bin/hw/android\.hardware\.power-service\.lenovo-sdm710-libperfmgr u:object_r:hal_power_default_exec:s0
/vendor/bin/hw/android\.hardware\.biometrics\.fingerprint@2\.1-fpcservice u:object_r:hal_fingerprint_default_exec:s0
/vendor/bin/hw/android\.hardware\.atrace@1.0-service\.pixel u:object_r:hal_atrace_default_exec:s0
/vendor/bin/hw/android\.hardware\.neuralnetworks@1\.2-service-qti u:object_r:hal_neuralnetworks_default_exec:s0
/(vendor|system/vendor)/bin/hw/android\.hardware\.thermal@2\.0-service\.mock u:object_r:hal_thermal_default_exec:s0
# Allystar GPS
/sys/ontim_bootinfo/gps_avdd_en u:object_r:sysfs_gps:s0

View file

@ -1,3 +1 @@
type vendor_persist_block_device, dev_type;
allow fsck self:capability { sys_admin kill };