From: Michael Gernoth Date: Fri, 20 May 2011 19:43:11 +0000 (+0200) Subject: start unpacking file, this is just a stub for now X-Git-Url: https://git.zerfleddert.de/cgi-bin/gitweb.cgi/ms2-fixes/commitdiff_plain/5738a32fed2d7c93bfbcfcb8e1ccdffdc5dceb6a start unpacking file, this is just a stub for now --- diff --git a/MS2Debounce/src/de/rmdir/ms2debounce/DebounceBootReceiver.java b/MS2Debounce/src/de/rmdir/ms2debounce/DebounceBootReceiver.java index de10592..2a15ea4 100644 --- a/MS2Debounce/src/de/rmdir/ms2debounce/DebounceBootReceiver.java +++ b/MS2Debounce/src/de/rmdir/ms2debounce/DebounceBootReceiver.java @@ -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(); } diff --git a/MS2Debounce/src/de/rmdir/ms2debounce/DebounceModuleHelper.java b/MS2Debounce/src/de/rmdir/ms2debounce/DebounceModuleHelper.java index fe9ffa8..2f9804c 100644 --- a/MS2Debounce/src/de/rmdir/ms2debounce/DebounceModuleHelper.java +++ b/MS2Debounce/src/de/rmdir/ms2debounce/DebounceModuleHelper.java @@ -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) {} } } diff --git a/MS2Debounce/src/de/rmdir/ms2debounce/MS2Debounce.java b/MS2Debounce/src/de/rmdir/ms2debounce/MS2Debounce.java index 3f7814e..00eaa61 100644 --- a/MS2Debounce/src/de/rmdir/ms2debounce/MS2Debounce.java +++ b/MS2Debounce/src/de/rmdir/ms2debounce/MS2Debounce.java @@ -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();