예제 #1
0
  private void updateLog(String iData) {
    if (_service != null) {
      List<String> aTempOut = _service.popOutput();
      if (aTempOut != null) {
        Log.d(Tools.TAG, "Popping temporary logs (" + aTempOut.size() + " lines)");
        _logTextView.append(Tools.ToString(aTempOut));
      }
    }
    if (iData != null) _logTextView.append(iData + "\n");

    // Limit log size (allow 10% to avoid doing it on each iteration)
    if (_service != null && _logTextView.getLineCount() > 1.1 * _service._maxLogSize) {
      int excessLineNumber = _logTextView.getLineCount() - _service._maxLogSize;
      Log.d(Tools.TAG, "Truncating logs (deleting " + excessLineNumber + " lines)");
      int eolIndex = -1;
      CharSequence charSequence = _logTextView.getText();
      for (int i = 0; i < excessLineNumber; i++) {
        do {
          eolIndex++;
        } while (eolIndex < charSequence.length() && charSequence.charAt(eolIndex) != '\n');
      }
      if (eolIndex < charSequence.length()) {
        _logTextView.getEditableText().delete(0, eolIndex + 1);
      } else {
        _logTextView.setText("");
      }
    }
  }
예제 #2
0
 private boolean checkRoot() {
   if (_service != null && _service._useSU) {
     // Ensure su is working correctly, as some implementations do simply nothing, without error...
     String aOut = Tools.ToString(Tools.Run("su", "id"));
     return (aOut.length() >= 5 && aOut.substring(0, 5).equals("uid=0"));
   }
   return true;
 }