diff --git a/BoardConfig.mk b/BoardConfig.mk index c12edfe..3ef98bd 100644 --- a/BoardConfig.mk +++ b/BoardConfig.mk @@ -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 diff --git a/power/Android.mk b/power/Android.mk deleted file mode 100644 index 3901072..0000000 --- a/power/Android.mk +++ /dev/null @@ -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) diff --git a/power/power-feature.h b/power/power-feature.h deleted file mode 100644 index b4c3ef6..0000000 --- a/power/power-feature.h +++ /dev/null @@ -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 diff --git a/power/power-feature.c b/power/power-mode.cpp similarity index 58% rename from power/power-feature.c rename to power/power-mode.cpp index 5bf2455..9079924 100644 --- a/power/power-feature.c +++ b/power/power-mode.cpp @@ -14,17 +14,12 @@ * limitations under the License. */ -#include -#include -#include -#include - -#include "power-feature.h" - -#include +#include +#include +#include #include -#include +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