Skip to content

Commit

Permalink
#654 use root to get traffic bytes from proc
Browse files Browse the repository at this point in the history
  • Loading branch information
ukanth committed Dec 16, 2018
1 parent 5010d69 commit 5959dd5
Showing 1 changed file with 23 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@
import android.widget.TextView;

import com.raizlabs.android.dbflow.sql.language.SQLite;
import com.stericson.rootshell.RootShell;
import com.stericson.rootshell.execution.Command;
import com.stericson.rootshell.execution.Shell;
import com.stericson.roottools.RootTools;

import java.io.BufferedReader;
import java.io.File;
Expand Down Expand Up @@ -137,20 +141,25 @@ private void setTotalBytesManual(TextView down, TextView up, int localUid) {
String textSent = "0";
try {
if (uidActualFileReceived.exists() && uidActualFileSent.exists()) {
BufferedReader brReceived = new BufferedReader(new FileReader(uidActualFileReceived));
BufferedReader brSent = new BufferedReader(new FileReader(uidActualFileSent));
String receivedLine;
String sentLine;
if ((receivedLine = brReceived.readLine()) != null) {
textReceived = receivedLine;
}
if ((sentLine = brSent.readLine()) != null) {
textSent = sentLine;
}
down.setText(" : " + humanReadableByteCount(Long.parseLong(textReceived), false));
up.setText(" : " + humanReadableByteCount(Long.parseLong(textSent), false));
brReceived.close();
brSent.close();
Command command = new Command(0, "cat " + uidActualFileReceived.getAbsolutePath())
{
@Override
public void commandOutput(int id, String line) {
down.setText(" : " + humanReadableByteCount(Long.parseLong(line), false));
super.commandOutput(id, line);
}
};
Command command1 = new Command(1, "cat " + uidActualFileSent.getAbsolutePath())
{
@Override
public void commandOutput(int id, String line) {
up.setText(" : " + humanReadableByteCount(Long.parseLong(line), false));
super.commandOutput(id, line);
}
};
Shell shell = RootTools.getShell(true);
shell.add(command);
shell.add(command1);
}
} catch (Exception e) {
Log.e(TAG, "Exception while reading tx bytes: " + e.getLocalizedMessage());
Expand Down

0 comments on commit 5959dd5

Please sign in to comment.