diff --git a/parts/AndroidManifest.xml b/parts/AndroidManifest.xml
index 29a6a39..f9ae3e8 100644
--- a/parts/AndroidManifest.xml
+++ b/parts/AndroidManifest.xml
@@ -73,6 +73,32 @@
android:permission="ThermalService">
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/parts/res/drawable/ic_htsr.xml b/parts/res/drawable/ic_htsr.xml
new file mode 100644
index 0000000..2891276
--- /dev/null
+++ b/parts/res/drawable/ic_htsr.xml
@@ -0,0 +1,11 @@
+
+
+
+
diff --git a/parts/res/values/strings.xml b/parts/res/values/strings.xml
index 8783e4c..6b6a22e 100644
--- a/parts/res/values/strings.xml
+++ b/parts/res/values/strings.xml
@@ -66,4 +66,10 @@
Reduces eye strain in low light conditions
DC Dimming is currently not supported by the kernel
+
+ Touch Responsiveness
+ Increase Touch Responsiveness
+ Increases touch polling rate to decrease latency
+ Increase Touch Responsiveness is currently not supported by the kernel
+
diff --git a/parts/res/xml/htsr_settings.xml b/parts/res/xml/htsr_settings.xml
new file mode 100644
index 0000000..3470c27
--- /dev/null
+++ b/parts/res/xml/htsr_settings.xml
@@ -0,0 +1,24 @@
+
+
+
+
+
+
diff --git a/parts/src/org/lineageos/settings/BootCompletedReceiver.java b/parts/src/org/lineageos/settings/BootCompletedReceiver.java
index 0a27487..be71ce4 100644
--- a/parts/src/org/lineageos/settings/BootCompletedReceiver.java
+++ b/parts/src/org/lineageos/settings/BootCompletedReceiver.java
@@ -35,6 +35,8 @@ public class BootCompletedReceiver extends BroadcastReceiver {
private static final String TAG = "XiaomiParts";
private static final String DC_DIMMING_ENABLE_KEY = "dc_dimming_enable";
private static final String DC_DIMMING_NODE = "/sys/devices/platform/soc/soc:qcom,dsi-display-primary/dimlayer_exposure";
+ private static final String HTSR_ENABLE_KEY = "htsr_enable";
+ private static final String HTSR_FILE = "/sys/devices/virtual/touch/touch_dev/bump_sample_rate";
@Override
public void onReceive(final Context context, Intent intent) {
@@ -45,6 +47,10 @@ public class BootCompletedReceiver extends BroadcastReceiver {
ThermalUtils.startService(context);
RefreshUtils.startService(context);
+ // Touch Sampling
+ boolean HTSREnabled = sharedPrefs.getBoolean(HTSR_ENABLE_KEY, false);
+ FileUtils.writeLine(HTSR_FILE, HTSREnabled ? "1" : "0");
+
// DC Dimming
FileUtils.enableService(context);
boolean dcDimmingEnabled = sharedPrefs.getBoolean(DC_DIMMING_ENABLE_KEY, false);
diff --git a/parts/src/org/lineageos/settings/touchsampling/TouchSamplingSettingsActivity.java b/parts/src/org/lineageos/settings/touchsampling/TouchSamplingSettingsActivity.java
new file mode 100644
index 0000000..f322fe4
--- /dev/null
+++ b/parts/src/org/lineageos/settings/touchsampling/TouchSamplingSettingsActivity.java
@@ -0,0 +1,34 @@
+/*
+ * Copyright (C) 2015-2016 The CyanogenMod Project
+ * 2017,2021-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.
+ */
+
+package org.lineageos.settings.touchsampling;
+
+import android.os.Bundle;
+
+import com.android.settingslib.collapsingtoolbar.CollapsingToolbarBaseActivity;
+
+public class TouchSamplingSettingsActivity extends CollapsingToolbarBaseActivity {
+
+ private static final String TAG_HTSR = "touchsampling";
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ getFragmentManager().beginTransaction().replace(com.android.settingslib.collapsingtoolbar.R.id.content_frame,
+ new TouchSamplingSettingsFragment(), TAG_HTSR).commit();
+ }
+}
diff --git a/parts/src/org/lineageos/settings/touchsampling/TouchSamplingSettingsFragment.java b/parts/src/org/lineageos/settings/touchsampling/TouchSamplingSettingsFragment.java
new file mode 100644
index 0000000..8a6c821
--- /dev/null
+++ b/parts/src/org/lineageos/settings/touchsampling/TouchSamplingSettingsFragment.java
@@ -0,0 +1,56 @@
+/*
+ * Copyright (C) 2018 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.
+ */
+
+package org.lineageos.settings.touchsampling;
+
+import android.content.Context;
+import android.os.Bundle;
+import androidx.preference.Preference;
+import androidx.preference.Preference.OnPreferenceChangeListener;
+import androidx.preference.PreferenceFragment;
+import androidx.preference.SwitchPreferenceCompat;
+
+import org.lineageos.settings.R;
+import org.lineageos.settings.utils.FileUtils;
+
+public class TouchSamplingSettingsFragment extends PreferenceFragment implements
+ OnPreferenceChangeListener {
+
+ private SwitchPreferenceCompat mTouchSamplingPreference;
+ private static final String HTSR_ENABLE_KEY = "htsr_enable";
+ private static final String HTSR_FILE = "/sys/devices/virtual/touch/touch_dev/bump_sample_rate";
+
+ @Override
+ public void onCreatePreferences(Bundle savedInstanceState, String rootKey) {
+ addPreferencesFromResource(R.xml.htsr_settings);
+ mTouchSamplingPreference = (SwitchPreferenceCompat) findPreference(HTSR_ENABLE_KEY);
+ if (FileUtils.fileExists(HTSR_FILE)) {
+ mTouchSamplingPreference.setEnabled(true);
+ mTouchSamplingPreference.setOnPreferenceChangeListener(this);
+ } else {
+ mTouchSamplingPreference.setSummary(R.string.htsr_enable_summary_not_supported);
+ mTouchSamplingPreference.setEnabled(false);
+ }
+ }
+
+ @Override
+ public boolean onPreferenceChange(Preference preference, Object newValue) {
+ if (HTSR_ENABLE_KEY.equals(preference.getKey())) {
+ FileUtils.writeLine(HTSR_FILE, (Boolean) newValue ? "1" : "0");
+ }
+ return true;
+ }
+}
diff --git a/parts/src/org/lineageos/settings/touchsampling/TouchSamplingTileService.java b/parts/src/org/lineageos/settings/touchsampling/TouchSamplingTileService.java
new file mode 100644
index 0000000..53cd86e
--- /dev/null
+++ b/parts/src/org/lineageos/settings/touchsampling/TouchSamplingTileService.java
@@ -0,0 +1,62 @@
+/*
+ * Copyright (C) 2024 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.
+ */
+
+package org.lineageos.settings.touchsampling;
+
+import android.content.SharedPreferences;
+import android.service.quicksettings.Tile;
+import android.service.quicksettings.TileService;
+import androidx.preference.PreferenceManager;
+
+import org.lineageos.settings.utils.FileUtils;
+
+public class TouchSamplingTileService extends TileService {
+
+ private static final String HTSR_ENABLE_KEY = "htsr_enable";
+ private static final String HTSR_FILE = "/sys/devices/virtual/touch/touch_dev/bump_sample_rate";
+
+ private void updateUI(boolean enabled) {
+ final Tile tile = getQsTile();
+ if (FileUtils.fileExists(HTSR_FILE)) {
+ tile.setState(enabled ? Tile.STATE_ACTIVE : Tile.STATE_INACTIVE);
+ } else {
+ tile.setState(Tile.STATE_UNAVAILABLE);
+ }
+ tile.updateTile();
+ }
+
+ @Override
+ public void onStartListening() {
+ super.onStartListening();
+ SharedPreferences sharedPrefs = PreferenceManager.getDefaultSharedPreferences(this);
+ updateUI(sharedPrefs.getBoolean(HTSR_ENABLE_KEY, false));
+ }
+
+ @Override
+ public void onStopListening() {
+ super.onStopListening();
+ }
+
+ @Override
+ public void onClick() {
+ super.onClick();
+ SharedPreferences sharedPrefs = PreferenceManager.getDefaultSharedPreferences(this);
+ final boolean enabled = !(sharedPrefs.getBoolean(HTSR_ENABLE_KEY, false));
+ FileUtils.writeLine(HTSR_FILE, enabled ? "1" : "0");
+ sharedPrefs.edit().putBoolean(HTSR_ENABLE_KEY, enabled).commit();
+ updateUI(enabled);
+ }
+}
diff --git a/rootdir/etc/init.qcom.rc b/rootdir/etc/init.qcom.rc
index 1110caa..c2bea6b 100644
--- a/rootdir/etc/init.qcom.rc
+++ b/rootdir/etc/init.qcom.rc
@@ -228,6 +228,10 @@ on post-fs-data
chown system system /sys/devices/platform/soc/soc:qcom,dsi-display-primary/hbm_enabled
chmod 0660 /sys/devices/platform/soc/soc:qcom,dsi-display-primary/hbm_enabled
+ # Allow systemto modify High Touch Sampling Rate
+ chown system system /sys/devices/virtual/touch/touch_dev/bump_sample_rate
+ chmod 0660 /sys/devices/virtual/touch/touch_dev/bump_sample_rate
+
on property:sys.boot_completed=1
# Enable UFS clock scaling back
write /sys/bus/platform/devices/1d84000.ufshc/clkscale_enable 1
diff --git a/sepolicy/vendor/file.te b/sepolicy/vendor/file.te
new file mode 100644
index 0000000..ab055ee
--- /dev/null
+++ b/sepolicy/vendor/file.te
@@ -0,0 +1 @@
+type sysfs_htsr, sysfs_type, fs_type;
diff --git a/sepolicy/vendor/file_contexts b/sepolicy/vendor/file_contexts
index 8132d31..fd2f8d1 100644
--- a/sepolicy/vendor/file_contexts
+++ b/sepolicy/vendor/file_contexts
@@ -34,6 +34,9 @@
/sys/devices/virtual/touch/tp_dev/fod_status u:object_r:vendor_sysfs_udfps:s0
/vendor/bin/hw/android\.hardware\.biometrics\.fingerprint-service\.xiaomi u:object_r:hal_fingerprint_default_exec:s0
+# HTSR
+/sys/devices/virtual/touch/touch_dev/bump_sample_rate u:object_r:sysfs_htsr:s0
+
# IR
/dev/lirc[0-9]+ u:object_r:lirc_device:s0
/vendor/bin/hw/android\.hardware\.ir-service\.xiaomi u:object_r:hal_ir_default_exec:s0
diff --git a/sepolicy/vendor/system_app.te b/sepolicy/vendor/system_app.te
index 02c39a7..aa934c4 100644
--- a/sepolicy/vendor/system_app.te
+++ b/sepolicy/vendor/system_app.te
@@ -4,3 +4,7 @@ allow system_app sysfs_thermal:file rw_file_perms;
# DC Dimming and HBM
allow system_app vendor_sysfs_graphics:dir search;
allow system_app vendor_sysfs_graphics:file { getattr open write };
+
+# HTSR
+allow system_app sysfs_htsr:file { read write open setattr getattr };
+allow system_app sysfs_htsr:dir { search open read };