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 e4ad296..229f00a 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