From 226a7d4d64fdbd6731e7f44f897343ad9f38658f Mon Sep 17 00:00:00 2001 From: Michael Gernoth Date: Fri, 20 May 2011 21:25:44 +0200 Subject: [PATCH 1/1] make helper non-static --- MS2Debounce/res/layout/main.xml | 2 +- .../ms2debounce/DebounceBootReceiver.java | 4 +++- .../ms2debounce/DebounceModuleHelper.java | 22 +++++++++++++++++-- .../src/de/rmdir/ms2debounce/MS2Debounce.java | 21 +++++++++--------- 4 files changed, 35 insertions(+), 14 deletions(-) diff --git a/MS2Debounce/res/layout/main.xml b/MS2Debounce/res/layout/main.xml index 0a850ba..8fc5194 100644 --- a/MS2Debounce/res/layout/main.xml +++ b/MS2Debounce/res/layout/main.xml @@ -7,7 +7,7 @@ diff --git a/MS2Debounce/src/de/rmdir/ms2debounce/DebounceBootReceiver.java b/MS2Debounce/src/de/rmdir/ms2debounce/DebounceBootReceiver.java index 3ab003d..de10592 100644 --- a/MS2Debounce/src/de/rmdir/ms2debounce/DebounceBootReceiver.java +++ b/MS2Debounce/src/de/rmdir/ms2debounce/DebounceBootReceiver.java @@ -8,7 +8,9 @@ public class DebounceBootReceiver extends BroadcastReceiver{ @Override public void onReceive(Context context, Intent intent) { if("android.intent.action.BOOT_COMPLETED".equals(intent.getAction())) { - DebounceModuleHelper.loadModule(); + DebounceModuleHelper module = new DebounceModuleHelper(context.getFilesDir()); + + module.loadModule(); } } } diff --git a/MS2Debounce/src/de/rmdir/ms2debounce/DebounceModuleHelper.java b/MS2Debounce/src/de/rmdir/ms2debounce/DebounceModuleHelper.java index f4569a5..fe9ffa8 100644 --- a/MS2Debounce/src/de/rmdir/ms2debounce/DebounceModuleHelper.java +++ b/MS2Debounce/src/de/rmdir/ms2debounce/DebounceModuleHelper.java @@ -1,15 +1,33 @@ package de.rmdir.ms2debounce; +import java.io.File; + public class DebounceModuleHelper { - static public void loadModule() { + private File filesdir; + + public DebounceModuleHelper(File appdir) { + filesdir = appdir; + } + + public void loadModule() { + extractModule(); + try { Process insmod = Runtime.getRuntime().exec(new String[]{"su","-c","/system/bin/insmod /system/lib/modules/debounce.ko"}); insmod.waitFor(); } catch (Exception e) {} } - static public boolean isLoaded() { + public boolean isLoaded() { return false; } + + private void extractModule() { + File debounce_ko = new File(filesdir + "/debounce.ko"); + + if (debounce_ko.exists()) { + return; + } + } } diff --git a/MS2Debounce/src/de/rmdir/ms2debounce/MS2Debounce.java b/MS2Debounce/src/de/rmdir/ms2debounce/MS2Debounce.java index 85ec653..3f7814e 100644 --- a/MS2Debounce/src/de/rmdir/ms2debounce/MS2Debounce.java +++ b/MS2Debounce/src/de/rmdir/ms2debounce/MS2Debounce.java @@ -6,16 +6,17 @@ import android.content.Intent; public class MS2Debounce extends Activity { - /** Called when the activity is first created. */ - @Override - public void onCreate(Bundle savedInstanceState) - { - super.onCreate(savedInstanceState); + @Override + public void onCreate(Bundle savedInstanceState) + { + super.onCreate(savedInstanceState); - if (!DebounceModuleHelper.isLoaded()) { - DebounceModuleHelper.loadModule(); - } + DebounceModuleHelper module = new DebounceModuleHelper(getFilesDir()); + + if (!module.isLoaded()) { + module.loadModule(); + } - setContentView(R.layout.main); - } + setContentView(R.layout.main); + } } -- 2.39.5