From d82ae5893a5e4cc3e082cf767aa7eca7edf87830 Mon Sep 17 00:00:00 2001 From: Michael Gernoth Date: Sat, 21 May 2011 00:19:37 +0200 Subject: [PATCH 1/1] implement isLoaded and getDelay in moduleHelper --- .../ms2debounce/DebounceModuleHelper.java | 37 ++++++++++++++++++- 1 file changed, 35 insertions(+), 2 deletions(-) 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() { -- 2.39.5