From: Michael Gernoth Date: Fri, 20 May 2011 22:19:37 +0000 (+0200) Subject: implement isLoaded and getDelay in moduleHelper X-Git-Url: https://git.zerfleddert.de/cgi-bin/gitweb.cgi/ms2-fixes/commitdiff_plain/d82ae5893a5e4cc3e082cf767aa7eca7edf87830?ds=sidebyside implement isLoaded and getDelay in moduleHelper --- diff --git a/MS2Debounce/src/de/rmdir/ms2debounce/DebounceModuleHelper.java b/MS2Debounce/src/de/rmdir/ms2debounce/DebounceModuleHelper.java index e4ad296..229f00a 100644 --- a/MS2Debounce/src/de/rmdir/ms2debounce/DebounceModuleHelper.java +++ b/MS2Debounce/src/de/rmdir/ms2debounce/DebounceModuleHelper.java @@ -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() {