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

View File

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

View File

@ -2,6 +2,10 @@
<LinearLayout <LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android" xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent" android:layout_width="fill_parent"
android:layout_height="fill_parent"> android:layout_height="fill_parent" android:isScrollContainer="true">
<TextView android:layout_width="fill_parent" android:layout_height="wrap_content" android:text="@string/reading_logs" android:id="@+id/logTextView"></TextView> <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> </LinearLayout>

View File

@ -59,7 +59,7 @@ public class SSLDroidGui extends ListActivity {
startService(new Intent(this, SSLDroid.class)); startService(new Intent(this, SSLDroid.class));
return true; return true;
case R.id.readlogs: case R.id.readlogs:
startService(new Intent(this, SSLDroid.class)); readLogs();
return true; return true;
} }
return super.onMenuItemSelected(featureId, item); return super.onMenuItemSelected(featureId, item);
@ -79,6 +79,9 @@ public class SSLDroidGui extends ListActivity {
Log.d("SSLDroid", "Starting service"); Log.d("SSLDroid", "Starting service");
startService(new Intent(this, SSLDroid.class)); startService(new Intent(this, SSLDroid.class));
return true; return true;
case R.id.readlogs:
readLogs();
return true;
} }
return super.onOptionsItemSelected(item); return super.onOptionsItemSelected(item);
} }
@ -101,6 +104,11 @@ public class SSLDroidGui extends ListActivity {
startActivityForResult(i, ACTIVITY_CREATE); 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 // ListView and view (row) on which was clicked, position and
@Override @Override
protected void onListItemClick(ListView l, View v, int position, long id) { 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.app.Activity;
import android.os.Bundle; import android.os.Bundle;
import android.util.Log;
import android.widget.TextView; import android.widget.TextView;
public class SSLDroidReadLogs extends Activity{ public class SSLDroidReadLogs extends Activity{
@ -14,19 +15,66 @@ public class SSLDroidReadLogs extends Activity{
public void onCreate(Bundle savedInstanceState) { public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
setContentView(R.layout.read_logs); setContentView(R.layout.read_logs);
try { TextView logcontainer = (TextView) findViewById(R.id.logTextView);
Process process = Runtime.getRuntime().exec("logcat -d"); /* try {
BufferedReader bufferedReader = new BufferedReader( int[] tags = new int[1];
new InputStreamReader(process.getInputStream())); 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());
}
} 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" });
StringBuilder log=new StringBuilder(); reader = new BufferedReader(new InputStreamReader(mLogcatProc.getInputStream()));
String line;
while ((line = bufferedReader.readLine()) != null) { String line;
log.append(line); final StringBuilder log = new StringBuilder();
} String separator = System.getProperty("line.separator");
TextView tv = (TextView)findViewById(R.id.logTextView);
tv.setText(log.toString()); while ((line = reader.readLine()) != null)
} catch (IOException e) { {
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());
}
}
} }
} }