public void onCreate() {
   super.onCreate();
   thisInstance = this;
   String str = GitBuildId.getAcraUri();
   if (str.equals("")) {
     Log.i("ReplApplication", "ACRA Not Active");
     return;
   }
   Log.i("ReplApplication", "ACRA Active, URI = " + str);
   ACRAConfiguration localACRAConfiguration = ACRA.getNewDefaultConfig(this);
   localACRAConfiguration.setFormUri(str);
   localACRAConfiguration.setDisableSSLCertValidation(true);
   ACRA.setConfig(localACRAConfiguration);
   ACRA.init(this);
   this.active = true;
 }
Example #2
0
  private static void startCoreDaemon() throws SuException, DaemonException {
    boolean access_granted = false;
    DataOutputStream writer = null;
    BufferedReader reader = null;
    String line;
    int ret = -1;

    try {
      Process shell = Runtime.getRuntime().exec("su");
      writer = new DataOutputStream(shell.getOutputStream());
      String cmd;

      cmd =
          String.format(
              "{ echo 'ACCESS GRANTED' >&2; cd '%s' && exec ./start_daemon.sh ;} || exit 1\n",
              System.getCorePath());

      writer.write(cmd.getBytes());
      writer.flush();

      ret = shell.waitFor();

      if (ret != 0) {
        reader = new BufferedReader(new InputStreamReader(shell.getErrorStream()));

        while ((line = reader.readLine()) != null) {
          if (line.equals("ACCESS GRANTED")) {
            access_granted = true;
            Logger.debug("'ACCESS GRANTED' found");
          } else Logger.warning("STDERR: " + line);
        }
      } else access_granted = true;

    } catch (IOException e) {
      // command "su" not found or cannot write to it's stdin
      Logger.error(e.getMessage());
    } catch (InterruptedException e) {
      // interrupted while waiting for shell exit value
      Logger.error(e.getMessage());
    } finally {
      if (writer != null)
        try {
          writer.close();
        } catch (IOException ignored) {
        }
      if (reader != null)
        try {
          reader.close();
        } catch (IOException ignored) {
        }
    }

    mKnownIssues.fromFile(String.format("%s/issues", getCorePath()));

    if (!access_granted) throw new SuException();

    if (ret != 0) {
      File log = new File(System.getCorePath(), "cSploitd.log");
      DaemonException daemonException = new DaemonException("core daemon returned " + ret);
      if (log.exists() && log.canRead()) {
        ACRAConfiguration conf = ACRA.getConfig();
        conf.setApplicationLogFile(log.getAbsolutePath());
        ACRA.setConfig(conf);
        ACRA.getErrorReporter().handleException(daemonException, false);
      }
      throw daemonException;
    }
  }