]> git.zerfleddert.de Git - ms2-fixes/commitdiff
implement isLoaded and getDelay in moduleHelper
authorMichael Gernoth <michael@gernoth.net>
Fri, 20 May 2011 22:19:37 +0000 (00:19 +0200)
committerMichael Gernoth <michael@gernoth.net>
Fri, 20 May 2011 22:19:37 +0000 (00:19 +0200)
MS2Debounce/src/de/rmdir/ms2debounce/DebounceModuleHelper.java

index e4ad296e2e47c5b2cad17967de860a2906061073..229f00ae72a568a3e5be878b44a4e27d84f45ce6 100644 (file)
@@ -3,6 +3,8 @@ package de.rmdir.ms2debounce;
 import java.io.InputStream;
 import java.io.OutputStream;
 import java.io.File;
+import java.io.FileReader;
+import java.io.BufferedReader;
 
 import android.content.Context;
 
@@ -39,11 +41,42 @@ public class DebounceModuleHelper
        }
 
        public boolean isLoaded() {
-               return false;
+               boolean loaded = false;
+               try {
+                       String read;
+
+                       FileReader modules = new FileReader("/proc/modules");
+                       BufferedReader modules_buf = new BufferedReader(modules);
+
+                       while((read = modules_buf.readLine()) != null) {
+                               if (read.regionMatches(0, "debounce", 0, 8)) {
+                                       loaded = true;
+                               }
+                       }
+
+               } catch (Exception e) {
+                       loaded = false;
+               }
+
+               return loaded;
        }
 
        public int getDelay() {
-               return 10;
+               int debounce_delay = -1;
+
+               try {
+                       String read;
+
+                       FileReader delay = new FileReader("/sys/module/debounce/parameters/debounce_delay");
+                       BufferedReader delay_buf = new BufferedReader(delay);
+
+                       read = delay_buf.readLine();
+                       if (read != null) {
+                               debounce_delay = Integer.parseInt(read.trim());
+                       }
+               } catch (Exception e) {}
+
+               return debounce_delay;
        }
 
        private synchronized void extractModule() {
Impressum, Datenschutz