优化停止frp服务

main
Matthew 11 months ago
parent 6b2b0cbddc
commit b8a7fa3602

@ -28,7 +28,9 @@
<service
android:name=".ShellService"
android:enabled="true"
android:exported="true" />
android:exported="false"
android:foregroundServiceType="dataSync" >
</service>
<activity
android:name=".MainActivity"

@ -198,7 +198,7 @@ public class MainActivity extends AppCompatActivity {
logger.info("Server stopped");
try {
MainActivity.this.stopShell();
stopShell();
} catch (Exception ex) {
logger.warning(ex.getMessage());
}
@ -214,6 +214,7 @@ public class MainActivity extends AppCompatActivity {
protected void onDestroy() {
super.onDestroy();
//
}
private final void setListener() {

@ -13,7 +13,6 @@ import android.os.IBinder;
import android.support.annotation.Nullable;
import android.text.TextUtils;
import android.util.Log;
import android.widget.Toast;
import java.io.File;
import java.util.Random;
@ -74,7 +73,6 @@ public class ShellService extends Service {
if (this.mProcessThread != null) {
Log.w("adx", "process isn't null,service won't start");
Toast.makeText((Context)this, (CharSequence)"process isn't null,service won't start", Toast.LENGTH_SHORT).show();
return Service.START_NOT_STICKY;
} else if (intent != null) {
Bundle extras = intent.getExtras();
@ -104,13 +102,13 @@ public class ShellService extends Service {
// Log.e("adx", ExceptionsKt.stackTraceToString((Throwable)var7));
logger.warning(ex.getMessage());
ex.printStackTrace();
Toast.makeText((Context)this, (CharSequence)ex.getMessage(), Toast.LENGTH_SHORT).show();
// Toast.makeText((Context)this, (CharSequence)ex.getMessage(), Toast.LENGTH_SHORT).show();
this.stopSelf();
return Service.START_NOT_STICKY;
}
logger.warning("Service has been started");
Toast.makeText((Context)this, (CharSequence)"已启动frp服务", Toast.LENGTH_SHORT).show();
// Toast.makeText((Context)this, (CharSequence)"已启动frp服务", Toast.LENGTH_SHORT).show();
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.O) {
this.startForeground(1, this.showNotification());
}
@ -119,19 +117,23 @@ public class ShellService extends Service {
} else {
fileName = "Error:filename unknown!!!";
Log.e("adx", fileName);
Toast.makeText((Context)this, (CharSequence)fileName, Toast.LENGTH_SHORT).show();
// Toast.makeText((Context)this, (CharSequence)fileName, Toast.LENGTH_SHORT).show();
this.stopSelf();
return Service.START_NOT_STICKY;
}
}
public void onDestroy() {
try {
if (mProcessThread != null) {
mProcessThread.interrupt();
}
logger.warning("Service has been stopped");
Toast.makeText((Context)this, (CharSequence)"已关闭frp服务", Toast.LENGTH_SHORT).show();
// Toast.makeText((Context)this, (CharSequence)"已关闭frp服务", Toast.LENGTH_SHORT).show();
} catch (Exception ex) {
}
}
private final void runCommand(String command, String[] envp, File dir) {

Loading…
Cancel
Save