|
@@ -186,60 +186,55 @@ public class ServicesFragment extends TrackerFragment {
|
|
|
mProfile = ProfileManager.getInstance().getCurrentActivatedProfile();
|
|
|
//SK: Temp bugfix
|
|
|
//if (!HelperUtils.isNetworkAvailable(getActivity())) {
|
|
|
- if (!HelperUtils.isWifiConnected(getActivity())) {
|
|
|
- if(!MainActivity.getInstance().getHostageService().hasRunningListeners()) {
|
|
|
- new AlertDialog.Builder(getActivity())
|
|
|
- .setTitle(R.string.information)
|
|
|
- .setMessage(R.string.wifi_not_connected_msg)
|
|
|
- .setPositiveButton(android.R.string.ok,
|
|
|
- new DialogInterface.OnClickListener() {
|
|
|
- public void onClick(DialogInterface dialog, int which) {
|
|
|
-
|
|
|
- }
|
|
|
- }
|
|
|
- )
|
|
|
- .setIcon(android.R.drawable.ic_dialog_info)
|
|
|
- .show();
|
|
|
- if(mServicesSwitchService.isChecked()) {
|
|
|
- setStateNotActive();
|
|
|
- }
|
|
|
- setStateNotConnected();
|
|
|
- }
|
|
|
- else{
|
|
|
- setStateActive();
|
|
|
- }
|
|
|
- } else {
|
|
|
- if (MainActivity.getInstance().isServiceBound()) {
|
|
|
- if (isChecked) {
|
|
|
- for (String protocol : protocols) {
|
|
|
- if (!protocol.equals("GHOST")) {
|
|
|
- if (!MainActivity.getInstance().getHostageService().isRunning(protocol)) {
|
|
|
- MainActivity.getInstance().getHostageService().startListener(protocol);
|
|
|
- }
|
|
|
- } else {
|
|
|
- if (mProfile.mGhostActive) {
|
|
|
-
|
|
|
- mGhostPorts = mProfile.getGhostPorts();
|
|
|
- if (mGhostPorts.length != 0) {
|
|
|
- for (Integer port : mGhostPorts) {
|
|
|
- if (!MainActivity.getInstance().getHostageService().isRunning("GHOST", port)) {
|
|
|
- MainActivity.getInstance().getHostageService().startListener("GHOST", port);
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- setStateActive();
|
|
|
- } else{
|
|
|
- MainActivity.getInstance().getHostageService().stopListeners();
|
|
|
- MainActivity.getInstance().stopAndUnbind();
|
|
|
- setStateNotActive();
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
+ //replaced with if (!HelperUtils.isWifiConnected(getActivity())) {
|
|
|
+
|
|
|
+ if (isChecked) { // switch activated
|
|
|
+ // we need a network connection
|
|
|
+ if (!HelperUtils.isWifiConnected(getActivity())) {
|
|
|
+ new AlertDialog.Builder(getActivity())
|
|
|
+ .setTitle(R.string.information)
|
|
|
+ .setMessage(R.string.wifi_not_connected_msg)
|
|
|
+ .setPositiveButton(android.R.string.ok,
|
|
|
+ new DialogInterface.OnClickListener() {
|
|
|
+ public void onClick(DialogInterface dialog, int which) {
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
+ )
|
|
|
+ .setIcon(android.R.drawable.ic_dialog_info)
|
|
|
+ .show();
|
|
|
+ setStateNotActive();
|
|
|
+ setStateNotConnected();
|
|
|
+ } else { // we have a connection
|
|
|
+ // activate all protocols
|
|
|
+ for (String protocol : protocols) {
|
|
|
+ if (protocol.equals("GHOST") && mProfile.mGhostActive) {
|
|
|
+ mGhostPorts = mProfile.getGhostPorts();
|
|
|
+ if (mGhostPorts.length != 0) {
|
|
|
+ for (Integer port : mGhostPorts) {
|
|
|
+ if (MainActivity.getInstance().getHostageService() != null
|
|
|
+ && !MainActivity.getInstance().getHostageService().isRunning("GHOST", port)) {
|
|
|
+ MainActivity.getInstance().getHostageService().startListener("GHOST", port);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ if (MainActivity.getInstance().getHostageService() != null
|
|
|
+ && !MainActivity.getInstance().getHostageService().isRunning(protocol)) {
|
|
|
+ MainActivity.getInstance().getHostageService().startListener(protocol);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ setStateActive();
|
|
|
+ }
|
|
|
+ } else { // switch deactivated
|
|
|
+ if (MainActivity.getInstance().getHostageService() != null) {
|
|
|
+ // why should the hostage service not be running??
|
|
|
+ MainActivity.getInstance().getHostageService().stopListeners();
|
|
|
+ MainActivity.getInstance().stopAndUnbind();
|
|
|
+ }
|
|
|
+ setStateNotActive();
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
};
|