1
0
mirror of https://github.com/moparisthebest/SSLDroid synced 2024-11-27 03:12:18 -05:00

Polished log view to a usable stage

Signed-off-by: Balint Kovacs <blint@blint.hu>
This commit is contained in:
Balint Kovacs 2011-05-03 17:06:04 +02:00
parent 662d62d7bd
commit 11db518fe9
5 changed files with 79 additions and 17 deletions

View File

@ -2,7 +2,6 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="hu.blint.ssldroid" android:versionCode="1"
android:versionName="1.0">
<uses-permission android:name="android.permission.READ_LOGS"></uses-permission>
<application android:label="@string/app_name" android:icon="@drawable/icon">
<activity android:name="SSLDroidGui" android:label="@string/app_name">
<intent-filter>
@ -12,6 +11,8 @@
</activity>
<activity android:name=".SSLDroidTunnelDetails"
android:windowSoftInputMode="stateVisible|adjustResize" />
<activity android:name=".SSLDroidReadLogs"
android:windowSoftInputMode="stateVisible|adjustResize" />
<service android:enabled="true" android:name="SSLDroid">
<intent-filter>
<action android:name="hu.blint.ssldroid.SSLDroid" />
@ -28,4 +29,5 @@
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
<uses-permission android:name="android.permission.READ_LOGS" />
</manifest>

View File

@ -8,4 +8,4 @@
# project structure.
# Project target.
target=android-7
target=android-8

View File

@ -2,6 +2,10 @@
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<TextView android:layout_width="fill_parent" android:layout_height="wrap_content" android:text="@string/reading_logs" android:id="@+id/logTextView"></TextView>
android:layout_height="fill_parent" android:isScrollContainer="true">
<ScrollView android:id="@+id/scrollView1" android:layout_height="match_parent" android:layout_width="wrap_content">
<LinearLayout android:id="@+id/linearLayout1" android:layout_width="match_parent" android:layout_height="match_parent">
<TextView android:layout_height="wrap_content" android:layout_width="fill_parent" android:id="@+id/logTextView" android:text="@string/reading_logs"></TextView>
</LinearLayout>
</ScrollView>
</LinearLayout>

View File

@ -59,7 +59,7 @@ public class SSLDroidGui extends ListActivity {
startService(new Intent(this, SSLDroid.class));
return true;
case R.id.readlogs:
startService(new Intent(this, SSLDroid.class));
readLogs();
return true;
}
return super.onMenuItemSelected(featureId, item);
@ -79,6 +79,9 @@ public class SSLDroidGui extends ListActivity {
Log.d("SSLDroid", "Starting service");
startService(new Intent(this, SSLDroid.class));
return true;
case R.id.readlogs:
readLogs();
return true;
}
return super.onOptionsItemSelected(item);
}
@ -101,6 +104,11 @@ public class SSLDroidGui extends ListActivity {
startActivityForResult(i, ACTIVITY_CREATE);
}
private void readLogs() {
Intent i = new Intent(this, SSLDroidReadLogs.class);
startActivity(i);
}
// ListView and view (row) on which was clicked, position and
@Override
protected void onListItemClick(ListView l, View v, int position, long id) {

View File

@ -6,6 +6,7 @@ import java.io.InputStreamReader;
import android.app.Activity;
import android.os.Bundle;
import android.util.Log;
import android.widget.TextView;
public class SSLDroidReadLogs extends Activity{
@ -14,19 +15,66 @@ public class SSLDroidReadLogs extends Activity{
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.read_logs);
try {
Process process = Runtime.getRuntime().exec("logcat -d");
BufferedReader bufferedReader = new BufferedReader(
new InputStreamReader(process.getInputStream()));
StringBuilder log=new StringBuilder();
String line;
while ((line = bufferedReader.readLine()) != null) {
log.append(line);
TextView logcontainer = (TextView) findViewById(R.id.logTextView);
/* try {
int[] tags = new int[1];
tags[0] = 0;
Collection<EventLog.Event> output = new HashSet<EventLog.Event>();
EventLog eventlog = new EventLog();
eventlog.readEvents(tags, output);
//Log.i("test",Integer.toString(desc.mTag));
logcontainer.setText("wtf");
Iterator<EventLog.Event> logs = output.iterator();
while (logs.hasNext()){
Log.d("SSLDroid", "Entry");
EventLog.Event entry = logs.next();
logcontainer.append(entry.getData().toString());
}
TextView tv = (TextView)findViewById(R.id.logTextView);
tv.setText(log.toString());
} catch (IOException e) {
e.printStackTrace();
} */
Process mLogcatProc = null;
BufferedReader reader = null;
try
{
mLogcatProc = Runtime.getRuntime().exec(new String[]
{"logcat", "-d", "SSLDroid:D SSLDroidGui:D *:S" });
reader = new BufferedReader(new InputStreamReader(mLogcatProc.getInputStream()));
String line;
final StringBuilder log = new StringBuilder();
String separator = System.getProperty("line.separator");
while ((line = reader.readLine()) != null)
{
log.append(line);
log.append(separator);
}
logcontainer.setText(log);
}
catch (IOException e)
{
Log.d("SSLDroid", "Logcat problem: "+e.toString());
}
finally
{
if (reader != null)
try
{
reader.close();
}
catch (IOException e)
{
Log.d("SSLDroid", "Logcat problem: "+e.toString());
}
}
}
}