|
@@ -1,6 +1,7 @@
|
|
package de.tudarmstadt.informatik.hostage.ui2.fragment;
|
|
package de.tudarmstadt.informatik.hostage.ui2.fragment;
|
|
import android.app.AlertDialog;
|
|
import android.app.AlertDialog;
|
|
import android.app.Fragment;
|
|
import android.app.Fragment;
|
|
|
|
+import android.app.FragmentManager;
|
|
import android.content.BroadcastReceiver;
|
|
import android.content.BroadcastReceiver;
|
|
import android.content.Context;
|
|
import android.content.Context;
|
|
import android.content.DialogInterface;
|
|
import android.content.DialogInterface;
|
|
@@ -9,6 +10,7 @@ import android.content.IntentFilter;
|
|
import android.content.SharedPreferences;
|
|
import android.content.SharedPreferences;
|
|
import android.os.Bundle;
|
|
import android.os.Bundle;
|
|
import android.support.v4.content.LocalBroadcastManager;
|
|
import android.support.v4.content.LocalBroadcastManager;
|
|
|
|
+import android.util.Log;
|
|
import android.view.LayoutInflater;
|
|
import android.view.LayoutInflater;
|
|
import android.view.View;
|
|
import android.view.View;
|
|
import android.view.ViewGroup;
|
|
import android.view.ViewGroup;
|
|
@@ -39,6 +41,7 @@ public class HomeFragment extends Fragment {
|
|
private TextView mHomeTextProfile;
|
|
private TextView mHomeTextProfile;
|
|
private TextView mHomeTextProfileHeader;
|
|
private TextView mHomeTextProfileHeader;
|
|
private ImageView mHomeProfileImage;
|
|
private ImageView mHomeProfileImage;
|
|
|
|
+ private ImageView mHomeConnectionInfoButton;
|
|
|
|
|
|
private View rootView;
|
|
private View rootView;
|
|
private BroadcastReceiver mReceiver;
|
|
private BroadcastReceiver mReceiver;
|
|
@@ -61,6 +64,7 @@ public class HomeFragment extends Fragment {
|
|
mHomeTextProfile = (TextView) rootView.findViewById(R.id.home_text_profile);
|
|
mHomeTextProfile = (TextView) rootView.findViewById(R.id.home_text_profile);
|
|
mHomeTextProfileHeader = (TextView) rootView.findViewById(R.id.home_text_profile_header);
|
|
mHomeTextProfileHeader = (TextView) rootView.findViewById(R.id.home_text_profile_header);
|
|
mHomeProfileImage = (ImageView) rootView.findViewById(R.id.home_image_profile);
|
|
mHomeProfileImage = (ImageView) rootView.findViewById(R.id.home_image_profile);
|
|
|
|
+ mHomeConnectionInfoButton = (ImageView) rootView.findViewById(R.id.home_button_connection_info);
|
|
}
|
|
}
|
|
|
|
|
|
private void registerBroadcastReceiver(){
|
|
private void registerBroadcastReceiver(){
|
|
@@ -118,6 +122,8 @@ public class HomeFragment extends Fragment {
|
|
mHomeTextAttacks.setVisibility(View.INVISIBLE);
|
|
mHomeTextAttacks.setVisibility(View.INVISIBLE);
|
|
mHomeTextProfile.setVisibility(View.INVISIBLE);
|
|
mHomeTextProfile.setVisibility(View.INVISIBLE);
|
|
mHomeTextProfileHeader.setVisibility(View.INVISIBLE);
|
|
mHomeTextProfileHeader.setVisibility(View.INVISIBLE);
|
|
|
|
+ mHomeProfileImage.setVisibility(View.INVISIBLE);
|
|
|
|
+ mHomeConnectionInfoButton.setVisibility(View.INVISIBLE);
|
|
|
|
|
|
mHomeTextName.setText("Not connected");
|
|
mHomeTextName.setText("Not connected");
|
|
}
|
|
}
|
|
@@ -125,6 +131,8 @@ public class HomeFragment extends Fragment {
|
|
public void setStateConnected(){
|
|
public void setStateConnected(){
|
|
mHomeTextProfile.setVisibility(View.VISIBLE);
|
|
mHomeTextProfile.setVisibility(View.VISIBLE);
|
|
mHomeTextProfileHeader.setVisibility(View.VISIBLE);
|
|
mHomeTextProfileHeader.setVisibility(View.VISIBLE);
|
|
|
|
+ mHomeProfileImage.setVisibility(View.VISIBLE);
|
|
|
|
+ mHomeConnectionInfoButton.setVisibility(View.VISIBLE);
|
|
}
|
|
}
|
|
|
|
|
|
public void updateUI(){
|
|
public void updateUI(){
|
|
@@ -139,7 +147,6 @@ public class HomeFragment extends Fragment {
|
|
mHomeTextName.setText(mConnectionInfo.getString(getString(R.string.connection_info_ssid), ""));
|
|
mHomeTextName.setText(mConnectionInfo.getString(getString(R.string.connection_info_ssid), ""));
|
|
}
|
|
}
|
|
|
|
|
|
- int dangerLevel = 0;
|
|
|
|
boolean hasActiveListeners = false;
|
|
boolean hasActiveListeners = false;
|
|
int totalAttacks = 0;
|
|
int totalAttacks = 0;
|
|
int totalLogged = 0;
|
|
int totalLogged = 0;
|
|
@@ -149,6 +156,7 @@ public class HomeFragment extends Fragment {
|
|
if(MainActivity.getInstance().getHoneyService().isRunning(protocol)){
|
|
if(MainActivity.getInstance().getHoneyService().isRunning(protocol)){
|
|
hasActiveListeners = true;
|
|
hasActiveListeners = true;
|
|
int attacks = MainActivity.getInstance().getHoneyService().getNumberOfActiveConnections(protocol);
|
|
int attacks = MainActivity.getInstance().getHoneyService().getNumberOfActiveConnections(protocol);
|
|
|
|
+ totalAttacks += attacks;
|
|
|
|
|
|
if(attacks == 0){
|
|
if(attacks == 0){
|
|
int log_attacks = dbh.numBssidSeen(protocol, mConnectionInfo.getString(getString(R.string.connection_info_bssid), null));
|
|
int log_attacks = dbh.numBssidSeen(protocol, mConnectionInfo.getString(getString(R.string.connection_info_bssid), null));
|
|
@@ -164,7 +172,6 @@ public class HomeFragment extends Fragment {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
} else {
|
|
} else {
|
|
- totalAttacks += attacks;
|
|
|
|
THREAT_LEVEL = ThreatIndicatorGLRenderer.ThreatLevel.LIVE_THREAT;
|
|
THREAT_LEVEL = ThreatIndicatorGLRenderer.ThreatLevel.LIVE_THREAT;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
@@ -217,6 +224,8 @@ public class HomeFragment extends Fragment {
|
|
|
|
|
|
super.onCreateView(inflater, container, savedInstanceState);
|
|
super.onCreateView(inflater, container, savedInstanceState);
|
|
|
|
|
|
|
|
+ getActivity().setTitle(getResources().getString(R.string.drawer_overview));
|
|
|
|
+
|
|
dbh = new UglyDbHelper(getActivity());
|
|
dbh = new UglyDbHelper(getActivity());
|
|
|
|
|
|
mProfileManager = ProfileManager.getInstance();
|
|
mProfileManager = ProfileManager.getInstance();
|
|
@@ -225,6 +234,15 @@ public class HomeFragment extends Fragment {
|
|
rootView = inflater.inflate(R.layout.fragment_home, container, false);
|
|
rootView = inflater.inflate(R.layout.fragment_home, container, false);
|
|
assignViews();
|
|
assignViews();
|
|
|
|
|
|
|
|
+ // hook up the connection info button
|
|
|
|
+ mHomeConnectionInfoButton.setOnClickListener(new View.OnClickListener() {
|
|
|
|
+ @Override
|
|
|
|
+ public void onClick(View v) {
|
|
|
|
+ ConnectionInfoDialogFragment connectionInfoDialogFragment = new ConnectionInfoDialogFragment();
|
|
|
|
+ connectionInfoDialogFragment.show(getFragmentManager().beginTransaction(), connectionInfoDialogFragment.getTag());
|
|
|
|
+ }
|
|
|
|
+ });
|
|
|
|
+
|
|
defaultTextColor = mHomeTextName.getCurrentTextColor();
|
|
defaultTextColor = mHomeTextName.getCurrentTextColor();
|
|
|
|
|
|
setStateNotActive(true);
|
|
setStateNotActive(true);
|
|
@@ -274,6 +292,15 @@ public class HomeFragment extends Fragment {
|
|
}
|
|
}
|
|
mHomeSwitchConnection.setOnCheckedChangeListener(switchChangeListener);
|
|
mHomeSwitchConnection.setOnCheckedChangeListener(switchChangeListener);
|
|
|
|
|
|
|
|
+ rootView.findViewById(R.id.home_profile_details).setOnClickListener(
|
|
|
|
+ new View.OnClickListener() {
|
|
|
|
+ @Override
|
|
|
|
+ public void onClick(View v) {
|
|
|
|
+ Fragment fragment = new ProfileManagerFragment();
|
|
|
|
+ MainActivity.getInstance().injectFragment(fragment, false);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ );
|
|
return rootView;
|
|
return rootView;
|
|
}
|
|
}
|
|
|
|
|