Skip to content

Commit

Permalink
phoenix: Add dt2w support
Browse files Browse the repository at this point in the history
Signed-off-by: Akhil Narang <me@akhilnarang.dev>
  • Loading branch information
TheScarastic authored and akhilnarang committed Apr 2, 2020
1 parent 6553179 commit fff1548
Show file tree
Hide file tree
Showing 7 changed files with 36 additions and 4 deletions.
3 changes: 3 additions & 0 deletions BoardConfig.mk
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,9 @@ TARGET_RELEASETOOLS_EXTENSIONS := $(DEVICE_PATH)
# Telephony
TARGET_PROVIDES_QTI_TELEPHONY_JAR := true

# Power
TARGET_TAP_TO_WAKE_NODE := "/dev/input/event3"

# Treble
BOARD_VNDK_VERSION := current

Expand Down
4 changes: 3 additions & 1 deletion overlay/frameworks/base/core/res/res/values/config.xml
Original file line number Diff line number Diff line change
Expand Up @@ -646,4 +646,6 @@
<item>13</item>
</integer-array>

</resources>
<!-- Whether device supports double tap to wake -->
<bool name="config_supportDoubleTapWake">true</bool>
</resources>
6 changes: 4 additions & 2 deletions power/Android.mk
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,13 @@ LOCAL_SRC_FILES := power-common.c metadata-parser.c utils.c list.c hint-data.c p
LOCAL_C_INCLUDES := external/libxml2/include \
external/icu/icu4c/source/common

# Include target-specific files.
ifneq ($(TARGET_TAP_TO_WAKE_NODE),)
LOCAL_CFLAGS += -DTAP_TO_WAKE_NODE=\"$(TARGET_TAP_TO_WAKE_NODE)\"
endif

ifeq ($(TARGET_USES_INTERACTION_BOOST),true)
LOCAL_CFLAGS += -DINTERACTION_BOOST
endif

include $(BUILD_EXECUTABLE)

include $(CLEAR_VARS)
Expand Down
20 changes: 20 additions & 0 deletions power/Power.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
#define LOG_TAG "QTI PowerHAL"

#include <android/log.h>
#include <linux/input.h>
#include <utils/Log.h>
#include "Power.h"
#include "power-common.h"
Expand Down Expand Up @@ -64,7 +65,26 @@ Return<void> Power::powerHint(PowerHint_1_0 hint, int32_t data) {
return Void();
}

void set_feature(feature_t feature, int state) {
switch (feature) {
#ifdef TAP_TO_WAKE_NODE
case POWER_FEATURE_DOUBLE_TAP_TO_WAKE: {
int fd = open(TAP_TO_WAKE_NODE, O_RDWR);
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;
write(fd, &ev, sizeof(ev));
close(fd);
} break;
#endif
default:
break;
}
}

Return<void> Power::setFeature(Feature feature, bool activate) {
set_feature(static_cast<feature_t>(feature), activate ? 1 : 0);
return Void();
}

Expand Down
2 changes: 1 addition & 1 deletion power/android.hardware.power@1.2-service.rc
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
service vendor.power-hal-1-2 /vendor/bin/hw/android.hardware.power@1.2-service
class hal
user system
group system
group system input
3 changes: 3 additions & 0 deletions power/power-common.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,9 @@ extern "C" {
#define MSMDCVS_GOVERNOR "msm-dcvs"
#define SCHEDUTIL_GOVERNOR "schedutil"

#define INPUT_EVENT_WAKUP_MODE_OFF 4
#define INPUT_EVENT_WAKUP_MODE_ON 5

#define HINT_HANDLED (0)
#define HINT_NONE (-1)

Expand Down
2 changes: 2 additions & 0 deletions sepolicy/private/hal_power.te
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
allow hal_power input_device:dir search;
allow hal_power input_device:chr_file rw_file_perms;

0 comments on commit fff1548

Please sign in to comment.