2 Commits
vic ... bka

Author SHA1 Message Date
Soo-Hwan Na
9f18b188f3 Flashlight: Handle case for unknown brightness value in getCurrentBrightness 2025-12-23 16:10:15 +09:00
Soo-Hwan Na
b7182582a8 Update for Android 16 2025-12-06 22:01:50 +09:00
9 changed files with 2 additions and 301 deletions

View File

@@ -36,6 +36,7 @@ ndk::ScopedAStatus Flashlight::getCurrentBrightness(int32_t* _aidl_return) {
case 0:
*_aidl_return = 0;
break;
case -1:
case 1:
*_aidl_return = GetIntProperty(FLASH_BRIGHTNESS_PROP, level_saved, 0, 5);
break;
@@ -60,7 +61,7 @@ ndk::ScopedAStatus Flashlight::getCurrentBrightness(int32_t* _aidl_return) {
char debugBuffer[50] = {};
snprintf(debugBuffer, sizeof(debugBuffer) - 1, "Unknown flash node value: %d", intvalue);
return ndk::ScopedAStatus::fromExceptionCodeWithMessage(EX_ILLEGAL_STATE, debugBuffer);
}
}
}
return ndk::ScopedAStatus::ok();
}

View File

@@ -25,7 +25,6 @@ cc_binary {
cflags: ["-Wno-missing-field-initializers"],
whole_static_libs: [
"libbase",
"libc++fs",
],
shared_libs: [
"liblog",

View File

@@ -1,37 +0,0 @@
// Copyright (C) 2019 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.
cc_binary {
name: "vendor.lineage.touch@1.0-service.ss",
stem: "vendor.lineage.touch@1.0-service.singletap",
init_rc: ["vendor.lineage.touch@1.0-service.singletap.rc"],
vintf_fragments: ["vendor.lineage.touch@1.0-service.singletap.xml"],
defaults: ["hidl_defaults"],
relative_install_path: "hw",
// FIXME: this should be 'vendor: true' for modules that will eventually be
// on AOSP.
proprietary: true,
local_include_dirs: ["include"],
srcs: [
"TouchscreenGesture.cpp",
"service.cpp"
],
shared_libs: [
"libbase",
"libbinder",
"libhidlbase",
"libutils",
"vendor.lineage.touch@1.0",
],
}

View File

@@ -1,86 +0,0 @@
/*
* Copyright (C) 2019 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.
*/
#include <fstream>
#include <mutex>
#include <android-base/file.h>
#include "TouchscreenGesture.h"
namespace vendor {
namespace lineage {
namespace touch {
namespace V1_0 {
namespace samsung {
static constexpr const char* kTspPath = TSP_CMD_NODE;
const std::map<int32_t, TouchscreenGesture::GestureInfo> TouchscreenGesture::kGestureInfoMap = {
// clang-format off
{0, {0x1c7, "Single Tap"}},
// clang-format on
};
bool TouchscreenGesture::isSupported() {
static bool kSupported = false;
static std::once_flag once;
std::call_once(once, [] {
std::string cmds;
android::base::ReadFileToString(TSP_CMD_LIST_NODE, &cmds);
kSupported = cmds.find("singletap_enable") != std::string::npos;
});
return kSupported;
}
// Methods from ::vendor::lineage::touch::V1_0::ITouchscreenGesture follow.
Return<void> TouchscreenGesture::getSupportedGestures(getSupportedGestures_cb resultCb) {
std::vector<Gesture> gestures;
if (isSupported()) {
for (const auto& entry : kGestureInfoMap) {
gestures.push_back({entry.first, entry.second.name, entry.second.keycode});
}
} else {
LOG(ERROR) << __func__ << ": Unsupported";
}
resultCb(gestures);
return Void();
}
Return<bool> TouchscreenGesture::setGestureEnabled(
const ::vendor::lineage::touch::V1_0::Gesture&, bool enabled) {
if (isSupported()) {
std::ofstream file(kTspPath);
if (file.is_open()) {
file << "singletap_enable," << enabled;
return true;
}
} else {
LOG(ERROR) << __func__ << ": Unsupported";
}
return false;
}
// Methods from ::android::hidl::base::V1_0::IBase follow.
} // namespace samsung
} // namespace V1_0
} // namespace touch
} // namespace lineage
} // namespace vendor

View File

@@ -1,65 +0,0 @@
/*
* Copyright (C) 2019-2022 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.
*/
#pragma once
#define LOG_TAG "vendor.lineage.touch@1.0-service.singletap"
#include <android-base/logging.h>
#include <hidl/MQDescriptor.h>
#include <hidl/Status.h>
#include <vendor/lineage/touch/1.0/ITouchscreenGesture.h>
#include "samsung_touch.h"
namespace vendor {
namespace lineage {
namespace touch {
namespace V1_0 {
namespace samsung {
using ::android::hardware::hidl_array;
using ::android::hardware::hidl_memory;
using ::android::hardware::hidl_string;
using ::android::hardware::hidl_vec;
using ::android::hardware::Return;
using ::android::hardware::Void;
using ::android::sp;
class TouchscreenGesture : public ITouchscreenGesture {
public:
bool isSupported();
// Methods from ::vendor::lineage::touch::V1_0::ITouchscreenGesture follow.
Return<void> getSupportedGestures(getSupportedGestures_cb resultCb) override;
Return<bool> setGestureEnabled(const ::vendor::lineage::touch::V1_0::Gesture& gesture,
bool enabled) override;
private:
typedef struct {
int32_t keycode;
const char* name;
} GestureInfo;
static const std::map<int32_t, GestureInfo> kGestureInfoMap; // id -> info
};
// FIXME: most likely delete, this is only for passthrough implementations
// extern "C" ITouchscreenGesture* HIDL_FETCH_ITouchscreenGesture(const char* name);
} // namespace samsung
} // namespace V1_0
} // namespace touch
} // namespace lineage
} // namespace vendor

View File

@@ -1,33 +0,0 @@
/*
* Copyright (C) 2021 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.
*/
#ifndef SAMSUNG_TOUCH_H
#define SAMSUNG_TOUCH_H
/*
* Board specific nodes
*
* If your kernel exposes these controls in another place, you can either
* symlink to the locations given here, or override this header in your
* device tree.
*/
// For GloveMode
#define TSP_CMD_LIST_NODE "/sys/class/sec/tsp/cmd_list"
#define TSP_CMD_RESULT_NODE "/sys/class/sec/tsp/cmd_result"
#define TSP_CMD_NODE "/sys/class/sec/tsp/cmd"
#endif // SAMSUNG_TOUCH_H

View File

@@ -1,63 +0,0 @@
/*
* Copyright (C) 2019 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.
*/
// Here to avoid -Wmacro-redefined
#include "TouchscreenGesture.h"
#include <binder/ProcessState.h>
#include <hidl/HidlTransportSupport.h>
using android::hardware::configureRpcThreadpool;
using android::hardware::joinRpcThreadpool;
using android::sp;
using android::status_t;
using android::OK;
using ::vendor::lineage::touch::V1_0::samsung::TouchscreenGesture;
int main() {
sp<TouchscreenGesture> touchscreenGesture;
status_t status;
LOG(INFO) << "Touch HAL service is starting.";
touchscreenGesture = new TouchscreenGesture();
if (touchscreenGesture == nullptr) {
LOG(ERROR) << "Can not create an instance of Touch HAL TouchscreenGesture Iface, exiting.";
goto shutdown;
}
configureRpcThreadpool(1, true /*callerWillJoin*/);
if (!touchscreenGesture->isSupported())
LOG(WARNING) << "isSupported() returns false, registering stub implementation!";
status = touchscreenGesture->registerAsService();
if (status != OK) {
LOG(ERROR) << "Could not register service for Touch HAL TouchscreenGesture Iface ("
<< status << ")";
goto shutdown;
}
LOG(INFO) << "Touch HAL service is ready.";
joinRpcThreadpool();
// Should not pass this line
shutdown:
// In normal operation, we don't expect the thread pool to shutdown
LOG(ERROR) << "Touch HAL service is shutting down.";
return 1;
}

View File

@@ -1,8 +0,0 @@
on early-init
# root uid because of powerhal, which runs as root
chown root system /sys/class/sec/tsp/cmd
service vendor.touch-hal-1-0-singletap /vendor/bin/hw/vendor.lineage.touch@1.0-service.singletap
class hal
user system
group system

View File

@@ -1,7 +0,0 @@
<manifest version="1.0" type="device">
<hal format="hidl">
<name>vendor.lineage.touch</name>
<transport>hwbinder</transport>
<fqname>@1.0::ITouchscreenGesture/default</fqname>
</hal>
</manifest>