@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();
}
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() {
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) {}
}
}
{
super.onCreate(savedInstanceState);
- DebounceModuleHelper module = new DebounceModuleHelper(getFilesDir());
+ DebounceModuleHelper module = new DebounceModuleHelper(this);
if (!module.isLoaded()) {
module.loadModule();