From 0ae502f627e216e71b179a37079c9d43c7feeed3 Mon Sep 17 00:00:00 2001 From: Michael Gernoth Date: Fri, 20 May 2011 21:01:42 +0200 Subject: [PATCH] there is no need for a service --- .gitignore | 2 +- MS2Debounce/AndroidManifest.xml | 1 - .../ms2debounce/DebounceBootReceiver.java | 3 +-- .../ms2debounce/DebounceModuleHelper.java | 15 +++++++++++ .../de/rmdir/ms2debounce/DebounceService.java | 25 ------------------- .../src/de/rmdir/ms2debounce/MS2Debounce.java | 5 ++-- 6 files changed, 20 insertions(+), 31 deletions(-) create mode 100644 MS2Debounce/src/de/rmdir/ms2debounce/DebounceModuleHelper.java delete mode 100644 MS2Debounce/src/de/rmdir/ms2debounce/DebounceService.java diff --git a/.gitignore b/.gitignore index aafe4df..3e427b5 100644 --- a/.gitignore +++ b/.gitignore @@ -3,7 +3,7 @@ .debounce.o.cmd .tmp_versions/ Module.symvers -debounce.ko +./debounce.ko debounce.mod.c debounce.mod.o debounce.o diff --git a/MS2Debounce/AndroidManifest.xml b/MS2Debounce/AndroidManifest.xml index 7f9b472..bc90811 100644 --- a/MS2Debounce/AndroidManifest.xml +++ b/MS2Debounce/AndroidManifest.xml @@ -11,7 +11,6 @@ - diff --git a/MS2Debounce/src/de/rmdir/ms2debounce/DebounceBootReceiver.java b/MS2Debounce/src/de/rmdir/ms2debounce/DebounceBootReceiver.java index 2f97c2c..3ab003d 100644 --- a/MS2Debounce/src/de/rmdir/ms2debounce/DebounceBootReceiver.java +++ b/MS2Debounce/src/de/rmdir/ms2debounce/DebounceBootReceiver.java @@ -8,8 +8,7 @@ public class DebounceBootReceiver extends BroadcastReceiver{ @Override public void onReceive(Context context, Intent intent) { if("android.intent.action.BOOT_COMPLETED".equals(intent.getAction())) { - Intent debouncesvc = new Intent(context, DebounceService.class); - context.startService(debouncesvc); + DebounceModuleHelper.loadModule(); } } } diff --git a/MS2Debounce/src/de/rmdir/ms2debounce/DebounceModuleHelper.java b/MS2Debounce/src/de/rmdir/ms2debounce/DebounceModuleHelper.java new file mode 100644 index 0000000..f4569a5 --- /dev/null +++ b/MS2Debounce/src/de/rmdir/ms2debounce/DebounceModuleHelper.java @@ -0,0 +1,15 @@ +package de.rmdir.ms2debounce; + +public class DebounceModuleHelper +{ + static public void loadModule() { + 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() { + return false; + } +} diff --git a/MS2Debounce/src/de/rmdir/ms2debounce/DebounceService.java b/MS2Debounce/src/de/rmdir/ms2debounce/DebounceService.java deleted file mode 100644 index c4a8762..0000000 --- a/MS2Debounce/src/de/rmdir/ms2debounce/DebounceService.java +++ /dev/null @@ -1,25 +0,0 @@ -package de.rmdir.ms2debounce; - -import android.content.Intent; -import android.app.IntentService; - -public class DebounceService extends IntentService { - - // Create worker thread - public DebounceService() { - super("DebounceService"); - } - - @Override - protected void onHandleIntent(Intent intent) { - } - - @Override - public void onCreate() { - try { - Process insmod = Runtime.getRuntime().exec(new String[]{"su","-c","/system/bin/insmod /system/lib/modules/debounce.ko"}); - insmod.waitFor(); - } catch (Exception e) {} - super.onCreate(); - } -} diff --git a/MS2Debounce/src/de/rmdir/ms2debounce/MS2Debounce.java b/MS2Debounce/src/de/rmdir/ms2debounce/MS2Debounce.java index 99ca40d..85ec653 100644 --- a/MS2Debounce/src/de/rmdir/ms2debounce/MS2Debounce.java +++ b/MS2Debounce/src/de/rmdir/ms2debounce/MS2Debounce.java @@ -12,8 +12,9 @@ public class MS2Debounce extends Activity { super.onCreate(savedInstanceState); - Intent debouncesvc = new Intent(this, DebounceService.class); - startService(debouncesvc); + if (!DebounceModuleHelper.isLoaded()) { + DebounceModuleHelper.loadModule(); + } setContentView(R.layout.main); } -- 2.39.5