davinci: power: Adapt extension to new aidl power HAL

Change-Id: I58ac49957d8d28ad904912986d89ac8db4820ff9
This commit is contained in:
Bruno Martins 2020-10-09 12:19:37 +01:00 committed by Arian
parent d52b6c8e3a
commit 6410f01039
No known key found for this signature in database
GPG Key ID: 48029380598CE3B9
4 changed files with 43 additions and 67 deletions

View File

@ -153,7 +153,7 @@ TARGET_COPY_OUT_VENDOR := vendor
TARGET_BOARD_PLATFORM := sm6150
# Power
TARGET_POWER_SET_FEATURE_LIB := libpower_feature.davinci
TARGET_POWERHAL_MODE_EXT := $(DEVICE_PATH)/power/power-mode.cpp
# Properties
TARGET_ODM_PROP += $(DEVICE_PATH)/odm.prop

View File

@ -1,31 +0,0 @@
#
# Copyright (C) 2020 The LineageOS 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_HEADER_LIBRARIES := \
generated_kernel_headers \
libhardware_headers
LOCAL_MODULE := libpower_feature.davinci
LOCAL_MODULE_TAGS := optional
LOCAL_VENDOR_MODULE := true
include $(BUILD_STATIC_LIBRARY)

View File

@ -1,20 +0,0 @@
/*
* Copyright (C) 2020 The LineageOS 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.
*/
#define LOG_TAG "libpower_feature.davinci"
#define INPUT_EVENT_WAKUP_MODE_OFF 4
#define INPUT_EVENT_WAKUP_MODE_ON 5

View File

@ -14,17 +14,12 @@
* limitations under the License.
*/
#include <dirent.h>
#include <fcntl.h>
#include <string.h>
#include <unistd.h>
#include "power-feature.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 <log/log.h>
namespace {
int open_ts_input() {
int fd = -1;
DIR *dir = opendir("/dev/input");
@ -56,21 +51,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 ? kInputEventWakeupModeOn : kInputEventWakeupModeOff;
write(fd, &ev, sizeof(ev));
close(fd);
return true;
}
default:
return false;
}
}
} // namespace impl
} // namespace power
} // namespace hardware
} // namespace android
} // namespace aidl