From: Michael Gernoth Date: Mon, 4 Jul 2011 19:42:06 +0000 (+0200) Subject: small update to adapt app to new module interface X-Git-Url: https://git.zerfleddert.de/cgi-bin/gitweb.cgi/ms2-fixes/commitdiff_plain/0b9d6422126cbd641917c648172f890e2ca72c6f?hp=1e0dcc40cee8b59f87f00f85081ed889609fd62e small update to adapt app to new module interface --- diff --git a/MS2Debounce/assets/debounce.ko b/MS2Debounce/assets/debounce.ko index c6ec28e..ebcac51 100644 Binary files a/MS2Debounce/assets/debounce.ko and b/MS2Debounce/assets/debounce.ko differ diff --git a/MS2Debounce/src/de/rmdir/ms2debounce/DebounceModuleHelper.java b/MS2Debounce/src/de/rmdir/ms2debounce/DebounceModuleHelper.java index 9c0a59e..5e2a476 100644 --- a/MS2Debounce/src/de/rmdir/ms2debounce/DebounceModuleHelper.java +++ b/MS2Debounce/src/de/rmdir/ms2debounce/DebounceModuleHelper.java @@ -4,7 +4,9 @@ import java.io.InputStream; 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; @@ -21,7 +23,8 @@ public class DebounceModuleHelper } public void loadModule() { - loadModule(getSavedDelay()); + _loadModule(); + setDelay(getSavedDelay()); } protected void runAsRoot(String command) throws java.io.IOException,java.lang.InterruptedException { @@ -35,7 +38,7 @@ public class DebounceModuleHelper rootcmd.waitFor(); } - public synchronized void loadModule(int delay) { + public synchronized void _loadModule() { File debounce_ko = new File(ctx.getFilesDir() + "/debounce.ko"); extractModule(); @@ -48,7 +51,7 @@ public class DebounceModuleHelper } try { - runAsRoot("/system/bin/insmod " + debounce_ko + " debounce_delay=" + delay); + runAsRoot("/system/bin/insmod " + debounce_ko); } catch (Exception e) { return; } @@ -99,34 +102,39 @@ public class DebounceModuleHelper 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) {