mirror of
http://galexander.org/git/simplesshd.git
synced 2024-12-28 17:08:08 +00:00
first draft of service
This commit is contained in:
parent
8140b594b3
commit
643a5aff23
@ -11,5 +11,7 @@
|
||||
<category android:name="android.intent.category.LAUNCHER" />
|
||||
</intent-filter>
|
||||
</activity>
|
||||
<service android:name="SimpleSSHDService"
|
||||
android:label="SimpleSSHDService">
|
||||
</application>
|
||||
</manifest>
|
||||
|
31
src/org/galexander/sshd/SimpleSSHDService.java
Normal file
31
src/org/galexander/sshd/SimpleSSHDService.java
Normal file
@ -0,0 +1,31 @@
|
||||
package org.galexander.sshd;
|
||||
|
||||
import android.app.Service;
|
||||
|
||||
public class SimpleSSHDService extends Service {
|
||||
public int sshd_pid = 0;
|
||||
|
||||
public int onStartCommand(Intent intent, int flags, int startId) {
|
||||
if ((intent == null) ||
|
||||
(!intent.getBooleanExtra("stop", false)) {
|
||||
if (is_started()) {
|
||||
stop_sshd();
|
||||
}
|
||||
start_sshd();
|
||||
return START_STICKY;
|
||||
} else {
|
||||
stop_sshd();
|
||||
return START_NOT_STICKY;
|
||||
}
|
||||
}
|
||||
|
||||
public boolean is_started() {
|
||||
return (sshd_pid != 0);
|
||||
}
|
||||
|
||||
private native void start_sshd(void);
|
||||
private native void stop_sshd(void);
|
||||
static {
|
||||
System.loadLibrary("simplesshd-jni");
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user