import java.io.OutputStream;
import java.io.File;
import java.io.FileReader;
+import java.io.FileWriter;
import java.io.BufferedReader;
+import java.io.BufferedWriter;
import java.io.DataOutputStream;
import android.content.Context;
}
public void loadModule() {
- loadModule(getSavedDelay());
+ _loadModule();
+ setDelay(getSavedDelay());
}
protected void runAsRoot(String command) throws java.io.IOException,java.lang.InterruptedException {
rootcmd.waitFor();
}
- public synchronized void loadModule(int delay) {
+ public synchronized void _loadModule() {
File debounce_ko = new File(ctx.getFilesDir() + "/debounce.ko");
extractModule();
}
try {
- runAsRoot("/system/bin/insmod " + debounce_ko + " debounce_delay=" + delay);
+ runAsRoot("/system/bin/insmod " + debounce_ko);
} catch (Exception e) {
return;
}
try {
String read;
- FileReader delay = new FileReader("/sys/module/debounce/parameters/debounce_delay");
+ FileReader delay = new FileReader("/sys/devices/debounce/debounce_delay");
BufferedReader delay_buf = new BufferedReader(delay);
read = delay_buf.readLine();
if (read != null) {
debounce_delay = Integer.parseInt(read.trim());
}
+
+ delay_buf.close();
} catch (Exception e) {}
return debounce_delay;
}
- public synchronized void setDelay(int delay) {
- if (isLoaded()) {
- if (getDelay() == delay) {
- return;
- }
-
- unloadModule();
+ public synchronized void setDelay(int debounce_delay) {
+ if (!isLoaded()) {
+ return;
}
- loadModule(delay);
+ try {
+ FileWriter delay = new FileWriter("/sys/devices/debounce/debounce_delay");
+ BufferedWriter delay_buf = new BufferedWriter(delay);
+
+ delay_buf.write((new Integer(debounce_delay)).toString());
+
+ delay_buf.close();
+ } catch (Exception e) {}
}
public synchronized int getSavedDelay() {
SharedPreferences settings = ctx.getSharedPreferences(PREFS_NAME, Context.MODE_PRIVATE);
- return settings.getInt("debounce_delay", 15);
+ return settings.getInt("debounce_delay", 8);
}
public synchronized void setSavedDelay(int delay) {