|
@@ -2,6 +2,7 @@ package de.tudarmstadt.informatik.hostage.ui2.activity;
|
|
|
|
|
|
import java.util.ArrayList;
|
|
import java.util.ArrayList;
|
|
import java.util.HashMap;
|
|
import java.util.HashMap;
|
|
|
|
+import java.util.List;
|
|
|
|
|
|
import android.app.ActionBar;
|
|
import android.app.ActionBar;
|
|
import android.app.Activity;
|
|
import android.app.Activity;
|
|
@@ -32,6 +33,8 @@ import android.widget.AdapterView;
|
|
import android.widget.ListView;
|
|
import android.widget.ListView;
|
|
import de.tudarmstadt.informatik.hostage.Hostage;
|
|
import de.tudarmstadt.informatik.hostage.Hostage;
|
|
import de.tudarmstadt.informatik.hostage.R;
|
|
import de.tudarmstadt.informatik.hostage.R;
|
|
|
|
+import de.tudarmstadt.informatik.hostage.model.Profile;
|
|
|
|
+import de.tudarmstadt.informatik.hostage.persistence.ProfileManager;
|
|
import de.tudarmstadt.informatik.hostage.ui.LogFilter;
|
|
import de.tudarmstadt.informatik.hostage.ui.LogFilter;
|
|
import de.tudarmstadt.informatik.hostage.ui2.adapter.DrawerListAdapter;
|
|
import de.tudarmstadt.informatik.hostage.ui2.adapter.DrawerListAdapter;
|
|
import de.tudarmstadt.informatik.hostage.ui2.fragment.AboutFragment;
|
|
import de.tudarmstadt.informatik.hostage.ui2.fragment.AboutFragment;
|
|
@@ -76,6 +79,8 @@ public class MainActivity extends Activity {
|
|
|
|
|
|
private boolean mServiceBound = false;
|
|
private boolean mServiceBound = false;
|
|
|
|
|
|
|
|
+ private ProfileManager mProfileManager;
|
|
|
|
+
|
|
/**
|
|
/**
|
|
* Connection to bind the background service
|
|
* Connection to bind the background service
|
|
*
|
|
*
|
|
@@ -146,11 +151,12 @@ public class MainActivity extends Activity {
|
|
super.onCreate(savedInstanceState);
|
|
super.onCreate(savedInstanceState);
|
|
|
|
|
|
sInstance = this;
|
|
sInstance = this;
|
|
-
|
|
|
|
MainActivity.context = getApplicationContext();
|
|
MainActivity.context = getApplicationContext();
|
|
|
|
|
|
setContentView(R.layout.activity_drawer_main);
|
|
setContentView(R.layout.activity_drawer_main);
|
|
|
|
|
|
|
|
+ mProfileManager = ProfileManager.getInstance();
|
|
|
|
+
|
|
ThreatIndicatorGLRenderer.assets = getAssets();
|
|
ThreatIndicatorGLRenderer.assets = getAssets();
|
|
ThreatIndicatorGLRenderer.setThreatLevel(ThreatIndicatorGLRenderer.ThreatLevel.NOT_MONITORING);
|
|
ThreatIndicatorGLRenderer.setThreatLevel(ThreatIndicatorGLRenderer.ThreatLevel.NOT_MONITORING);
|
|
// set background color
|
|
// set background color
|
|
@@ -402,7 +408,11 @@ public class MainActivity extends Activity {
|
|
|
|
|
|
getFragmentManager().popBackStackImmediate(HomeFragment.class.getName(), 0);
|
|
getFragmentManager().popBackStackImmediate(HomeFragment.class.getName(), 0);
|
|
// update selected item and title, then close the drawer if needed
|
|
// update selected item and title, then close the drawer if needed
|
|
- if(!(fragment instanceof HomeFragment) || isFirst) injectFragment(fragment);// , false, menuItemPosition);
|
|
|
|
|
|
+ if(!(fragment instanceof HomeFragment) || isFirst) {
|
|
|
|
+ injectFragment(fragment);// , false, menuItemPosition);
|
|
|
|
+ } else {
|
|
|
|
+ this.mDisplayedFragment = fragment;
|
|
|
|
+ }
|
|
|
|
|
|
mDrawerList.setItemChecked(position, true);
|
|
mDrawerList.setItemChecked(position, true);
|
|
mDrawerList.setSelection(position);
|
|
mDrawerList.setSelection(position);
|
|
@@ -497,16 +507,6 @@ public class MainActivity extends Activity {
|
|
return super.onKeyDown(keycode, e);
|
|
return super.onKeyDown(keycode, e);
|
|
}
|
|
}
|
|
|
|
|
|
- public static void displayBackStack(FragmentManager fm) {
|
|
|
|
- int count = fm.getBackStackEntryCount();
|
|
|
|
- Log.d("Backstack log", "There are " + count + " entries");
|
|
|
|
- for (int i = 0; i < count; i++) {
|
|
|
|
- // Display Backstack-entry data like
|
|
|
|
- String name = fm.getBackStackEntryAt(i).getName();
|
|
|
|
- Log.d("Backstack log", "entry " + i + ": " + name);
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
public Intent getServiceIntent() {
|
|
public Intent getServiceIntent() {
|
|
return new Intent(this, Hostage.class);
|
|
return new Intent(this, Hostage.class);
|
|
}
|
|
}
|
|
@@ -533,6 +533,23 @@ public class MainActivity extends Activity {
|
|
return false;
|
|
return false;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ public void startMonitorServices(List<String> protocols){
|
|
|
|
+ for(String protocol: protocols){
|
|
|
|
+ if(protocol.equals("GHOST")){
|
|
|
|
+ if(mProfileManager.getCurrentActivatedProfile() != null){
|
|
|
|
+ Profile profile = mProfileManager.getCurrentActivatedProfile();
|
|
|
|
+ if(profile.mGhostActive){
|
|
|
|
+ for(int port: profile.getGhostPorts()){
|
|
|
|
+ if(!getHostageService().isRunning(protocol, port)) getHostageService().startListener(protocol, port);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ } else {
|
|
|
|
+ if(!getHostageService().isRunning(protocol)) getHostageService().startListener(protocol);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
public enum MainMenuItem {
|
|
public enum MainMenuItem {
|
|
HOME(0, HomeFragment.class),
|
|
HOME(0, HomeFragment.class),
|
|
THREAT_MAP(1, ThreatMapFragment.class),
|
|
THREAT_MAP(1, ThreatMapFragment.class),
|