Stop a daemon before starting it

in case the daemon is not cleaned up in last session.
This commit is contained in:
Hung-ying Tyan
2009-07-18 11:12:40 +08:00
parent a8d5644b54
commit 2c53de6904
2 changed files with 8 additions and 0 deletions

View File

@@ -106,6 +106,13 @@ public class AndroidServiceProxy extends ProcessProxy {
@Override
protected void performTask() throws IOException {
String svc = mServiceName;
Log.d(mTag, "----- Stop the daemon just in case: " + mServiceName);
SystemProperties.set(SVC_STOP_CMD, mServiceName);
if (!blockUntil(SVC_STATE_STOPPED, 5)) {
throw new IOException("cannot start service anew: " + svc
+ ", it is still running");
}
Log.d(mTag, "+++++ Start: " + svc);
SystemProperties.set(SVC_START_CMD, svc);

View File

@@ -57,6 +57,7 @@ public class VpnServiceBinder extends Service {
public void onStart (Intent intent, int startId) {
super.onStart(intent, startId);
setForeground(true);
android.util.Log.d("VpnServiceBinder", "becomes a foreground service");
}
public IBinder onBind(Intent intent) {