diff --git a/device.mk b/device.mk index 66822fade..77d93d388 100755 --- a/device.mk +++ b/device.mk @@ -170,7 +170,7 @@ PRODUCT_COPY_FILES += \ # power HAL PRODUCT_PACKAGES += \ - android.hardware.power@1.1-service.wahoo + android.hardware.power@1.2-service.wahoo PRODUCT_COPY_FILES += \ $(LOCAL_PATH)/powerhint.xml:$(TARGET_COPY_OUT_VENDOR)/etc/powerhint.xml @@ -611,7 +611,7 @@ PRODUCT_PROPERTY_OVERRIDES += \ # Enable CameraHAL perfd usage PRODUCT_PROPERTY_OVERRIDES += \ - persist.camera.perfd.enable=true + persist.camera.perfd.enable=false # Enable Gcam FD Ensemble PRODUCT_PROPERTY_OVERRIDES += \ diff --git a/manifest.xml b/manifest.xml index 6cd9ba826..ae293f11e 100644 --- a/manifest.xml +++ b/manifest.xml @@ -219,7 +219,7 @@ android.hardware.power hwbinder - 1.1 + 1.2 IPower default diff --git a/power/Android.mk b/power/Android.mk index f2e291884..1e9071e49 100644 --- a/power/Android.mk +++ b/power/Android.mk @@ -21,8 +21,8 @@ LOCAL_PROPRIETARY_MODULE := true LOCAL_MODULE_OWNER := qcom LOCAL_MODULE_TAGS := optional -LOCAL_MODULE := android.hardware.power@1.1-service.wahoo -LOCAL_INIT_RC := android.hardware.power@1.1-service.wahoo.rc +LOCAL_MODULE := android.hardware.power@1.2-service.wahoo +LOCAL_INIT_RC := android.hardware.power@1.2-service.wahoo.rc LOCAL_SRC_FILES := service.cpp \ Power.cpp \ InteractionHandler.cpp \ @@ -53,6 +53,6 @@ LOCAL_SHARED_LIBRARIES := \ libhidltransport \ libhardware \ libutils \ - android.hardware.power@1.1 \ + android.hardware.power@1.2 \ include $(BUILD_EXECUTABLE) diff --git a/power/Power.cpp b/power/Power.cpp index 81f5db9f2..700663a59 100644 --- a/power/Power.cpp +++ b/power/Power.cpp @@ -14,10 +14,10 @@ * limitations under the License. */ -#define LOG_TAG "android.hardware.power@1.1-service.wahoo" +#define LOG_TAG "android.hardware.power@1.2-service.wahoo" -#include #include +#include #include #include #include @@ -33,14 +33,14 @@ extern struct stat_pair rpm_stat_map[]; namespace android { namespace hardware { namespace power { -namespace V1_1 { +namespace V1_2 { namespace implementation { using ::android::hardware::power::V1_0::Feature; -using ::android::hardware::power::V1_0::PowerHint; using ::android::hardware::power::V1_0::PowerStatePlatformSleepState; using ::android::hardware::power::V1_0::Status; using ::android::hardware::power::V1_1::PowerStateSubsystem; +using ::android::hardware::power::V1_1::PowerStateSubsystemSleepState; using ::android::hardware::hidl_vec; using ::android::hardware::Return; using ::android::hardware::Void; @@ -59,9 +59,9 @@ Return Power::setInteractive(bool interactive) { return Void(); } -Return Power::powerHint(PowerHint hint, int32_t data) { +Return Power::powerHint(PowerHint_1_0 hint, int32_t data) { if (android::base::GetProperty("init.svc.vendor.perfd", "") != "running") { - ALOGW("perfd is not started"); + LOG(WARNING) << "perfd is not started"; return Void(); } @@ -192,18 +192,42 @@ bool Power::isSupportedGovernor() { if (buf == SCHEDUTIL_GOVERNOR || buf == SCHED_GOVERNOR || buf == INTERACTIVE_GOVERNOR) { return true; } else { - ALOGE("Governor not supported by powerHAL, skipping"); + LOG(ERROR) << "Governor not supported by powerHAL, skipping"; return false; } } -Return Power::powerHintAsync(PowerHint hint, int32_t data) { +Return Power::powerHintAsync(PowerHint_1_0 hint, int32_t data) { // just call the normal power hint in this oneway function return powerHint(hint, data); } +// Methods from ::android::hardware::power::V1_2::IPower follow. +Return Power::powerHintAsync_1_2(PowerHint_1_2 hint, int32_t data) { + switch(hint) { + case PowerHint_1_2::AUDIO_LOW_LATENCY: + process_audio_low_latency_hint(data); + break; + case PowerHint_1_2::AUDIO_STREAMING: + process_audio_streaming_hint(data); + break; + case PowerHint_1_2::CAMERA_LAUNCH: + process_camera_launch_hint(data); + break; + case PowerHint_1_2::CAMERA_STREAMING: + process_camera_streaming_hint(data); + break; + case PowerHint_1_2::CAMERA_SHOT: + process_camera_shot_hint(data); + break; + default: + return powerHint(static_cast(hint), data); + } + return Void(); +} + } // namespace implementation -} // namespace V1_1 +} // namespace V1_2 } // namespace power } // namespace hardware } // namespace android diff --git a/power/Power.h b/power/Power.h index 9d4f79fd7..650a5181d 100644 --- a/power/Power.h +++ b/power/Power.h @@ -14,10 +14,10 @@ * limitations under the License. */ -#ifndef ANDROID_HARDWARE_POWER_V1_1_POWER_H -#define ANDROID_HARDWARE_POWER_V1_1_POWER_H +#ifndef ANDROID_HARDWARE_POWER_V1_2_POWER_H +#define ANDROID_HARDWARE_POWER_V1_2_POWER_H -#include +#include #include #include #include @@ -27,15 +27,16 @@ namespace android { namespace hardware { namespace power { -namespace V1_1 { +namespace V1_2 { namespace implementation { using ::android::hardware::power::V1_0::Feature; -using ::android::hardware::power::V1_0::PowerHint; -using ::android::hardware::power::V1_1::IPower; +using ::android::hardware::power::V1_2::IPower; using ::android::hardware::Return; using ::android::hardware::Void; using ::InteractionHandler; +using PowerHint_1_0 = ::android::hardware::power::V1_0::PowerHint; +using PowerHint_1_2 = ::android::hardware::power::V1_2::PowerHint; struct Power : public IPower { // Methods from ::android::hardware::power::V1_0::IPower follow. @@ -43,13 +44,16 @@ struct Power : public IPower { Power(); Return setInteractive(bool interactive) override; - Return powerHint(PowerHint hint, int32_t data) override; + Return powerHint(PowerHint_1_0 hint, int32_t data) override; Return setFeature(Feature feature, bool activate) override; Return getPlatformLowPowerStats(getPlatformLowPowerStats_cb _hidl_cb) override; // Methods from ::android::hardware::power::V1_1::IPower follow. Return getSubsystemLowPowerStats(getSubsystemLowPowerStats_cb _hidl_cb) override; - Return powerHintAsync(PowerHint hint, int32_t data) override; + Return powerHintAsync(PowerHint_1_0 hint, int32_t data) override; + + // Methods from ::android::hardware::power::V1_2::IPower follow. + Return powerHintAsync_1_2(PowerHint_1_2 hint, int32_t data) override; // Methods from ::android::hidl::base::V1_0::IBase follow. @@ -59,9 +63,9 @@ struct Power : public IPower { }; } // namespace implementation -} // namespace V1_1 +} // namespace V1_2 } // namespace power } // namespace hardware } // namespace android -#endif // ANDROID_HARDWARE_POWER_V1_1_POWER_H +#endif // ANDROID_HARDWARE_POWER_V1_2_POWER_H diff --git a/power/android.hardware.power@1.1-service.wahoo.rc b/power/android.hardware.power@1.1-service.wahoo.rc deleted file mode 100644 index cb31655ab..000000000 --- a/power/android.hardware.power@1.1-service.wahoo.rc +++ /dev/null @@ -1,4 +0,0 @@ -service vendor.power-hal-1-1 /vendor/bin/hw/android.hardware.power@1.1-service.wahoo - class hal - user system - group system diff --git a/power/android.hardware.power@1.2-service.wahoo.rc b/power/android.hardware.power@1.2-service.wahoo.rc new file mode 100644 index 000000000..dd5537c72 --- /dev/null +++ b/power/android.hardware.power@1.2-service.wahoo.rc @@ -0,0 +1,4 @@ +service vendor.power-hal-1-2 /vendor/bin/hw/android.hardware.power@1.2-service.wahoo + class hal + user system + group system diff --git a/power/hint-data.h b/power/hint-data.h index 7be3b3b25..6885396ad 100644 --- a/power/hint-data.h +++ b/power/hint-data.h @@ -39,6 +39,12 @@ #define INTERACTION_HINT_ID (0x1A00) #define BOOST_HINT_ID (0x1B00) +#define CAMERA_LAUNCH_HINT_ID (0x0B0A) +#define CAMERA_STREAMING_HINT_ID (0x0C0A) +#define CAMERA_SHOT_HINT_ID (0x0D0A) +#define AUDIO_STREAMING_HINT_ID (0x0E0A) +#define AUDIO_LOW_LATENCY_HINT_ID (0x0F0A) + struct hint_data { unsigned long hint_id; /* This is our key. */ unsigned long perflock_handle; diff --git a/power/power-8998.c b/power/power-8998.c index dbc6542f5..869f23b64 100644 --- a/power/power-8998.c +++ b/power/power-8998.c @@ -180,18 +180,18 @@ static int process_vr_mode_hint(void *data) return HINT_HANDLED; } -static int process_boost(int boost_handle, int duration) +static int process_boost(int hint_id, int boost_handle, int duration) { int *resource_values; int resources; - resource_values = getPowerhint(BOOST_HINT_ID, &resources); + resource_values = getPowerhint(hint_id, &resources); if (resource_values != NULL) { boost_handle = interaction_with_handle( boost_handle, duration, resources, resource_values); if (!CHECK_HANDLE(boost_handle)) { - ALOGE("Failed interaction_with_handle for boost_handle"); + ALOGE("Failed interaction_with_handle for hint_id %d", hint_id); } } @@ -205,7 +205,7 @@ static int process_video_encode_hint(void *data) if (data) { // TODO: remove the launch boost based on camera launch time int duration = 2000; // boosts 2s for starting encoding - boost_handle = process_boost(boost_handle, duration); + boost_handle = process_boost(BOOST_HINT_ID, boost_handle, duration); ALOGD("LAUNCH ENCODER-ON: %d MS", duration); int *resource_values = NULL; int resources = 0; @@ -222,6 +222,95 @@ static int process_video_encode_hint(void *data) return HINT_NONE; } +int process_camera_launch_hint(int32_t duration) +{ + static int cam_launch_handle = -1; + + if (duration > 0) { + cam_launch_handle = process_boost(CAMERA_LAUNCH_HINT_ID, cam_launch_handle, duration); + ALOGD("CAMERA LAUNCH ON: %d MS", duration); + return HINT_HANDLED; + } else if (duration == 0) { + release_request(cam_launch_handle); + ALOGD("CAMERA LAUNCH OFF"); + return HINT_HANDLED; + } else { + ALOGE("CAMERA LAUNCH INVALID DATA: %d", duration); + } + return HINT_NONE; +} + +int process_camera_streaming_hint(int32_t duration) +{ + static int cam_streaming_handle = -1; + + if (duration > 0) { + cam_streaming_handle = process_boost(CAMERA_STREAMING_HINT_ID, cam_streaming_handle, duration); + ALOGD("CAMERA STREAMING ON: %d MS", duration); + return HINT_HANDLED; + } else if (duration == 0) { + release_request(cam_streaming_handle); + ALOGD("CAMERA STREAMING OFF"); + return HINT_HANDLED; + } else { + ALOGE("CAMERA STREAMING INVALID DATA: %d", duration); + } + return HINT_NONE; +} + +int process_camera_shot_hint(int32_t duration) +{ + static int cam_shot_handle = -1; + + if (duration > 0) { + cam_shot_handle = process_boost(CAMERA_SHOT_HINT_ID, cam_shot_handle, duration); + ALOGD("CAMERA SHOT ON: %d MS", duration); + return HINT_HANDLED; + } else if (duration == 0) { + release_request(cam_shot_handle); + ALOGD("CAMERA SHOT OFF"); + return HINT_HANDLED; + } else { + ALOGE("CAMERA SHOT INVALID DATA: %d", duration); + } + return HINT_NONE; +} + +int process_audio_streaming_hint(int32_t duration) +{ + static int audio_streaming_handle = -1; + + if (duration > 0) { + // set max duration 2s for starting audio + audio_streaming_handle = process_boost(AUDIO_STREAMING_HINT_ID, audio_streaming_handle, 2000); + ALOGD("AUDIO STREAMING ON"); + return HINT_HANDLED; + } else if (duration == 0) { + release_request(audio_streaming_handle); + ALOGD("AUDIO STREAMING OFF"); + return HINT_HANDLED; + } else { + ALOGE("AUDIO STREAMING INVALID DATA: %d", duration); + } + return HINT_NONE; +} + +int process_audio_low_latency_hint(int32_t data) +{ + static int audio_low_latency_handle = -1; + + if (data) { + // Hint until canceled + audio_low_latency_handle = process_boost(AUDIO_LOW_LATENCY_HINT_ID, audio_low_latency_handle, 0); + ALOGD("AUDIO LOW LATENCY ON"); + } else { + release_request(audio_low_latency_handle); + ALOGD("AUDIO LOW LATENCY OFF"); + return HINT_HANDLED; + } + return HINT_HANDLED; +} + static int process_activity_launch_hint(void *data) { // boost will timeout in 1.25s @@ -236,7 +325,7 @@ static int process_activity_launch_hint(void *data) // restart the launch hint if the framework has not yet released // this shouldn't happen, but we've seen bugs where it could if (data) { - launch_handle = process_boost(launch_handle, duration); + launch_handle = process_boost(BOOST_HINT_ID, launch_handle, duration); if (launch_handle > 0) { launch_mode = 1; ALOGD("Activity launch hint handled"); diff --git a/power/power-helper.h b/power/power-helper.h index b2ef147aa..6117cabad 100644 --- a/power/power-helper.h +++ b/power/power-helper.h @@ -102,6 +102,12 @@ int extract_wlan_stats(uint64_t *list); int is_perf_hint_active(int hint); +int process_camera_launch_hint(int32_t duration); +int process_camera_streaming_hint(int32_t duration); +int process_camera_shot_hint(int32_t duration); +int process_audio_streaming_hint(int32_t duration); +int process_audio_low_latency_hint(int32_t data); + #ifdef __cplusplus } #endif diff --git a/power/powerhintparser.h b/power/powerhintparser.h index c1da1de1e..971a472a7 100644 --- a/power/powerhintparser.h +++ b/power/powerhintparser.h @@ -31,7 +31,7 @@ #define __POWERHINTPARSER__ #define POWERHINT_XML "/vendor/etc/powerhint.xml" -#define MAX_HINT 8 +#define MAX_HINT 16 #define MAX_PARAM 30 typedef struct perflock_param_t { diff --git a/power/service.cpp b/power/service.cpp index 5b3a47d65..54e6d826d 100644 --- a/power/service.cpp +++ b/power/service.cpp @@ -14,7 +14,7 @@ * limitations under the License. */ -#define LOG_TAG "android.hardware.power@1.1-service.wahoo" +#define LOG_TAG "android.hardware.power@1.2-service.wahoo" #include #include @@ -30,15 +30,15 @@ using android::hardware::configureRpcThreadpool; using android::hardware::joinRpcThreadpool; // Generated HIDL files -using android::hardware::power::V1_1::IPower; -using android::hardware::power::V1_1::implementation::Power; +using android::hardware::power::V1_2::IPower; +using android::hardware::power::V1_2::implementation::Power; int main() { status_t status; android::sp service = nullptr; - ALOGI("Power HAL Service 1.1 for Wahoo is starting."); + ALOGI("Power HAL Service 1.2 for Wahoo is starting."); service = new Power(); if (service == nullptr) { diff --git a/powerhint.xml b/powerhint.xml index a87dfcdc6..01d6e4242 100755 --- a/powerhint.xml +++ b/powerhint.xml @@ -74,4 +74,29 @@ + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/sepolicy/vendor/audioserver.te b/sepolicy/vendor/audioserver.te index 02c801caf..4dd8b7cc9 100644 --- a/sepolicy/vendor/audioserver.te +++ b/sepolicy/vendor/audioserver.te @@ -1,6 +1,4 @@ binder_call(audioserver, bootanim) -allow audioserver perfd_socket:sock_file write; - allow audioserver sysfs_soc:file r_file_perms; allow audioserver sysfs_soc:dir search; diff --git a/sepolicy/vendor/file_contexts b/sepolicy/vendor/file_contexts index 95550cfbe..a4e7d2936 100644 --- a/sepolicy/vendor/file_contexts +++ b/sepolicy/vendor/file_contexts @@ -168,7 +168,7 @@ /vendor/bin/oemlock_provision u:object_r:hal_bootctl_default_exec:s0 /vendor/bin/oemlock-bridge u:object_r:hal_bootctl_default_exec:s0 /vendor/bin/hw/android\.hardware\.usb@1\.1-service.wahoo u:object_r:hal_usb_default_exec:s0 -/vendor/bin/hw/android\.hardware\.power@1\.1-service.wahoo u:object_r:hal_power_default_exec:s0 +/vendor/bin/hw/android\.hardware\.power@1\.2-service.wahoo u:object_r:hal_power_default_exec:s0 /vendor/bin/hw/android\.hardware\.thermal@1\.0-service.wahoo u:object_r:hal_thermal_default_exec:s0 /vendor/bin/chre u:object_r:chre_exec:s0 /vendor/bin/time_daemon u:object_r:time_daemon_exec:s0 diff --git a/sepolicy/vendor/hal_audio_default.te b/sepolicy/vendor/hal_audio_default.te index 357b4cdfb..47f4f7e3b 100644 --- a/sepolicy/vendor/hal_audio_default.te +++ b/sepolicy/vendor/hal_audio_default.te @@ -3,8 +3,10 @@ r_dir_file(hal_audio_default, sysfs_soc) allow hal_audio_default audio_vendor_data_file:dir rw_dir_perms; allow hal_audio_default audio_vendor_data_file:file create_file_perms; -allow hal_audio_default perfd:unix_stream_socket connectto; -allow hal_audio_default perfd_socket:sock_file write; +dontaudit hal_audio_default perfd:unix_stream_socket connectto; +dontaudit hal_audio_default perfd_socket:sock_file write; + +hal_client_domain(hal_audio_default, hal_power) userdebug_or_eng(` allow hal_audio diag_device:chr_file rw_file_perms;