Пример #1
0
 RpcReceiverManager getRpcReceiverManager() throws InterruptedException {
   mLatch.await();
   if (mFacadeManager == null) { // Facade manage may not be available on
     // startup.
     mFacadeManager = mProxy.getRpcReceiverManagerFactory().getRpcReceiverManagers().get(0);
   }
   return mFacadeManager;
 }
Пример #2
0
  @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);
          }
        });
  }
Пример #3
0
  @Override
  public void onDestroy() {
    super.onDestroy();
    Log.d("onDestroy()");

    Log.d("Closing socket connections");
    if (mProxy != null) mProxy.shutdown();
    Log.d("Script ended");

    try {
      if (sock != null) {
        sock.close();
        sock = null;
      }
      if (serverSock != null) {
        serverSock.close();
        serverSock = null;
      }
    } catch (IOException e) {
      Log.d(e.toString());
    }
  }