@Override
  public void onStart(Intent intent, final int startId) {
    super.onStart(intent, startId);

    String path = intent.getStringExtra("scriptPath");
    Log.d("Script Path: " + path);
    mScript = new Script(path);
    Log.d("FileName: " + mScript.getFileName());
    Log.d("FileExtension: " + mScript.getFileExtension());

    handleNetwork();

    Interpreter interpreter =
        mInterpreterConfiguration.getInterpreterForScript(mScript.getFileName());
    if (interpreter == null || !interpreter.isInstalled()) {
      mLatch.countDown();
      if (FeaturedInterpreters.isSupported(mScript.getFileName())) {
        Log.d("Is Supported");
        Intent i = new Intent(this, DialogActivity.class);
        i.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
        i.putExtra(Constants.EXTRA_SCRIPT_PATH, mScript.getFileName());
        startActivity(i);
      } else {
        Log.e(this, "Cannot find an interpreter for script " + mScript.getFileName());
      }
      stopSelf(startId);
      return;
    }

    File script = new File(path);
    Log.d("Launch with proxy ");

    mProxy = new AndroidProxy(this, null, true);
    mProxy.startLocal();
    mLatch.countDown();
    ScriptLauncher.launchScript(
        script,
        mInterpreterConfiguration,
        mProxy,
        new Runnable() {
          @Override
          public void run() {
            mProxy.shutdown();
            stopSelf(startId);
          }
        });
  }
Exemple #2
0
 public void execute(String scriptName, String function, String arguments) {
   for (Script s : this) {
     if (s.getFile().equals(scriptName)) {
       if (s.getCompiledScript() == null) {
         InterpreterFactory.getFactory()
             .getScript(s.getFileName())
             .invoke(s.getMain(), (Object) s.getMainArgs());
       } else {
         try {
           s.getCompiledScript().eval();
         } catch (ScriptException e) {
           e.printStackTrace();
         }
       }
     }
   }
 }