summaryrefslogtreecommitdiff
path: root/power-libperfmgr
diff options
context:
space:
mode:
authorWei Wang <wvw@google.com>2018-01-16 12:03:13 -0800
committerWei Wang <wvw@google.com>2018-01-17 12:13:06 -0800
commit48a226ea47a165fabcb9e3fdda38e412551032ca (patch)
treecf318a425d11089cad0489aced986dbc0a971a3a /power-libperfmgr
parentd20619cf6d449018bea170bd9a4a21ddf64c6899 (diff)
downloadbonito-48a226ea47a165fabcb9e3fdda38e412551032ca.tar.gz
Power: restart PowerHAL if audio HAL died with active low_latency hint
Audio low latency which can go parallel with other long-term hints and there is small change that leaves the powerHAL stuck with the hint for long time. This CL will require another property to record the state of it. Bug: 67648152 Test: kill audiohal, audioserver Change-Id: Ic0017b0c7a27994e7583d7701665b2cd156ca192
Diffstat (limited to 'power-libperfmgr')
-rw-r--r--power-libperfmgr/Power.cpp23
-rw-r--r--power-libperfmgr/Power.h1
-rw-r--r--power-libperfmgr/android.hardware.power@1.2-service.crosshatch-libperfmgr.rc7
3 files changed, 27 insertions, 4 deletions
diff --git a/power-libperfmgr/Power.cpp b/power-libperfmgr/Power.cpp
index 0bb205cb..98321458 100644
--- a/power-libperfmgr/Power.cpp
+++ b/power-libperfmgr/Power.cpp
@@ -74,9 +74,14 @@ Power::Power() :
mSustainedPerfModeOn = true;
mVRModeOn = true;
} else {
- ALOGI("Initialize with default setting");
+ ALOGI("Initialize PowerHAL");
}
+ state = android::base::GetProperty(kPowerHalAudioProp, "");
+ if (state == "LOW_LATENCY") {
+ ALOGI("Initialize with AUDIO_LOW_LATENCY on");
+ mHintManager->DoHint("AUDIO_LOW_LATENCY");
+ }
}
// Methods from ::android::hardware::power::V1_0::IPower follow.
@@ -98,6 +103,10 @@ Return<void> Power::powerHint(PowerHint_1_0 hint, int32_t data) {
}
break;
case PowerHint_1_0::VIDEO_ENCODE:
+ if (mVRModeOn || mSustainedPerfModeOn) {
+ ALOGV("%s: ignoring due to other active perf hints", __func__);
+ break;
+ }
ATRACE_BEGIN("video_encode");
if (mVRModeOn || mSustainedPerfModeOn) {
ALOGV("%s: ignoring due to other active perf hints", __func__);
@@ -353,10 +362,16 @@ Return<void> Power::powerHintAsync_1_2(PowerHint_1_2 hint, int32_t data) {
ATRACE_INT("audio_low_latency_lock", 1);
mHintManager->DoHint("AUDIO_LOW_LATENCY");
ALOGD("AUDIO LOW LATENCY ON");
+ if (!android::base::SetProperty(kPowerHalAudioProp, "LOW_LATENCY")) {
+ ALOGE("%s: could not set powerHAL audio state property to LOW_LATENCY", __func__);
+ }
} else {
ATRACE_INT("audio_low_latency_lock", 0);
mHintManager->EndHint("AUDIO_LOW_LATENCY");
ALOGD("AUDIO LOW LATENCY OFF");
+ if (!android::base::SetProperty(kPowerHalAudioProp, "")) {
+ ALOGE("%s: could not clear powerHAL audio state property", __func__);
+ }
}
ATRACE_END();
break;
@@ -366,11 +381,11 @@ Return<void> Power::powerHintAsync_1_2(PowerHint_1_2 hint, int32_t data) {
// Hint until canceled
ATRACE_INT("audio_streaming_lock", 1);
mHintManager->DoHint("AUDIO_STREAMING");
- ALOGD("AUDIO LOW LATENCY ON");
+ ALOGD("AUDIO STREAMING ON");
} else {
ATRACE_INT("audio_streaming_lock", 0);
mHintManager->EndHint("AUDIO_STREAMING");
- ALOGD("AUDIO LOW LATENCY OFF");
+ ALOGD("AUDIO STREAMING OFF");
}
ATRACE_END();
break;
@@ -379,7 +394,7 @@ Return<void> Power::powerHintAsync_1_2(PowerHint_1_2 hint, int32_t data) {
if (data > 0) {
ATRACE_INT("camera_launch_lock", 1);
mHintManager->DoHint("CAMERA_LAUNCH", std::chrono::milliseconds(data));
- ALOGD("CAMERA LAUNCH ON: %d MS", data);
+ ALOGD("CAMERA LAUNCH ON: %d MS, LAUNCH ON: 2500 MS", data);
// boosts 2.5s for launching
mHintManager->DoHint("LAUNCH", std::chrono::milliseconds(2500));
} else if (data == 0) {
diff --git a/power-libperfmgr/Power.h b/power-libperfmgr/Power.h
index 1b301c8c..d1eccbe4 100644
--- a/power-libperfmgr/Power.h
+++ b/power-libperfmgr/Power.h
@@ -42,6 +42,7 @@ using PowerHint_1_2 = ::android::hardware::power::V1_2::PowerHint;
using ::android::perfmgr::HintManager;
constexpr char kPowerHalStateProp[] = "vendor.powerhal.state";
+constexpr char kPowerHalAudioProp[] = "vendor.powerhal.audio";
struct Power : public IPower {
// Methods from ::android::hardware::power::V1_0::IPower follow.
diff --git a/power-libperfmgr/android.hardware.power@1.2-service.crosshatch-libperfmgr.rc b/power-libperfmgr/android.hardware.power@1.2-service.crosshatch-libperfmgr.rc
index 385504c7..3f328f76 100644
--- a/power-libperfmgr/android.hardware.power@1.2-service.crosshatch-libperfmgr.rc
+++ b/power-libperfmgr/android.hardware.power@1.2-service.crosshatch-libperfmgr.rc
@@ -6,9 +6,16 @@ service vendor.power-hal-1-2 /vendor/bin/hw/android.hardware.power@1.2-service.c
# restart powerHAL when framework died
on property:init.svc.zygote=restarting && property:vendor.powerhal.state=*
setprop vendor.powerhal.state ""
+ setprop vendor.powerhal.audio ""
restart vendor.power-hal-1-2
# restart powerHAL when cameraHAL died
on property:init.svc.vendor.camera-provider-2-4=restarting && property:vendor.powerhal.state=VIDEO_ENCODE
setprop vendor.powerhal.state ""
+ setprop vendor.powerhal.audio ""
+ restart vendor.power-hal-1-2
+
+# restart powerHAL when audioHAL died
+on property:init.svc.vendor.audio-hal-2-0=restarting && property:vendor.powerhal.audio=LOW_LATENCY
+ setprop vendor.powerhal.audio ""
restart vendor.power-hal-1-2