-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
tomato: Use device-specific power feature lib
* 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
Showing
3 changed files
with
91 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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"); | ||
} | ||
} |