Not logged in.  Login/Logout/Register | List snippets | | Create snippet | Upload image | Upload data

110
LINES

< > BotCompany Repo | #1004186 // Android Boot Program (try to start awareness)

JavaX source code (Android) [tags: use-pretranspiled] - run with: the app

Libraryless. Click here for Pure Java version (817L/6K/20K).

!752

import android.os.*;
import android.widget.*;
import android.app.*;

static S snippetToRun = "#1004078", snippetArg = "alarm";

static Class x30;
  
public static void main(final Service service) {
  androidContext = service;

  androidLifecycle("#1004186 toasting");

  pcall {
    androidToast("JavaX starting awareness.");
  }
  
  new Thread() {
    public void run() {
      try {
        androidLifecycle("#1004186 threading");
        String[] a = { snippetToRun, snippetArg };
        callx30(a);
      } catch e {
        androidLifecycle(e);
      }
    }
  }.start();

}

  static void callx30(S[] args) {
    getx30();
    androidLifecycle("#1004186 calling x30 " + join(" ", args));
    pcall {
      callMain(x30, args);
      androidLifecycle("x30 done");
    }
  }
  
  static synchronized void getx30() {
    if (x30 == null) {
      O dataStore = null;
      pcall {
        dataStore = Class.forName("de.tinybrain.javax_allperms.DataStore");
      }
      if (dataStore != null)
        x30 = (Class) call(dataStore, "get", "x30");
      if (x30 == null) {
        androidLifecycle("#1004186 loading x30");
        x30 = loadx30("#1004182");
        callOpt(dataStore, "put", "x30", x30);
      }
    }
  }
  
  static Class<?> loadx30(String programID) ctex {
    S url = "http://tinybrain.de:8080/dexcompile.php?id=" + parseSnippetID(programID);
    byte[] dexData = loadBinaryPage(url);
    if (!isDex(dexData))
      throw new RuntimeException("Dex generation error");
      
    androidLifecycle("Dex loaded: " + dexData.length + "b");

    File dexDir = makeAndroidTempDir();
    File dexFile = new File(dexDir, System.currentTimeMillis() + ".dex");
    File dexOutputDir = makeAndroidTempDir();

    try {
      saveBinaryFile(dexFile.getPath(), dexData);
    } catch (Throwable e) {
      System.out.println("Whoa!");
      throw new RuntimeException(e);
    }

    System.out.println("Getting parent class loader.");
    ClassLoader parentClassLoader =
      main.class.getClassLoader().getParent();

    //System.out.println("Making DexClassLoader.");
    //DexClassLoader classLoader = new DexClassLoader(dexFile.getAbsolutePath(), dexOutputDir.getAbsolutePath(), null,
    //  parentClassLoader);
    Class dcl = Class.forName("dalvik.system.DexClassLoader");
    Object classLoader = dcl.getConstructors()[0].newInstance(dexFile.getAbsolutePath(), dexOutputDir.getAbsolutePath(), null,
      parentClassLoader);

    androidLifecycle("Loading main class.");
    Class<?> theClass = (Class<?>) call(classLoader, "loadClass", "x30");

    androidLifecycle("Main class loaded.");
    try {
      set(theClass, "androidContext", androidContext);
    } catch (Throwable e) {}

    setVars(theClass, programID);
    hotwire_copyOver(theClass);
    return theClass;
  }
  
  static void setVars(Class<?> theClass, String programID) {
    try {
      set(theClass, "programID", programID);
    } catch (Throwable e) {}

    try {
      set(theClass, "__javax", x30);
    } catch (Throwable e) {}
  }

Author comment

Began life as a copy of #1002655

download  show line numbers  debug dex  old transpilations   

Travelled to 13 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, gwrvuhgaqvyk, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tslmcundralx, tvejysmllsmz, vouqrxazstgt

No comments. add comment

Snippet ID: #1004186
Snippet name: Android Boot Program (try to start awareness)
Eternal ID of this version: #1004186/1
Text MD5: eaa08f7130ffc91cae58c94d18a4805b
Transpilation MD5: b0c418a4b926bcda2d2840fae65ec88e
Author: stefan
Category:
Type: JavaX source code (Android)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2016-08-20 21:14:21
Source code size: 3140 bytes / 110 lines
Pitched / IR pitched: No / No
Views / Downloads: 446 / 808
Referenced in: [show references]