Example #1
0
 public static HtmlActivityTask launchHtmlScript(
     File script, Service service, Intent intent, InterpreterConfiguration config) {
   if (!script.exists()) {
     throw new RuntimeException("No such script to launch.");
   }
   HtmlInterpreter interpreter =
       (HtmlInterpreter) config.getInterpreterByName(HtmlInterpreter.HTML);
   if (interpreter == null) {
     throw new RuntimeException("HtmlInterpreter is not available.");
   }
   final FacadeManager manager =
       new FacadeManager(
           FacadeConfiguration.getSdkLevel(),
           service,
           intent,
           FacadeConfiguration.getFacadeClasses());
   FutureActivityTaskExecutor executor =
       ((BaseApplication) service.getApplication()).getTaskExecutor();
   final HtmlActivityTask task =
       new HtmlActivityTask(
           manager,
           interpreter.getAndroidJsSource(),
           interpreter.getJsonSource(),
           script.getAbsolutePath(),
           true);
   executor.execute(task);
   return task;
 }
Example #2
0
 @Override
 public void onDestroy() {
   super.onDestroy();
   mConfiguration.unregisterObserver(mObserver);
   // mManager.setOnCancelListener(null);
   android.os.Process.killProcess(android.os.Process.myPid());
   System.exit(1);
 }
  @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);
          }
        });
  }
Example #4
0
 private void buildMenuIdMaps() {
   mAddMenuIds = new LinkedHashMap<Integer, Interpreter>();
   int i = MenuId.values().length + Menu.FIRST;
   List<Interpreter> installed = mConfiguration.getInstalledInterpreters();
   Collections.sort(
       installed,
       new Comparator<Interpreter>() {
         @Override
         public int compare(Interpreter interpreterA, Interpreter interpreterB) {
           return interpreterA.getNiceName().compareTo(interpreterB.getNiceName());
         }
       });
   for (Interpreter interpreter : installed) {
     mAddMenuIds.put(i, interpreter);
     ++i;
   }
 }
Example #5
0
 public static InterpreterProcess launchInterpreter(
     final AndroidProxy proxy,
     Intent intent,
     InterpreterConfiguration config,
     Runnable shutdownHook) {
   Interpreter interpreter;
   String interpreterName;
   interpreterName = intent.getStringExtra(Constants.EXTRA_INTERPRETER_NAME);
   interpreter = config.getInterpreterByName(interpreterName);
   InterpreterProcess process = new InterpreterProcess(interpreter, proxy);
   if (shutdownHook == null) {
     process.start(
         new Runnable() {
           @Override
           public void run() {
             proxy.shutdown();
           }
         });
   } else {
     process.start(shutdownHook);
   }
   return process;
 }
Example #6
0
 @Override
 public void onStart() {
   super.onStart();
   mConfiguration.registerObserver(mObserver);
 }