diff --git a/jni/interface.c b/jni/interface.c index e29f81f..099c833 100644 --- a/jni/interface.c +++ b/jni/interface.c @@ -31,7 +31,7 @@ jni_init(JNIEnv *env_) CLASS(string, "java/lang/String") CLASS(simplesshdservice, "org/galexander/sshd/SimpleSSHDService") - FIELD(sss_sshd_pid, simplesshdservice, "sshd_pid", "I") + STFIELD(sss_sshd_pid, simplesshdservice, "sshd_pid", "I") return 1; } @@ -48,7 +48,7 @@ Java_org_galexander_sshd_SimpleSSHDService_start_1sshd(JNIEnv *env_, if (pid == 0) { /* XXX - call dropbear main() */ } else { - (*env)->SetIntField(env, this, fid_sss_sshd_pid, pid); + (*env)->SetStaticIntField(env, cl_simplesshdservice, fid_sss_sshd_pid, pid); } } @@ -59,7 +59,7 @@ Java_org_galexander_sshd_SimpleSSHDService_stop_1sshd(JNIEnv *env_, jobject this if (!jni_init(env_)) { return; } - pid = (*env)->GetIntField(env, this, fid_sss_sshd_pid); + pid = (*env)->GetStaticIntField(env, cl_simplesshdservice, fid_sss_sshd_pid); kill(pid, SIGKILL); - (*env)->SetIntField(env, this, fid_sss_sshd_pid, 0); + (*env)->SetStaticIntField(env, cl_simplesshdservice, fid_sss_sshd_pid, 0); } diff --git a/src/org/galexander/sshd/SimpleSSHDService.java b/src/org/galexander/sshd/SimpleSSHDService.java index bf30323..7ebac8d 100644 --- a/src/org/galexander/sshd/SimpleSSHDService.java +++ b/src/org/galexander/sshd/SimpleSSHDService.java @@ -5,7 +5,7 @@ import android.content.Intent; import android.os.IBinder; public class SimpleSSHDService extends Service { - public int sshd_pid = 0; + public static int sshd_pid = 0; public int onStartCommand(Intent intent, int flags, int startId) { if ((intent == null) || @@ -24,7 +24,7 @@ public class SimpleSSHDService extends Service { return null; } - public boolean is_started() { + public static boolean is_started() { return (sshd_pid != 0); }