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 # HIDL
DEVICE_MANIFEST_FILE := $(COMMON_PATH)/manifest.xml DEVICE_MANIFEST_FILE := $(COMMON_PATH)/manifest.xml
DEVICE_MATRIX_FILE := $(COMMON_PATH)/compatibility_matrix.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 # Partitions
BOARD_BOOTIMAGE_PARTITION_SIZE := 67108864 BOARD_BOOTIMAGE_PARTITION_SIZE := 67108864
@ -131,7 +127,6 @@ BOARD_ROOT_EXTRA_SYMLINKS := \
/vendor/firmware_mnt:/firmware /vendor/firmware_mnt:/firmware
# Recovery # Recovery
TARGET_RECOVERY_PIXEL_FORMAT := BGRA_8888
TARGET_RECOVERY_FSTAB := $(COMMON_PATH)/rootdir/etc/fstab.qcom TARGET_RECOVERY_FSTAB := $(COMMON_PATH)/rootdir/etc/fstab.qcom
# Releasetools # Releasetools

View file

@ -61,10 +61,7 @@ fi
function blob_fixup() { function blob_fixup() {
case "${1}" in case "${1}" in
vendor/etc/seccomp_policy/vendor.qti.hardware.dsp.policy) vendor/etc/seccomp_policy/vendor.qti.hardware.dsp.policy)
echo 'madvise: 1' >> "${2}" echo 'madvise: 1' >> ${2}
;;
vendor/lib/libwvhidl.so)
"${PATCHELF}" --replace-needed "libcrypto.so" "libcrypto-v33.so" "${2}"
;; ;;
esac 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"> <hal format="hidl">
<name>android.hardware.audio</name> <name>android.hardware.audio</name>
<transport>hwbinder</transport> <transport>hwbinder</transport>
@ -19,6 +19,16 @@
</interface> </interface>
<fqname>@6.0::IEffectsFactory/default</fqname> <fqname>@6.0::IEffectsFactory/default</fqname>
</hal> </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"> <hal format="hidl">
<name>android.hardware.bluetooth</name> <name>android.hardware.bluetooth</name>
<transport>hwbinder</transport> <transport>hwbinder</transport>

View file

@ -399,6 +399,14 @@
The default is false. --> The default is false. -->
<bool name="config_lidControlsSleep">true</bool> <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 --> <!-- SQLite -->
<string name="db_default_journal_mode">MEMORY</string> <string name="db_default_journal_mode">MEMORY</string>
<string name="db_default_sync_mode">OFF</string> <string name="db_default_sync_mode">OFF</string>
@ -419,6 +427,9 @@
2: gestures only for back, home and overview --> 2: gestures only for back, home and overview -->
<integer name="config_navBarInteractionMode">2</integer> <integer name="config_navBarInteractionMode">2</integer>
<!-- Specify if the fingerprint hardware support gestures-->
<bool name="config_fingerprintSupportsGestures">true</bool>
<!-- Enable system navigation keys. --> <!-- Enable system navigation keys. -->
<bool name="config_supportSystemNavigationKeys">true</bool> <bool name="config_supportSystemNavigationKeys">true</bool>

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -13,18 +13,23 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
#pragma once #pragma once
#include <atomic> #include <atomic>
#include <memory> #include <memory>
#include <thread> #include <thread>
#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>
namespace aidl { namespace aidl {
namespace google { namespace google {
namespace hardware { namespace hardware {
namespace power { namespace power {
namespace impl { namespace impl {
namespace pixel { namespace pixel {
class PowerExt : public ::aidl::google::hardware::power::extension::pixel::BnPowerExt { class PowerExt : public ::aidl::google::hardware::power::extension::pixel::BnPowerExt {
public: public:
PowerExt() {} 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 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;
ndk::ScopedAStatus isBoostSupported(const std::string &boost, bool *_aidl_return) override; ndk::ScopedAStatus isBoostSupported(const std::string &boost, bool *_aidl_return) override;
private: private:
}; };
} // namespace pixel } // namespace pixel
} // namespace impl } // namespace impl
} // namespace power } // namespace power

View file

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

View file

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

View file

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

View file

@ -13,26 +13,34 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
#pragma once #pragma once
#include <android-base/properties.h> #include <android-base/properties.h>
#include <perfmgr/HintManager.h> #include <perfmgr/HintManager.h>
#include <utils/Looper.h> #include <utils/Looper.h>
#include <mutex> #include <mutex>
#include <optional> #include <optional>
#include <unordered_set> #include <unordered_set>
#include "PowerHintSession.h" #include "PowerHintSession.h"
namespace aidl { namespace aidl {
namespace google { namespace google {
namespace hardware { namespace hardware {
namespace power { namespace power {
namespace impl { namespace impl {
namespace pixel { namespace pixel {
using ::android::Looper; using ::android::Looper;
using ::android::Message; using ::android::Message;
using ::android::MessageHandler; using ::android::MessageHandler;
using ::android::Thread; using ::android::Thread;
using ::android::perfmgr::HintManager; using ::android::perfmgr::HintManager;
constexpr char kPowerHalAdpfDisableTopAppBoost[] = "vendor.powerhal.adpf.disable.hint"; constexpr char kPowerHalAdpfDisableTopAppBoost[] = "vendor.powerhal.adpf.disable.hint";
class PowerSessionManager : public MessageHandler { class PowerSessionManager : public MessageHandler {
public: public:
// current hint info // current hint info
@ -46,16 +54,19 @@ class PowerSessionManager : public MessageHandler {
void setUclampMinLocked(PowerHintSession *session, int min); void setUclampMinLocked(PowerHintSession *session, int min);
void handleMessage(const Message &message) override; void handleMessage(const Message &message) override;
void dumpToFd(int fd); void dumpToFd(int fd);
// Singleton // Singleton
static sp<PowerSessionManager> getInstance() { static sp<PowerSessionManager> getInstance() {
static sp<PowerSessionManager> instance = new PowerSessionManager(); static sp<PowerSessionManager> instance = new PowerSessionManager();
return instance; return instance;
} }
private: private:
std::optional<bool> isAnyAppSessionActive(); std::optional<bool> isAnyAppSessionActive();
void disableSystemTopAppBoost(); void disableSystemTopAppBoost();
void enableSystemTopAppBoost(); void enableSystemTopAppBoost();
const std::string kDisableBoostHintName; const std::string kDisableBoostHintName;
std::unordered_set<PowerHintSession *> mSessions; // protected by mLock std::unordered_set<PowerHintSession *> mSessions; // protected by mLock
std::unordered_map<int, int> mTidRefCountMap; // protected by mLock std::unordered_map<int, int> mTidRefCountMap; // protected by mLock
std::unordered_map<int, std::unordered_set<PowerHintSession *>> mTidSessionListMap; std::unordered_map<int, std::unordered_set<PowerHintSession *>> mTidSessionListMap;
@ -74,6 +85,7 @@ class PowerSessionManager : public MessageHandler {
PowerSessionManager(PowerSessionManager const &) = delete; PowerSessionManager(PowerSessionManager const &) = delete;
void operator=(PowerSessionManager const &) = delete; void operator=(PowerSessionManager const &) = delete;
}; };
class PowerHintMonitor : public Thread { class PowerHintMonitor : public Thread {
public: public:
void start(); void start();
@ -86,11 +98,13 @@ class PowerHintMonitor : public Thread {
} }
PowerHintMonitor(PowerHintMonitor const &) = delete; PowerHintMonitor(PowerHintMonitor const &) = delete;
void operator=(PowerHintMonitor const &) = delete; void operator=(PowerHintMonitor const &) = delete;
private: private:
sp<Looper> mLooper; sp<Looper> mLooper;
// Singleton // Singleton
PowerHintMonitor() : Thread(false), mLooper(new Looper(true)) {} PowerHintMonitor() : Thread(false), mLooper(new Looper(true)) {}
}; };
} // namespace pixel } // namespace pixel
} // namespace impl } // namespace impl
} // namespace power } // 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 class hal
user root user root
group system group system
priority -20 priority -20
on late-fs on late-fs
start vendor.power-hal-aidl start vendor.power-hal-aidl
# Restart powerHAL when framework died # Restart powerHAL when framework died
on property:init.svc.zygote=restarting && property:vendor.powerhal.state=* on property:init.svc.zygote=restarting && property:vendor.powerhal.state=*
setprop vendor.powerhal.state "" setprop vendor.powerhal.state ""
setprop vendor.powerhal.audio "" setprop vendor.powerhal.audio ""
setprop vendor.powerhal.rendering "" setprop vendor.powerhal.rendering ""
restart vendor.power-hal-aidl restart vendor.power-hal-aidl
# Clean up after b/163539793 resolved # Clean up after b/163539793 resolved
on property:vendor.powerhal.dalvik.vm.dex2oat-threads=* on property:vendor.powerhal.dalvik.vm.dex2oat-threads=*
setprop dalvik.vm.dex2oat-threads ${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} setprop dalvik.vm.restore-dex2oat-threads ${vendor.powerhal.dalvik.vm.dex2oat-threads}
on property:vendor.powerhal.dalvik.vm.dex2oat-cpu-set=* 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.dex2oat-cpu-set ${vendor.powerhal.dalvik.vm.dex2oat-cpu-set}
setprop dalvik.vm.restore-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 # Restart powerHAL when debug property set
on property:ro.debuggable=1 && property:vendor.powerhal.config.debug=* on property:ro.debuggable=1 && property:vendor.powerhal.config.debug=*
restart vendor.power-hal-aidl restart vendor.power-hal-aidl
on property:persist.vendor.powerhal.config.debug=* on property:persist.vendor.powerhal.config.debug=*
setprop vendor.powerhal.config.debug ${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 * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
#define LOG_TAG "powerhal-libperfmgr" #define LOG_TAG "powerhal-libperfmgr"
#include <android-base/logging.h> #include <android-base/logging.h>
#include <android-base/properties.h> #include <android-base/properties.h>
#include <android/binder_ibinder_platform.h> #include <android/binder_ibinder_platform.h>
#include <android/binder_manager.h> #include <android/binder_manager.h>
#include <android/binder_process.h> #include <android/binder_process.h>
#include <perfmgr/HintManager.h> #include <perfmgr/HintManager.h>
#include <thread> #include <thread>
#include "Power.h" #include "Power.h"
#include "PowerExt.h" #include "PowerExt.h"
#include "PowerSessionManager.h" #include "PowerSessionManager.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;
using aidl::google::hardware::power::impl::pixel::PowerHintMonitor; using aidl::google::hardware::power::impl::pixel::PowerHintMonitor;
using aidl::google::hardware::power::impl::pixel::PowerSessionManager; using aidl::google::hardware::power::impl::pixel::PowerSessionManager;
using ::android::perfmgr::HintManager; using ::android::perfmgr::HintManager;
constexpr std::string_view kPowerHalInitProp("vendor.powerhal.init"); constexpr std::string_view kPowerHalInitProp("vendor.powerhal.init");
int main() { int main() {
// Parse config but do not start the looper // 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) { if (!hm) {
LOG(FATAL) << "HintManager Init failed"; LOG(FATAL) << "HintManager Init failed";
} }
// single thread // single thread
ABinderProcess_setThreadPoolMaxThreadCount(0); ABinderProcess_setThreadPoolMaxThreadCount(0);
// core service // core service
std::shared_ptr<Power> pw = ndk::SharedRefBase::make<Power>(); std::shared_ptr<Power> pw = ndk::SharedRefBase::make<Power>();
ndk::SpAIBinder pwBinder = pw->asBinder(); ndk::SpAIBinder pwBinder = pw->asBinder();
AIBinder_setMinSchedulerPolicy(pwBinder.get(), SCHED_NORMAL, -20); AIBinder_setMinSchedulerPolicy(pwBinder.get(), SCHED_NORMAL, -20);
// extension service // extension service
std::shared_ptr<PowerExt> pwExt = ndk::SharedRefBase::make<PowerExt>(); std::shared_ptr<PowerExt> pwExt = ndk::SharedRefBase::make<PowerExt>();
auto pwExtBinder = pwExt->asBinder(); auto pwExtBinder = pwExt->asBinder();
AIBinder_setMinSchedulerPolicy(pwExtBinder.get(), SCHED_NORMAL, -20); AIBinder_setMinSchedulerPolicy(pwExtBinder.get(), SCHED_NORMAL, -20);
// 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()));
const std::string instance = std::string() + Power::descriptor + "/default"; const std::string instance = std::string() + Power::descriptor + "/default";
binder_status_t status = AServiceManager_addService(pw->asBinder().get(), instance.c_str()); binder_status_t status = AServiceManager_addService(pw->asBinder().get(), instance.c_str());
CHECK(status == STATUS_OK); 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()) { if (HintManager::GetInstance()->GetAdpfProfile()) {
PowerHintMonitor::getInstance()->start(); PowerHintMonitor::getInstance()->start();
} }
std::thread initThread([&]() { std::thread initThread([&]() {
::android::base::WaitForProperty(kPowerHalInitProp.data(), "1"); ::android::base::WaitForProperty(kPowerHalInitProp.data(), "1");
HintManager::GetInstance()->Start(); HintManager::GetInstance()->Start();
}); });
initThread.detach(); initThread.detach();
ABinderProcess_joinThreadPool(); ABinderProcess_joinThreadPool();
// should not reach // 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; 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.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 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 # AID/fs configs
PRODUCT_PACKAGES += \ PRODUCT_PACKAGES += \
fs_config_files fs_config_files
@ -160,11 +143,6 @@ PRODUCT_PACKAGES += \
init.target.rc \ init.target.rc \
ueventd.qcom.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 # Codec2
PRODUCT_PACKAGES += \ PRODUCT_PACKAGES += \
libcodec2_vndk.vendor \ libcodec2_vndk.vendor \
@ -219,10 +197,6 @@ PRODUCT_PACKAGES += \
android.hardware.drm@1.3.vendor \ android.hardware.drm@1.3.vendor \
android.hardware.drm-service.clearkey android.hardware.drm-service.clearkey
# CBS_init
PRODUCT_PACKAGES += \
libcrypto-v33
# Fastbootd # Fastbootd
PRODUCT_PACKAGES += \ PRODUCT_PACKAGES += \
fastbootd fastbootd
@ -258,9 +232,7 @@ PRODUCT_PACKAGES += \
# Fingerprint # Fingerprint
PRODUCT_PACKAGES += \ PRODUCT_PACKAGES += \
android.hardware.biometrics.fingerprint-service.xiaomi \ android.hardware.biometrics.fingerprint@2.1.vendor
android.hardware.biometrics.fingerprint@2.1.vendor \
# Dynamic Partitions # Dynamic Partitions
PRODUCT_BUILD_SUPER_PARTITION := false PRODUCT_BUILD_SUPER_PARTITION := false
@ -320,7 +292,7 @@ PRODUCT_PACKAGES += \
# Media # Media
PRODUCT_PACKAGES += \ PRODUCT_PACKAGES += \
#android.hardware.media.omx@1.0-impl \ android.hardware.media.omx@1.0-impl \
android.hardware.media.omx@1.0-service \ android.hardware.media.omx@1.0-service \
libavservices_minijail \ libavservices_minijail \
libavservices_minijail.vendor \ libavservices_minijail.vendor \
@ -393,7 +365,7 @@ PRODUCT_PACKAGES += \
android.hardware.power@1.2 \ android.hardware.power@1.2 \
android.hardware.power@1.2.vendor \ android.hardware.power@1.2.vendor \
android.hardware.power.stats@1.0-service.mock \ android.hardware.power.stats@1.0-service.mock \
android.hardware.power-service.xiaomi-libperfmgr android.hardware.power-service.lenovo-sdm710-libperfmgr
PRODUCT_COPY_FILES += \ PRODUCT_COPY_FILES += \
$(LOCAL_PATH)/configs/powerhint.json:$(TARGET_COPY_OUT_VENDOR)/etc/powerhint.json $(LOCAL_PATH)/configs/powerhint.json:$(TARGET_COPY_OUT_VENDOR)/etc/powerhint.json
@ -464,7 +436,6 @@ PRODUCT_PACKAGES += \
# Soong namespaces # Soong namespaces
PRODUCT_SOONG_NAMESPACES += \ PRODUCT_SOONG_NAMESPACES += \
$(LOCAL_PATH) \ $(LOCAL_PATH) \
hardware/xiaomi \
hardware/google/interfaces \ hardware/google/interfaces \
hardware/google/pixel \ hardware/google/pixel \
vendor/qcom/opensource/commonsys/system/bt/conf \ vendor/qcom/opensource/commonsys/system/bt/conf \
@ -480,8 +451,8 @@ PRODUCT_ALWAYS_PREOPT_EXTRACTED_APK := true
PRODUCT_PACKAGES += \ PRODUCT_PACKAGES += \
telephony-ext telephony-ext
#PRODUCT_BOOT_JARS += \ PRODUCT_BOOT_JARS += \
# telephony-ext telephony-ext
PRODUCT_PACKAGES += \ PRODUCT_PACKAGES += \
qti-telephony-hidl-wrapper \ qti-telephony-hidl-wrapper \
@ -495,8 +466,8 @@ PRODUCT_PACKAGES += \
# Thermal # Thermal
PRODUCT_PACKAGES += \ PRODUCT_PACKAGES += \
android.hardware.thermal@2.0-service.mock android.hardware.thermal@2.0-service.qti
PRODUCT_COPY_FILES += \ PRODUCT_COPY_FILES += \
$(LOCAL_PATH)/configs/thermal-engine.conf:$(TARGET_COPY_OUT_VENDOR)/etc/thermal-engine.conf $(LOCAL_PATH)/configs/thermal-engine.conf:$(TARGET_COPY_OUT_VENDOR)/etc/thermal-engine.conf

View file

@ -13,13 +13,11 @@
# HALs # 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\.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@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\.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@2\.1-fpcservice u:object_r:hal_fingerprint_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\.atrace@1.0-service\.pixel u:object_r:hal_atrace_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/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 # Allystar GPS
/sys/ontim_bootinfo/gps_avdd_en u:object_r:sysfs_gps:s0 /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 }; allow fsck self:capability { sys_admin kill };