Android Open Source - android-sms-relay Log Collector






From Project

Back to project page android-sms-relay.

License

The source code is released under:

GNU General Public License

If you think the Android project android-sms-relay listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

package com.nyaruka.log;
//  ww  w  .j  av a2s.c om
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.ArrayList;

import android.util.Log;

import com.nyaruka.androidrelay.AndroidRelay;
import com.nyaruka.androidrelay.MainActivity;

public class LogCollector {
  public final static String TAG = AndroidRelay.TAG;
  public static final String EXTRA_FORMAT = "com.nyaruka.log.FORMAT";//$NON-NLS-1$
  public static final String EXTRA_BUFFER = "com.nyaruka.log.BUFFER";//$NON-NLS-1$

  final int MAX_LOG_MESSAGE_LENGTH = 100000;

  public static String collectLog(){
    final StringBuilder log = new StringBuilder();
    try {
      ArrayList<String> commandLine = new ArrayList<String>();
      commandLine.add("logcat");//$NON-NLS-1$
      commandLine.add("-d");//$NON-NLS-1$

      commandLine.add("-v");
      commandLine.add("time");

      commandLine.add("-t");
      commandLine.add("2500");

      commandLine.add(AndroidRelay.TAG + ":V");
      commandLine.add("*:S");

      Process process = Runtime.getRuntime().exec(commandLine.toArray(new String[0]));
      BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(process.getInputStream()));

      String line;
      while ((line = bufferedReader.readLine()) != null) {
        log.append(line);
        log.append(MainActivity.LINE_SEPARATOR);
      }
    } catch (Throwable t){
      Log.e(TAG, "CollectLogTask.doInBackground failed", t);
    }
    
    return log.toString();
  }
}




Java Source Code List

com.commonsware.cwac.wakeful.AlarmReceiver.java
com.commonsware.cwac.wakeful.WakefulIntentService.java
com.nyaruka.android.actionbarcompat.ActionBarActivity.java
com.nyaruka.android.actionbarcompat.ActionBarHelperBase.java
com.nyaruka.android.actionbarcompat.ActionBarHelperHoneycomb.java
com.nyaruka.android.actionbarcompat.ActionBarHelperICS.java
com.nyaruka.android.actionbarcompat.ActionBarHelper.java
com.nyaruka.android.actionbarcompat.SimpleMenuItem.java
com.nyaruka.android.actionbarcompat.SimpleMenu.java
com.nyaruka.androidrelay.AlarmListener.java
com.nyaruka.androidrelay.AndroidRelay.java
com.nyaruka.androidrelay.BootStrapper.java
com.nyaruka.androidrelay.CheckService.java
com.nyaruka.androidrelay.MainActivity.java
com.nyaruka.androidrelay.MessageListFragment.java
com.nyaruka.androidrelay.RebootService.java
com.nyaruka.androidrelay.RelayService.java
com.nyaruka.androidrelay.SMSModem.java
com.nyaruka.androidrelay.SettingsActivity.java
com.nyaruka.androidrelay.data.TextMessageHelper.java
com.nyaruka.androidrelay.data.TextMessage.java
com.nyaruka.log.LogCollector.java