|
@@ -6,9 +6,11 @@ import android.app.ActivityManager;
|
|
|
import android.app.Fragment;
|
|
|
import android.app.FragmentManager;
|
|
|
import android.app.FragmentTransaction;
|
|
|
+import android.content.BroadcastReceiver;
|
|
|
import android.content.ComponentName;
|
|
|
import android.content.Context;
|
|
|
import android.content.Intent;
|
|
|
+import android.content.IntentFilter;
|
|
|
import android.content.ServiceConnection;
|
|
|
import android.content.pm.ActivityInfo;
|
|
|
import android.content.res.Configuration;
|
|
@@ -16,6 +18,7 @@ import android.content.res.TypedArray;
|
|
|
import android.os.Bundle;
|
|
|
import android.os.IBinder;
|
|
|
import android.support.v4.app.ActionBarDrawerToggle;
|
|
|
+import android.support.v4.content.LocalBroadcastManager;
|
|
|
import android.support.v4.widget.DrawerLayout;
|
|
|
import android.util.Log;
|
|
|
import android.view.MenuItem;
|
|
@@ -26,6 +29,7 @@ import android.widget.ListView;
|
|
|
import java.io.BufferedReader;
|
|
|
import java.io.InputStreamReader;
|
|
|
import java.util.ArrayList;
|
|
|
+import java.util.HashMap;
|
|
|
|
|
|
import de.tudarmstadt.informatik.hostage.HoneyService;
|
|
|
import de.tudarmstadt.informatik.hostage.R;
|
|
@@ -107,7 +111,9 @@ public class MainActivity extends Activity {
|
|
|
|
|
|
};
|
|
|
|
|
|
- private boolean mInvalidMenuItem;
|
|
|
+ private boolean mInvalidMenuItem = false;
|
|
|
+
|
|
|
+ private HashMap<String, Boolean> mAttacksOnProtocol;
|
|
|
|
|
|
/**
|
|
|
* Retrieve the singleton latest instance of the activity
|
|
@@ -126,11 +132,21 @@ public class MainActivity extends Activity {
|
|
|
public void onStart(){
|
|
|
super.onStart();
|
|
|
|
|
|
+ registerReceiver();
|
|
|
+
|
|
|
if(isServiceRunning()){
|
|
|
this.bindService();
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ @Override
|
|
|
+ protected void onStop() {
|
|
|
+ // Unregister Broadcast Receiver
|
|
|
+ unregisterReceiver();
|
|
|
+
|
|
|
+ super.onStop();
|
|
|
+ }
|
|
|
+
|
|
|
@Override
|
|
|
protected void onCreate(Bundle savedInstanceState) {
|
|
|
super.onCreate(savedInstanceState);
|
|
@@ -208,6 +224,22 @@ public class MainActivity extends Activity {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ private void registerReceiver() {
|
|
|
+ LocalBroadcastManager.getInstance(this).registerReceiver(mReceiver,
|
|
|
+ new IntentFilter(getString(R.string.broadcast)));
|
|
|
+ }
|
|
|
+
|
|
|
+ private void unregisterReceiver() {
|
|
|
+ LocalBroadcastManager.getInstance(this).unregisterReceiver(mReceiver);
|
|
|
+ }
|
|
|
+
|
|
|
+ private BroadcastReceiver mReceiver = new BroadcastReceiver() {
|
|
|
+ @Override
|
|
|
+ public void onReceive(Context context, Intent intent) {
|
|
|
+
|
|
|
+ }
|
|
|
+ };
|
|
|
+
|
|
|
public void startAndBind() {
|
|
|
if(!isServiceRunning()){
|
|
|
startService(getServiceIntent());
|
|
@@ -225,8 +257,13 @@ public class MainActivity extends Activity {
|
|
|
}
|
|
|
|
|
|
public void unbindService() {
|
|
|
- unbindService(mConnection);
|
|
|
- //mServiceBound = false;
|
|
|
+ try {
|
|
|
+ unbindService(mConnection);
|
|
|
+ } catch(IllegalArgumentException ex){
|
|
|
+ // somehow already unbound.
|
|
|
+ } finally {
|
|
|
+ mServiceBound = false;
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
public void bindService() {
|
|
@@ -361,7 +398,8 @@ public class MainActivity extends Activity {
|
|
|
public void injectFragment(Fragment fragment, boolean enableBack){
|
|
|
injectFragment(fragment, enableBack, null);
|
|
|
}
|
|
|
- public void injectFragment(Fragment fragment, boolean enableBack, Object tagObj){
|
|
|
+
|
|
|
+ private void injectFragment(Fragment fragment, boolean enableBack, Object tagObj){
|
|
|
if(enableBack){
|
|
|
mDrawerToggle.setDrawerIndicatorEnabled(false);
|
|
|
}
|