|
|
|
@ -19,6 +19,7 @@ import java.io.BufferedReader;
|
|
|
|
|
|
|
|
|
|
public class SimpleSSHD extends Activity
|
|
|
|
|
{
|
|
|
|
|
private static final Object lock = new Object();
|
|
|
|
|
private EditText log_view;
|
|
|
|
|
private Button startstop_view;
|
|
|
|
|
public static SimpleSSHD curr = null;
|
|
|
|
@ -34,14 +35,18 @@ public class SimpleSSHD extends Activity
|
|
|
|
|
|
|
|
|
|
public void onResume() {
|
|
|
|
|
super.onResume();
|
|
|
|
|
curr = this;
|
|
|
|
|
update_startstop();
|
|
|
|
|
synchronized (lock) {
|
|
|
|
|
curr = this;
|
|
|
|
|
}
|
|
|
|
|
update_startstop_prime();
|
|
|
|
|
updater = new UpdaterThread();
|
|
|
|
|
updater.start();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void onPause() {
|
|
|
|
|
curr = null;
|
|
|
|
|
synchronized (lock) {
|
|
|
|
|
curr = null;
|
|
|
|
|
}
|
|
|
|
|
updater.interrupt();
|
|
|
|
|
super.onPause();
|
|
|
|
|
}
|
|
|
|
@ -66,7 +71,7 @@ public class SimpleSSHD extends Activity
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void update_startstop() {
|
|
|
|
|
private void update_startstop_prime() {
|
|
|
|
|
if (SimpleSSHDService.is_started()) {
|
|
|
|
|
startstop_view.setText("STOP");
|
|
|
|
|
startstop_view.setTextColor(0xFF881111);
|
|
|
|
@ -76,6 +81,23 @@ public class SimpleSSHD extends Activity
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static void update_startstop() {
|
|
|
|
|
Thread t = new Thread() {
|
|
|
|
|
public void run() {
|
|
|
|
|
synchronized (lock) {
|
|
|
|
|
if (curr != null) {
|
|
|
|
|
curr.update_startstop_prime();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
synchronized (lock) {
|
|
|
|
|
if (curr != null) {
|
|
|
|
|
curr.runOnUiThread(t);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void startstop_clicked(View v) {
|
|
|
|
|
Intent i = new Intent(this, SimpleSSHDService.class);
|
|
|
|
|
if (SimpleSSHDService.is_started()) {
|
|
|
|
@ -84,7 +106,7 @@ public class SimpleSSHD extends Activity
|
|
|
|
|
startService(i);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void update_log() {
|
|
|
|
|
private void update_log_prime() {
|
|
|
|
|
String[] lines = new String[50];
|
|
|
|
|
int curr_line = 0;
|
|
|
|
|
boolean wrapped = false;
|
|
|
|
@ -118,4 +140,21 @@ public class SimpleSSHD extends Activity
|
|
|
|
|
log_view.setText(output);
|
|
|
|
|
log_view.setSelection(output.length());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static void update_log() {
|
|
|
|
|
Thread t = new Thread() {
|
|
|
|
|
public void run() {
|
|
|
|
|
synchronized (lock) {
|
|
|
|
|
if (curr != null) {
|
|
|
|
|
curr.update_log_prime();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
synchronized (lock) {
|
|
|
|
|
if (curr != null) {
|
|
|
|
|
curr.runOnUiThread(t);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|