Skip to content

Commit

Permalink
Limit the maximum number of lines copied from logcat to 500.
Browse files Browse the repository at this point in the history
  • Loading branch information
iiordanov committed Jan 23, 2019
1 parent 7f08a26 commit 9228540
Show file tree
Hide file tree
Showing 11 changed files with 24 additions and 13 deletions.
20 changes: 14 additions & 6 deletions Opaque/src/main/java/com/undatech/opaque/util/LogcatReader.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package com.undatech.opaque.util;

import com.iiordanov.bVNC.Constants;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
Expand All @@ -22,20 +24,26 @@ public LogcatReader() {
logcatCommand.add(Integer.toString(id));
}

public String getMyLogcat() {
String logCatOutput = "";
String line = "";
public String getMyLogcat(int lines) {
ArrayList<String> logCatLines = new ArrayList<>(Constants.LOGCAT_MAX_LINES);
StringBuilder logCatOutput = new StringBuilder(Constants.LOGCAT_MAX_LINES);
String line;

try {
Process p = new ProcessBuilder().command(logcatCommand).start();
BufferedReader buffReader = new BufferedReader(new InputStreamReader(p.getInputStream()));
while ((line = buffReader.readLine()) != null) {
logCatOutput = logCatOutput + line + "\n";
logCatLines.add(line + "\n");
}
} catch (IOException e) {
android.util.Log.e (TAG, "Error obtaining output from logcat");
android.util.Log.e(TAG, "Error obtaining output from logcat");
e.printStackTrace();
}
return logCatOutput;

for (int i = Math.max(logCatLines.size() - Constants.LOGCAT_MAX_LINES, 0); i < logCatLines.size(); i++) {
logCatOutput.append(logCatLines.get(i));
}

return logCatOutput.toString();
}
}
2 changes: 1 addition & 1 deletion bVNC/AndroidManifest.xml.aRDP
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
package="com.iiordanov.aRDP" android:installLocation="auto"
android:versionCode="114034" android:versionName="v4.0.3">
android:versionCode="114035" android:versionName="v4.0.3">

<uses-sdk android:minSdkVersion="21"> </uses-sdk>
<uses-permission tools:node="removeAll"/>
Expand Down
2 changes: 1 addition & 1 deletion bVNC/AndroidManifest.xml.aSPICE
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
package="com.iiordanov.aSPICE" android:installLocation="auto"
android:versionCode="114034" android:versionName="v4.0.3">
android:versionCode="114035" android:versionName="v4.0.3">

<uses-sdk android:minSdkVersion="14"></uses-sdk>
<uses-permission tools:node="removeAll"/>
Expand Down
2 changes: 1 addition & 1 deletion bVNC/AndroidManifest.xml.bVNC
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
package="com.iiordanov.bVNC" android:installLocation="auto"
android:versionCode="114034" android:versionName="v4.0.3">
android:versionCode="114035" android:versionName="v4.0.3">

<uses-sdk android:minSdkVersion="14"> </uses-sdk>
<uses-permission
Expand Down
2 changes: 1 addition & 1 deletion bVNC/AndroidManifest.xml.freeaRDP
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
package="com.iiordanov.freeaRDP" android:installLocation="auto"
android:versionCode="114034" android:versionName="v4.0.3">
android:versionCode="114035" android:versionName="v4.0.3">

<uses-sdk android:minSdkVersion="21"> </uses-sdk>
<uses-permission tools:node="removeAll"/>
Expand Down
2 changes: 1 addition & 1 deletion bVNC/AndroidManifest.xml.freeaSPICE
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
package="com.iiordanov.freeaSPICE" android:installLocation="auto"
android:versionCode="114034" android:versionName="v4.0.3">
android:versionCode="114035" android:versionName="v4.0.3">

<uses-sdk android:minSdkVersion="14"> </uses-sdk>
<uses-permission tools:node="removeAll"/>
Expand Down
2 changes: 1 addition & 1 deletion bVNC/AndroidManifest.xml.freebVNC
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
package="com.iiordanov.freebVNC" android:installLocation="auto"
android:versionCode="114034" android:versionName="v4.0.3">
android:versionCode="114035" android:versionName="v4.0.3">

<uses-sdk android:minSdkVersion="14"> </uses-sdk>
<uses-permission tools:node="removeAll"/>
Expand Down
1 change: 1 addition & 0 deletions bVNC/CHANGELOG-aRDP
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
v4.0.3
- Fix for SD card redirection
- Updated FreeRDP
- Updated OpenSSL
- Updated sshlib
v4.0.2
- Fixes for widget names
Expand Down
1 change: 1 addition & 0 deletions bVNC/CHANGELOG-aSPICE
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
v4.0.3
- Updated spice library
- Updated gnutls
- Updated sshlib
v4.0.2
- Fixes for widget names
Expand Down
1 change: 1 addition & 0 deletions bVNC/src2/main/java/com/iiordanov/bVNC/Constants.java
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ public class Constants {
public static final int SOCKET_CONN_TIMEOUT = 30 * 1000; //30 sec

public static final int DEFAULT_SSH_PORT = 22;
public static final int LOGCAT_MAX_LINES = 500;
public static volatile int DEFAULT_PROTOCOL_PORT = 5900;
public static final int DEFAULT_VNC_PORT = 5900;
public static final int DEFAULT_RDP_PORT = 3389;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ public void onClick(View v) {
public void onClick(View v) {
LogcatReader logcatReader = new LogcatReader();
ClipboardManager cm = (ClipboardManager) getSystemService(Context.CLIPBOARD_SERVICE);
cm.setText(logcatReader.getMyLogcat());
cm.setText(logcatReader.getMyLogcat(Constants.LOGCAT_MAX_LINES));
Toast.makeText(getBaseContext(), getResources().getString(R.string.log_copied),
Toast.LENGTH_LONG).show();
}
Expand Down

0 comments on commit 9228540

Please sign in to comment.