-
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.
porsche: Bring back screen-off touch gestures
Introduce custom power HAL extension, inspired by LineageOS/android_hardware_oplus@ce722bd Change-Id: Ied1f685f398a7fa739738d5e99cb9626fadd50cf
- Loading branch information
1 parent
ba7797f
commit 1b96679
Showing
3 changed files
with
84 additions
and
0 deletions.
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,15 @@ | ||
// | ||
// Copyright (C) 2023 Paranoid Android | ||
// | ||
// SPDX-License-Identifier: Apache-2.0 | ||
// | ||
|
||
cc_library_static { | ||
name: "libpowerfeature_ext_porsche", | ||
srcs: ["power-feature.cpp"], | ||
shared_libs: [ | ||
"libbase", | ||
"vendor.aospa.power-V1-ndk", | ||
], | ||
vendor: true, | ||
} |
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) 2023 Paranoid Android | ||
* | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
#include <aidl/vendor/aospa/power/BnPowerFeature.h> | ||
#include <android-base/file.h> | ||
#include <android-base/strings.h> | ||
#include <unordered_map> | ||
|
||
#define GESTURE_ENABLE_PATH "/proc/touchpanel/double_tap_enable_indep" | ||
|
||
using ::android::base::ReadFileToString; | ||
using ::android::base::Trim; | ||
using ::android::base::WriteStringToFile; | ||
|
||
namespace aidl { | ||
namespace vendor { | ||
namespace aospa { | ||
namespace power { | ||
|
||
// based on values in touchpanel_common.h | ||
static const std::unordered_map<Feature, int> GESTURE_MAP = { | ||
{Feature::DOUBLE_TAP, 1}, | ||
{Feature::DRAW_V, 2}, | ||
{Feature::DRAW_INVERSE_V, 3}, | ||
{Feature::DRAW_O, 6}, | ||
{Feature::DRAW_M, 12}, | ||
{Feature::DRAW_W, 13}, | ||
{Feature::DRAW_ARROW_LEFT, 5}, | ||
{Feature::DRAW_ARROW_RIGHT, 4}, | ||
{Feature::ONE_FINGER_SWIPE_UP, 11}, | ||
{Feature::ONE_FINGER_SWIPE_RIGHT, 8}, | ||
{Feature::ONE_FINGER_SWIPE_DOWN, 10}, | ||
{Feature::ONE_FINGER_SWIPE_LEFT, 9}, | ||
{Feature::TWO_FINGER_SWIPE, 7}, | ||
{Feature::DRAW_S, 18}, | ||
}; | ||
|
||
bool setDeviceSpecificFeature(Feature feature, bool enabled) { | ||
int contents = 0; | ||
auto gesture = GESTURE_MAP.find(feature); | ||
|
||
if (gesture == GESTURE_MAP.end()) { | ||
// Unsupported gesture | ||
return false; | ||
} | ||
|
||
if (std::string tmp; ReadFileToString(GESTURE_ENABLE_PATH, &tmp)) { | ||
contents = std::stoi(Trim(tmp), nullptr, 16); | ||
} | ||
|
||
if (enabled) { | ||
contents |= (1 << gesture->second); | ||
} else { | ||
contents &= ~(1 << gesture->second); | ||
} | ||
|
||
return WriteStringToFile(std::to_string(contents), GESTURE_ENABLE_PATH, true); | ||
} | ||
|
||
} // namespace power | ||
} // namespace aospa | ||
} // namespace vendor | ||
} // namespace aidl |