sdm845-common: power: Adapt extension to new aidl power HAL
Change-Id: I58ac49957d8d28ad904912986d89ac8db4820ff9
This commit is contained in:
parent
f4f5655e44
commit
8af17a83d4
@ -117,7 +117,7 @@ TARGET_USES_MKE2FS := true
|
||||
TARGET_COPY_OUT_VENDOR := vendor
|
||||
|
||||
# Power
|
||||
TARGET_POWER_SET_FEATURE_LIB := libpower_feature.xiaomi_sdm845
|
||||
TARGET_POWERHAL_MODE_EXT := $(COMMON_PATH)/power/power-mode.cpp
|
||||
|
||||
# Properties
|
||||
TARGET_ODM_PROP += $(COMMON_PATH)/odm.prop
|
||||
|
@ -1,16 +0,0 @@
|
||||
LOCAL_PATH := $(call my-dir)
|
||||
|
||||
include $(CLEAR_VARS)
|
||||
|
||||
LOCAL_MODULE := libpower_feature.xiaomi_sdm845
|
||||
LOCAL_MODULE_TAGS := optional
|
||||
|
||||
LOCAL_VENDOR_MODULE := true
|
||||
|
||||
LOCAL_SRC_FILES := power-feature.c
|
||||
|
||||
LOCAL_SHARED_LIBRARIES := libutils
|
||||
|
||||
LOCAL_HEADER_LIBRARIES := libhardware_headers qti_powerhal_headers
|
||||
|
||||
include $(BUILD_STATIC_LIBRARY)
|
@ -14,17 +14,12 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include <dirent.h>
|
||||
#include <hardware/power.h>
|
||||
#include <aidl/android/hardware/power/BnPower.h>
|
||||
#include <android-base/file.h>
|
||||
#include <android-base/logging.h>
|
||||
#include <linux/input.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
#include <utils.h>
|
||||
#include <utils/Log.h>
|
||||
|
||||
#define INPUT_EVENT_WAKUP_MODE_OFF 4
|
||||
#define INPUT_EVENT_WAKUP_MODE_ON 5
|
||||
|
||||
namespace {
|
||||
int open_ts_input() {
|
||||
int fd = -1;
|
||||
DIR* dir = opendir("/dev/input");
|
||||
@ -59,23 +54,53 @@ int open_ts_input() {
|
||||
|
||||
return fd;
|
||||
}
|
||||
} // anonymous namespace
|
||||
|
||||
void set_device_specific_feature(feature_t feature, int state) {
|
||||
switch (feature) {
|
||||
case POWER_FEATURE_DOUBLE_TAP_TO_WAKE: {
|
||||
namespace aidl {
|
||||
namespace android {
|
||||
namespace hardware {
|
||||
namespace power {
|
||||
namespace impl {
|
||||
|
||||
static constexpr int kInputEventWakeupModeOff = 4;
|
||||
static constexpr int kInputEventWakeupModeOn = 5;
|
||||
|
||||
using ::aidl::android::hardware::power::Mode;
|
||||
|
||||
bool isDeviceSpecificModeSupported(Mode type, bool* _aidl_return) {
|
||||
switch (type) {
|
||||
case Mode::DOUBLE_TAP_TO_WAKE:
|
||||
*_aidl_return = true;
|
||||
return true;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
bool setDeviceSpecificMode(Mode type, bool enabled) {
|
||||
switch (type) {
|
||||
case Mode::DOUBLE_TAP_TO_WAKE: {
|
||||
int fd = open_ts_input();
|
||||
if (fd == -1) {
|
||||
ALOGW("DT2W won't work because no supported touchscreen input devices were found");
|
||||
return;
|
||||
LOG(WARNING)
|
||||
<< "DT2W won't work because no supported touchscreen input devices were found";
|
||||
return false;
|
||||
}
|
||||
struct input_event ev;
|
||||
ev.type = EV_SYN;
|
||||
ev.code = SYN_CONFIG;
|
||||
ev.value = state ? INPUT_EVENT_WAKUP_MODE_ON : INPUT_EVENT_WAKUP_MODE_OFF;
|
||||
ev.value = enabled ? kInputEventWakeupModeOff : kInputEventWakeupModeOn;
|
||||
write(fd, &ev, sizeof(ev));
|
||||
close(fd);
|
||||
} break;
|
||||
}
|
||||
return true;
|
||||
default:
|
||||
break;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace impl
|
||||
} // namespace power
|
||||
} // namespace hardware
|
||||
} // namespace android
|
||||
} // namespace aidl
|
@ -694,7 +694,7 @@ service vendor.contexthub-hal-1-0 /vendor/bin/hw/android.hardware.contexthub@1.0
|
||||
group system
|
||||
disabled
|
||||
|
||||
service vendor.power-hal-1-2 /vendor/bin/hw/android.hardware.power@1.2-service-qti
|
||||
service vendor.power-hal /vendor/bin/hw/android.hardware.power-service-qti
|
||||
override
|
||||
class hal
|
||||
user system
|
||||
|
Loading…
Reference in New Issue
Block a user