+ SharedPreferences settings = ctx.getSharedPreferences(PREFS_NAME, Context.MODE_PRIVATE);
+ SharedPreferences.Editor editor = settings.edit();
+ if (is_safe_to_load()) {
+ editor.putBoolean("safe_to_load", false);
+ editor.commit();
+ }
+
+ try {
+ runAsRoot("/system/bin/insmod " + debounce_ko + " debounce_delay=" + delay);
+ } catch (Exception e) {
+ return;
+ }
+
+ if (!isLoaded()) {
+ return;
+ }
+
+ if (getDelay() <= 0) {
+ return;
+ }
+
+ /* Module was obviously loaded, so it is safe to load on boot */
+ editor.putBoolean("safe_to_load", true);
+ editor.commit();
+ }
+
+ public synchronized void unloadModule() {
+ try {
+ runAsRoot("/system/bin/rmmod debounce");
+ } catch (Exception e) {}
+ }
+
+ public synchronized boolean isLoaded() {
+ 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 synchronized int getDelay() {
+ int debounce_delay = -1;
+