start unpacking file, this is just a stub for now
authorMichael Gernoth <michael@gernoth.net>
Fri, 20 May 2011 19:43:11 +0000 (21:43 +0200)
committerMichael Gernoth <michael@gernoth.net>
Fri, 20 May 2011 19:43:11 +0000 (21:43 +0200)
MS2Debounce/src/de/rmdir/ms2debounce/DebounceBootReceiver.java
MS2Debounce/src/de/rmdir/ms2debounce/DebounceModuleHelper.java
MS2Debounce/src/de/rmdir/ms2debounce/MS2Debounce.java

index de10592..2a15ea4 100644 (file)
@@ -8,7 +8,7 @@ public class DebounceBootReceiver extends BroadcastReceiver{
        @Override
        public void onReceive(Context context, Intent intent) {
                if("android.intent.action.BOOT_COMPLETED".equals(intent.getAction())) {
-                       DebounceModuleHelper module = new DebounceModuleHelper(context.getFilesDir());
+                       DebounceModuleHelper module = new DebounceModuleHelper(context);
 
                        module.loadModule();
                }
index fe9ffa8..2f9804c 100644 (file)
@@ -1,13 +1,17 @@
 package de.rmdir.ms2debounce;
 
+import java.io.InputStream;
+import java.io.OutputStream;
 import java.io.File;
 
+import android.content.Context;
+
 public class DebounceModuleHelper
 {
-       private File filesdir;
+       private Context ctx;
 
-       public DebounceModuleHelper(File appdir) {
-               filesdir = appdir;
+       public DebounceModuleHelper(Context context) {
+               ctx = context;
        }
 
        public void loadModule() {
@@ -23,11 +27,19 @@ public class DebounceModuleHelper
                return false;
        }
 
-       private void extractModule() {
-               File debounce_ko = new File(filesdir + "/debounce.ko");
+       private synchronized void extractModule() {
+               File debounce_ko = new File(ctx.getFilesDir() + "/debounce.ko");
 
                if (debounce_ko.exists()) {
                        return;
                }
+
+               try {
+                       InputStream apk = ctx.getAssets().open("debounce.ko");
+                       OutputStream mod = ctx.openFileOutput("debounce.ko", 0);
+
+                       apk.close();
+                       mod.close();
+               } catch (Exception e) {}
        }
 }
index 3f7814e..00eaa61 100644 (file)
@@ -11,7 +11,7 @@ public class MS2Debounce extends Activity
        {
                super.onCreate(savedInstanceState);
 
-               DebounceModuleHelper module = new DebounceModuleHelper(getFilesDir());
+               DebounceModuleHelper module = new DebounceModuleHelper(this);
 
                if (!module.isLoaded()) {
                        module.loadModule();
Impressum, Datenschutz