Skip to content

Commit

Permalink
tomato: Use device-specific power feature lib
Browse files Browse the repository at this point in the history
* Fix double tap to wake toggle as tomato doesn't simply
  write 1 or 0 to the sysfs node

Change-Id: I7aa887dcdffd87a5041d947ac86591ad2c25585a
  • Loading branch information
mikeNG authored and Gerrit Code Review committed May 8, 2016
1 parent 4f8855c commit 0a8329e
Show file tree
Hide file tree
Showing 3 changed files with 91 additions and 1 deletion.
2 changes: 1 addition & 1 deletion BoardConfig.mk
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ USE_DEVICE_SPECIFIC_CAMERA := true

# CMHW
BOARD_HARDWARE_CLASS += $(DEVICE_PATH)/cmhw/src
TARGET_TAP_TO_WAKE_NODE := "/sys/devices/virtual/touchscreen/touchscreen_dev/gesture_ctrl"
TARGET_POWER_SET_FEATURE_LIB := libpower_set_feature_tomato

# CPU
TARGET_CPU_CORTEX_A53 := true
Expand Down
24 changes: 24 additions & 0 deletions power/Android.mk
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# Copyright (C) 2016 The CyanogenMod Project
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

LOCAL_PATH:= $(call my-dir)
include $(CLEAR_VARS)

LOCAL_SRC_FILES := power-feature.c
LOCAL_SHARED_LIBRARIES := liblog libcutils

LOCAL_MODULE := libpower_set_feature_tomato
LOCAL_MODULE_TAGS := optional

include $(BUILD_STATIC_LIBRARY)
66 changes: 66 additions & 0 deletions power/power-feature.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
/*
* Copyright (C) 2016 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

#include <errno.h>
#include <string.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <dlfcn.h>
#include <stdlib.h>
#include <unistd.h>

#include <hardware/power.h>

#define LOG_TAG "PowerHAL feature"
#include <utils/Log.h>

#define TAP_TO_WAKE_NODE "/sys/devices/virtual/touchscreen/touchscreen_dev/gesture_ctrl"

static int sysfs_write(char *path, char *s)
{
char buf[80];
int len;
int ret = 0;
int fd = open(path, O_WRONLY);

if (fd < 0) {
strerror_r(errno, buf, sizeof(buf));
ALOGE("Error opening %s: %s\n", path, buf);
return -1 ;
}

len = write(fd, s, strlen(s));
if (len < 0) {
strerror_r(errno, buf, sizeof(buf));
ALOGE("Error writing to %s: %s\n", path, buf);

ret = -1;
}

close(fd);

return ret;
}

void set_device_specific_feature(struct power_module *module __unused,
feature_t feature, int state)
{
if (feature == POWER_FEATURE_DOUBLE_TAP_TO_WAKE) {
sysfs_write(TAP_TO_WAKE_NODE,
state ? "double_click=true" : "double_click=false");
}
}

0 comments on commit 0a8329e

Please sign in to comment.