moved diagnotics to menu option (not launcher)
This commit is contained in:
parent
b6e7a02fb4
commit
4aa3cd6ea2
|
@ -72,6 +72,14 @@
|
||||||
yourapp:showAsAction="ifRoom"
|
yourapp:showAsAction="ifRoom"
|
||||||
|
|
||||||
/>
|
/>
|
||||||
|
|
||||||
|
|
||||||
|
<item android:id="@+id/menu_diag"
|
||||||
|
android:title="Test Mode"
|
||||||
|
android:icon="@drawable/ic_menu_check"
|
||||||
|
yourapp:showAsAction="never"
|
||||||
|
|
||||||
|
/>
|
||||||
|
|
||||||
</menu>
|
</menu>
|
||||||
<!--
|
<!--
|
||||||
|
|
|
@ -3,7 +3,7 @@ SOCKSListenAddress 127.0.0.1
|
||||||
SafeSocks 0
|
SafeSocks 0
|
||||||
TestSocks 1
|
TestSocks 1
|
||||||
WarnUnsafeSocks 1
|
WarnUnsafeSocks 1
|
||||||
Log debug stdout
|
Log info stdout
|
||||||
ControlListenAddress 127.0.0.1
|
ControlListenAddress 127.0.0.1
|
||||||
ControlPort 9051
|
ControlPort 9051
|
||||||
CookieAuthentication 1
|
CookieAuthentication 1
|
||||||
|
|
|
@ -34,6 +34,7 @@ public class OrbotDiagnosticsActivity extends Activity {
|
||||||
private TextView mTextView = null;
|
private TextView mTextView = null;
|
||||||
private final static String TAG = "OrbotDiag";
|
private final static String TAG = "OrbotDiag";
|
||||||
private StringBuffer log = new StringBuffer();
|
private StringBuffer log = new StringBuffer();
|
||||||
|
Process mProcess;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onCreate(Bundle savedInstanceState) {
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
|
@ -64,17 +65,22 @@ public class OrbotDiagnosticsActivity extends Activity {
|
||||||
protected void onDestroy() {
|
protected void onDestroy() {
|
||||||
|
|
||||||
super.onDestroy();
|
super.onDestroy();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private void stopTor ()
|
||||||
|
{
|
||||||
File appBinHome = this.getDir("bin", Context.MODE_PRIVATE);
|
File appBinHome = this.getDir("bin", Context.MODE_PRIVATE);
|
||||||
|
|
||||||
File fileTor= new File(appBinHome, TorServiceConstants.TOR_ASSET_KEY);
|
File fileTor= new File(appBinHome, TorServiceConstants.TOR_ASSET_KEY);
|
||||||
|
|
||||||
try {
|
if (mProcess != null)
|
||||||
killAllTor (fileTor);
|
mProcess.destroy();
|
||||||
} catch (IOException e) {
|
|
||||||
// TODO Auto-generated catch block
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onResume() {
|
protected void onResume() {
|
||||||
|
@ -102,40 +108,6 @@ public class OrbotDiagnosticsActivity extends Activity {
|
||||||
runTorTest();
|
runTorTest();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void killAllTor (File fileTor) throws IOException
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
int maxTry = 5;
|
|
||||||
int currTry = 0;
|
|
||||||
|
|
||||||
Shell shell = Shell.startShell();
|
|
||||||
int procId;
|
|
||||||
|
|
||||||
while ((procId = TorServiceUtils.findProcessId(fileTor.getAbsolutePath())) != -1 && currTry++ < maxTry)
|
|
||||||
{
|
|
||||||
|
|
||||||
log ("Found existing orphan Tor process; Trying to shutdown now (device restart may be needed)...");
|
|
||||||
log("Found Tor PID=" + procId + " - attempt to shutdown now...");
|
|
||||||
|
|
||||||
SimpleCommand killCommand = new SimpleCommand("toolbox kill -9 " + procId);
|
|
||||||
shell.add(killCommand);
|
|
||||||
killCommand.waitForFinish();
|
|
||||||
log ("kill output: " + killCommand.getExitCode() + "; " + killCommand.getOutput());
|
|
||||||
killCommand = new SimpleCommand("kill -9 " + procId);
|
|
||||||
shell.add(killCommand);
|
|
||||||
killCommand.waitForFinish();
|
|
||||||
log ("kill output: " + killCommand.getExitCode() + "; " + killCommand.getOutput());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
catch (Exception e)
|
|
||||||
{
|
|
||||||
log("error killing Tor: " + e.getLocalizedMessage());
|
|
||||||
Log.d(TAG, "error killing Tor", e);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
private void runTorTest ()
|
private void runTorTest ()
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
|
@ -145,8 +117,7 @@ public class OrbotDiagnosticsActivity extends Activity {
|
||||||
|
|
||||||
File fileTor= new File(appBinHome, TorServiceConstants.TOR_ASSET_KEY);
|
File fileTor= new File(appBinHome, TorServiceConstants.TOR_ASSET_KEY);
|
||||||
enableBinExec (fileTor, appBinHome);
|
enableBinExec (fileTor, appBinHome);
|
||||||
killAllTor (fileTor);
|
|
||||||
|
|
||||||
InputStream is = getResources().openRawResource(R.raw.torrcdiag);
|
InputStream is = getResources().openRawResource(R.raw.torrcdiag);
|
||||||
File fileTorrc = new File(appBinHome, TorServiceConstants.TORRC_ASSET_KEY + "diag");
|
File fileTorrc = new File(appBinHome, TorServiceConstants.TORRC_ASSET_KEY + "diag");
|
||||||
TorResourceInstaller.streamToFile(is,fileTorrc, false, false);
|
TorResourceInstaller.streamToFile(is,fileTorrc, false, false);
|
||||||
|
@ -163,20 +134,20 @@ public class OrbotDiagnosticsActivity extends Activity {
|
||||||
|
|
||||||
log ("Executing command> " + cmd);
|
log ("Executing command> " + cmd);
|
||||||
|
|
||||||
Process process = Runtime.getRuntime().exec(cmd);
|
mProcess = Runtime.getRuntime().exec(cmd);
|
||||||
|
|
||||||
BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(process.getInputStream()));
|
BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(mProcess.getInputStream()));
|
||||||
StreamGobbler sg = new StreamGobbler();
|
StreamGobbler sg = new StreamGobbler();
|
||||||
sg.reader = bufferedReader;
|
sg.reader = bufferedReader;
|
||||||
sg.process = process;
|
sg.process = mProcess;
|
||||||
new Thread(sg).start();
|
new Thread(sg).start();
|
||||||
|
|
||||||
if (process.getErrorStream() != null)
|
if (mProcess.getErrorStream() != null)
|
||||||
{
|
{
|
||||||
bufferedReader = new BufferedReader(new InputStreamReader(process.getErrorStream()));
|
bufferedReader = new BufferedReader(new InputStreamReader(mProcess.getErrorStream()));
|
||||||
sg = new StreamGobbler();
|
sg = new StreamGobbler();
|
||||||
sg.reader = bufferedReader;
|
sg.reader = bufferedReader;
|
||||||
sg.process = process;
|
sg.process = mProcess;
|
||||||
new Thread(sg).start();
|
new Thread(sg).start();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -209,7 +180,8 @@ public class OrbotDiagnosticsActivity extends Activity {
|
||||||
Log.d(TAG, "error reading line",e);
|
Log.d(TAG, "error reading line",e);
|
||||||
}
|
}
|
||||||
|
|
||||||
log("Tor exit code=" + process.exitValue() + ";");
|
//log("Tor exit code=" + process.exitValue() + ";");
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue