there is no need for a service
authorMichael Gernoth <michael@gernoth.net>
Fri, 20 May 2011 19:01:42 +0000 (21:01 +0200)
committerMichael Gernoth <michael@gernoth.net>
Fri, 20 May 2011 19:01:42 +0000 (21:01 +0200)
.gitignore
MS2Debounce/AndroidManifest.xml
MS2Debounce/src/de/rmdir/ms2debounce/DebounceBootReceiver.java
MS2Debounce/src/de/rmdir/ms2debounce/DebounceModuleHelper.java [new file with mode: 0644]
MS2Debounce/src/de/rmdir/ms2debounce/DebounceService.java [deleted file]
MS2Debounce/src/de/rmdir/ms2debounce/MS2Debounce.java

index aafe4df..3e427b5 100644 (file)
@@ -3,7 +3,7 @@
 .debounce.o.cmd
 .tmp_versions/
 Module.symvers
-debounce.ko
+./debounce.ko
 debounce.mod.c
 debounce.mod.o
 debounce.o
index 7f9b472..bc90811 100644 (file)
@@ -11,7 +11,6 @@
                 <category android:name="android.intent.category.LAUNCHER" />
             </intent-filter>
         </activity>
-       <service android:name=".DebounceService"/>
        <receiver android:name=".DebounceBootReceiver">
                <intent-filter>
                        <action android:name="android.intent.action.BOOT_COMPLETED" />
index 2f97c2c..3ab003d 100644 (file)
@@ -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 (file)
index 0000000..f4569a5
--- /dev/null
@@ -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 (file)
index c4a8762..0000000
+++ /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();
-       }
-}
index 99ca40d..85ec653 100644 (file)
@@ -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);
     }
Impressum, Datenschutz