sm8250-common: tri-state-key: Add hall sensor calibration support
Change-Id: I8449041eec5c8ab4153bd2942ebc7fda9ceb743e
This commit is contained in:
parent
2412a59d46
commit
19525f89df
5 changed files with 22 additions and 0 deletions
1
sepolicy/vendor/file.te
vendored
1
sepolicy/vendor/file.te
vendored
|
@ -20,4 +20,5 @@ type sysfs_fuse, fs_type, sysfs_type;
|
|||
type sysfs_memplus, fs_type, sysfs_type;
|
||||
type sysfs_project_info, fs_type, sysfs_type;
|
||||
type sysfs_tpd, fs_type, sysfs_type;
|
||||
type sysfs_tri_state_key, sysfs_type, fs_type;
|
||||
type vendor_sysfs_video_call_on, fs_type, sysfs_type;
|
||||
|
|
1
sepolicy/vendor/file_contexts
vendored
1
sepolicy/vendor/file_contexts
vendored
|
@ -89,6 +89,7 @@
|
|||
# Sys files (wakeup)
|
||||
/sys/devices/platform/soc/c440000\.qcom,spmi/spmi-0/spmi0-00/c440000\.qcom,spmi:qcom,pm8150@0:qcom,pm8150_rtc/rtc/rtc0/wakeup[0-9]+(/.*)? u:object_r:sysfs_wakeup:s0
|
||||
/sys/devices/platform/soc/soc:oneplus_wlchg/power_supply/wireless/wakeup[0-9]+(/.*)? u:object_r:sysfs_wakeup:s0
|
||||
/sys/devices/platform/soc/soc:tri_state_key/hall_data_calib u:object_r:sysfs_tri_state_key:s0
|
||||
/sys/devices/virtual/diag/diag/wakeup[0-9]+(/.*)? u:object_r:sysfs_wakeup:s0
|
||||
/sys/devices/virtual/misc/msm_aac/wakeup[0-9]+(/.*)? u:object_r:sysfs_wakeup:s0
|
||||
/sys/devices/virtual/misc/msm_alac/wakeup[0-9]+(/.*)? u:object_r:sysfs_wakeup:s0
|
||||
|
|
6
sepolicy/vendor/tri-state-key_daemon.te
vendored
6
sepolicy/vendor/tri-state-key_daemon.te
vendored
|
@ -5,3 +5,9 @@ init_daemon_domain(tri-state-key_daemon)
|
|||
|
||||
allow tri-state-key_daemon uhid_device:chr_file rw_file_perms;
|
||||
allow tri-state-key_daemon self:netlink_kobject_uevent_socket create_socket_perms_no_ioctl;
|
||||
|
||||
allow tri-state-key_daemon sysfs_tri_state_key:file w_file_perms;
|
||||
|
||||
allow tri-state-key_daemon mnt_vendor_file:dir search;
|
||||
|
||||
r_dir_file(tri-state-key_daemon, oem_file)
|
||||
|
|
|
@ -16,6 +16,7 @@
|
|||
|
||||
#define LOG_TAG "tri-state-key_daemon"
|
||||
|
||||
#include <android-base/file.h>
|
||||
#include <android-base/logging.h>
|
||||
#include <fcntl.h>
|
||||
#include <linux/input.h>
|
||||
|
@ -24,10 +25,15 @@
|
|||
|
||||
#include "uevent_listener.h"
|
||||
|
||||
#define HALL_CALIBRATION_DATA "/sys/devices/platform/soc/soc:tri_state_key/hall_data_calib"
|
||||
#define HALL_PERSIST_CALIBRATION_DATA "/mnt/vendor/persist/engineermode/tri_state_hall_data"
|
||||
|
||||
#define KEY_MODE_NORMAL 601
|
||||
#define KEY_MODE_VIBRATION 602
|
||||
#define KEY_MODE_SILENCE 603
|
||||
|
||||
using android::base::ReadFileToString;
|
||||
using android::base::WriteStringToFile;
|
||||
using android::Uevent;
|
||||
using android::UeventListener;
|
||||
|
||||
|
@ -39,6 +45,11 @@ int main() {
|
|||
|
||||
LOG(INFO) << "Started";
|
||||
|
||||
if (std::string hallData; ReadFileToString(HALL_PERSIST_CALIBRATION_DATA, &hallData)) {
|
||||
std::replace(hallData.begin(), hallData.end(), ';', ',');
|
||||
WriteStringToFile(hallData, HALL_CALIBRATION_DATA);
|
||||
}
|
||||
|
||||
uinputFd = open("/dev/uinput", O_WRONLY | O_NONBLOCK);
|
||||
if (uinputFd < 0) {
|
||||
LOG(ERROR) << "Unable to open uinput node";
|
||||
|
|
|
@ -1,4 +1,7 @@
|
|||
on fs
|
||||
chown system system /sys/devices/platform/soc/soc:tri_state_key/hall_data_calib
|
||||
chown system system /mnt/vendor/persist/engineermode/tri_state_hall_data
|
||||
|
||||
start tri-state-key_daemon
|
||||
|
||||
service tri-state-key_daemon /vendor/bin/tri-state-key_daemon
|
||||
|
|
Loading…
Reference in a new issue