Browse Source

-Added user feedback when first time turning on applications and portbinder missing.
--Links to video tutorial
--Links to website directly
--TODO: Link Portbinder location via advanced settings.

shankar.karuppayah 10 years ago
parent
commit
49eb26459a

+ 1 - 1
res/values/api_keys.xml

@@ -1,5 +1,5 @@
 <?xml version="1.0" encoding="utf-8"?>
 <resources>
-	<string name="google_maps_api_key_debug">AIzaSyCqh4bb4aMzvDcpDfiqHyXoAWFTQ6iNxe8</string>
+	<string name="google_maps_api_key_debug">AIzaSyCiKokfd8BtGaWm8mmSZR1PslAtUm2VIEI</string>
 	<string name="google_maps_api_key_release">AIzaSyCxYbHYCoA0Mc_uZ_RwxqfJFZC1HBzzTR8</string>
 </resources>

+ 6 - 3
res/values/strings.xml

@@ -24,9 +24,12 @@
 	<string name="network_not_connected_msg">You are not connected to any network. \n\nPlease connect to one, before trying to activate HosTaGe.</string>
 	<string name="no_network_connection_threatmap_msg">Currently you are not connected to the Internet.\n\nPlease establish a connection to use the Threatmap.</string>
     <string name="profile_no_services_msg">The current active profile does not seem to monitor any services.\n\nPlease activate some services to monitor in the profile.</string>
-    <string name="no_portbinder_msg">Your device does not have \'Portbinder\' installed. Due to the limitations of Android OS, you could only use services that are utilizing ports > 1024.\n\nTo enable the full functionality of HosTaGe, please make sure your device is rooted and \'Portbinder\' is installed.</string>
-    <string name="Help">Help Me Get \'Portbinder\'!</string>
-    <string name="HelpPortbinder">Have a look at our video tutorials : https://www.youtube.com/watch?v=gi6fSiIJASk \n\nor visit http://www.tk.informatik.tu-darmstadt.de/my/research/secure-smart-infrastructures/hostage/ for more information.</string>
+    <string name="no_portbinder_msg">Your device does not have \'Portbinder\' installed. Due to the limitations of Android OS, you could only use services that are utilizing ports > 1024.\n\nTo enable full functionality of HosTaGe, please make sure your device is rooted and \'Portbinder\' is installed.</string>
+    <string name="help">How?</string>
+    <string name="portbinder">Portbinder</string>
+    <string name="portbinder_tutorial">Video Tutorial</string>
+    <string name="portbinder_website">Visit Official Website</string>
+    <string name="helpPortbinder">You can compile the \'Portbinder\' yourself from source, i.e., located in the folder \'native\', or download some precompiled binaries (with your own risk) based on the architecture of your device, e.g., ARM, from our website. \n\nPlease also check the video tutorial on how to install \'Portbinder\' in your device.</string>
 
 	<string name="profile_needs_name">An profile needs a name. Please type in a name and press save again.</string>
 

+ 8 - 3
res/values/strings_preferences.xml

@@ -32,6 +32,11 @@
 	<string name="pref_location_retries_default">3</string>
 	<string name="pref_auto_synchronize_title">Auto Synchronization</string>
 	<string name="pref_auto_synchronize_summ">Enable auto synchronization of log data</string>
-	
-	
-</resources>
+    <string name="pref_portbinder_settings">Portbinder Settings</string>
+    <string name="pref_portbinder_location">Location of Portbinder</string>
+    <string name="pref_portbinder_location_summary">Location of Portbinder binary</string>
+    <string name="pref_portbinder_location_default">/data/local/bind</string>
+
+
+</resources>
+

+ 21 - 11
res/xml/settings_preferences.xml

@@ -24,6 +24,7 @@
 				android:title="@string/pref_external_location_title"
 				/>
 	</PreferenceCategory>
+
 	<PreferenceCategory android:title="@string/pref_upload" >
 		<CheckBoxPreference
 			android:defaultValue="false"
@@ -60,19 +61,28 @@
 						android:summary="@string/pref_sleeptime_summary"
 						android:title="@string/pref_sleeptime" />
 			</PreferenceCategory>
-			<PreferenceCategory android:title="@string/pref_location_settings" >
-				<EditTextPreference
-						android:key="pref_location_time"
-						android:defaultValue="@string/pref_location_time_default"
-						android:summary="@string/pref_location_time_summary"
-						android:title="@string/pref_location_time" />
+            <PreferenceCategory android:title="@string/pref_location_settings" >
+                <EditTextPreference
+                    android:key="pref_location_time"
+                    android:defaultValue="@string/pref_location_time_default"
+                    android:summary="@string/pref_location_time_summary"
+                    android:title="@string/pref_location_time" />
 
-				<EditTextPreference
-						android:key="pref_location_retries"
-						android:defaultValue="@string/pref_location_retries_default"
-						android:title="@string/pref_location_retries" />
+                <EditTextPreference
+                    android:key="pref_location_retries"
+                    android:defaultValue="@string/pref_location_retries_default"
+                    android:title="@string/pref_location_retries" />
 
-			</PreferenceCategory>
+            </PreferenceCategory>
+            <PreferenceCategory android:title="@string/pref_portbinder_settings" >
+                <EditTextPreference
+                    android:key="pref_portbinder_location"
+                    android:defaultValue="@string/pref_portbinder_location_default"
+                    android:summary="@string/pref_portbinder_location_summary"
+                    android:title="@string/pref_portbinder_location" />
+
+
+            </PreferenceCategory>
 		</PreferenceScreen>
 	</PreferenceCategory>
 </PreferenceScreen>

+ 1 - 0
src/de/tudarmstadt/informatik/hostage/system/Device.java

@@ -20,6 +20,7 @@ public class Device {
 			public void run() {
 				try {
 					String test = "[ -e /data/local/bind ]";
+
 					Process su = new ProcessBuilder("su", "-c", test).start();
 					switch (su.waitFor()) {
 					case 0:

+ 2 - 0
src/de/tudarmstadt/informatik/hostage/system/PrivilegedPort.java

@@ -54,6 +54,8 @@ public class PrivilegedPort implements Runnable {
 	public void run() {
         /*@Shankar TODO: Update the location of PortBinder to GUI-Input*/
 		String command = String.format("/data/local/bind %s %d", type.toString(), port);
+
+
 		try {
 			Process p = new ProcessBuilder("su", "-c", command).start();
 			if (p.waitFor() != 0) {

+ 37 - 8
src/de/tudarmstadt/informatik/hostage/ui2/fragment/HomeFragment.java

@@ -392,25 +392,54 @@ public class HomeFragment extends TrackerFragment {
                             mSharedPreferences = getActivity().getSharedPreferences(getString(R.string.shared_preference_path), Hostage.MODE_PRIVATE);
 
 
-                            if(mSharedPreferences.getBoolean("isFirstEmulation", true)) {
+                            if(mSharedPreferences.getBoolean( "isFirstEmulation", true)) {
                                 //Notify Porthack is not installed to user
                                 if(!Device.isPorthackInstalled()) {
-                                    new AlertDialog.Builder(getActivity()).setTitle(R.string.information).setMessage(R.string.no_portbinder_msg)
+                                    new AlertDialog.Builder(getActivity())
+                                            .setTitle(R.string.information)
+                                            .setMessage(R.string.no_portbinder_msg)
                                             .setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() {
                                                 public void onClick(DialogInterface dialog, int which) {
 
                                                 }
                                             })
-                                            .setNeutralButton(R.string.Help, new DialogInterface.OnClickListener() {
+                                            .setNegativeButton(R.string.help, new DialogInterface.OnClickListener() {
 
                                                 public void onClick(DialogInterface dialog, int which) {
-                                                    Uri uri = Uri.parse("https://www.youtube.com/watch?v=gi6fSiIJASk");
-                                                    Intent intent = new Intent(Intent.ACTION_VIEW, uri);
-                                                    startActivity(intent);
+                                                    dialog.dismiss();
+                                                    final AlertDialog alert;
+
+                                                    new AlertDialog.Builder(getActivity())
+                                                            .setTitle(R.string.portbinder)
+                                                            .setMessage(R.string.helpPortbinder)
+                                                            .setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() {
+                                                                public void onClick(DialogInterface dialog, int which) {
+
+                                                                }
+                                                            })
+                                                            .setNeutralButton(R.string.portbinder_tutorial, new DialogInterface.OnClickListener() {
+                                                                public void onClick(DialogInterface dialog, int which) {
+
+                                                                    Uri uri = Uri.parse("https://www.youtube.com/watch?v=gi6fSiIJASk");
+                                                                    Intent intent = new Intent(Intent.ACTION_VIEW, uri);
+                                                                    startActivity(intent);
+
+                                                                }
+                                                            })
+                                                            .setNegativeButton(R.string.portbinder_website, new DialogInterface.OnClickListener() {
+                                                                public void onClick(DialogInterface dialog, int which) {
+
+                                                                    Uri uri = Uri.parse("https://www.tk.informatik.tu-darmstadt.de/de/research/secure-smart-infrastructures/hostage/");
+                                                                    Intent intent = new Intent(Intent.ACTION_VIEW, uri);
+                                                                    startActivity(intent);
+
+                                                                }
+                                                            })
+                                                            .setIcon(android.R.drawable.ic_dialog_info).show();
+
                                                 }
                                             })
-                                            .setIcon(android.R.drawable.ic_dialog_info).show()
-                                        ;
+                                            .setIcon(android.R.drawable.ic_dialog_info).show();
 
                                 }
 

+ 69 - 1
src/de/tudarmstadt/informatik/hostage/ui2/fragment/SettingsFragment.java

@@ -1,13 +1,25 @@
 package de.tudarmstadt.informatik.hostage.ui2.fragment;
 
+import android.app.AlertDialog;
+import android.app.DownloadManager;
+import android.app.Fragment;
 import android.app.FragmentManager;
+import android.content.Context;
+import android.content.DialogInterface;
+import android.content.Intent;
+import android.net.Uri;
 import android.os.Bundle;
+import android.os.Environment;
+import android.util.Log;
 import android.view.LayoutInflater;
 import android.view.View;
 import android.view.ViewGroup;
 import android.widget.TextView;
+
+import de.tudarmstadt.informatik.hostage.Hostage;
 import de.tudarmstadt.informatik.hostage.R;
 import de.tudarmstadt.informatik.hostage.system.Device;
+import de.tudarmstadt.informatik.hostage.ui2.activity.MainActivity;
 
 /**
  * Creates the view to edit the preferences of the app and shows the porthack and rooted state of the device
@@ -45,7 +57,62 @@ public class SettingsFragment extends UpNavigatibleFragment {
 			porthackText.setTextColor(getResources().getColor(R.color.holo_red));
 		}
 
-		return v;
+        //Allow no porthack text box clickable
+        if (Device.isRooted() && !Device.isPorthackInstalled())
+        {
+            porthackText.setOnClickListener(new View.OnClickListener() {
+
+                @Override
+                public void onClick(View arg0) {
+                    new AlertDialog.Builder(getActivity())
+                            .setTitle(R.string.information)
+                            .setMessage(R.string.no_portbinder_msg)
+                            .setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() {
+                                public void onClick(DialogInterface dialog, int which) {
+
+                                }
+                            })
+                            .setNegativeButton(R.string.help, new DialogInterface.OnClickListener() {
+
+                                public void onClick(DialogInterface dialog, int which) {
+                                    dialog.dismiss();
+                                    final AlertDialog alert;
+
+                                    new AlertDialog.Builder(getActivity())
+                                            .setTitle(R.string.portbinder)
+                                            .setMessage(R.string.helpPortbinder)
+                                            .setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() {
+                                                public void onClick(DialogInterface dialog, int which) {
+
+                                                }
+                                            })
+                                            .setNeutralButton(R.string.portbinder_tutorial, new DialogInterface.OnClickListener() {
+                                                public void onClick(DialogInterface dialog, int which) {
+
+                                                    Uri uri = Uri.parse("https://www.youtube.com/watch?v=gi6fSiIJASk");
+                                                    Intent intent = new Intent(Intent.ACTION_VIEW, uri);
+                                                    startActivity(intent);
+
+                                                }
+                                            })
+                                            .setNegativeButton(R.string.portbinder_website, new DialogInterface.OnClickListener() {
+                                                public void onClick(DialogInterface dialog, int which) {
+
+                                                    Uri uri = Uri.parse("https://www.tk.informatik.tu-darmstadt.de/de/research/secure-smart-infrastructures/hostage/");
+                                                    Intent intent = new Intent(Intent.ACTION_VIEW, uri);
+                                                    startActivity(intent);
+
+                                                }
+                                            })
+                                            .setIcon(android.R.drawable.ic_dialog_info).show();
+
+                                }
+                            })
+                            .setIcon(android.R.drawable.ic_dialog_info).show();}
+                });
+        }
+
+            return v;
 	}
 
 	/**
@@ -55,6 +122,7 @@ public class SettingsFragment extends UpNavigatibleFragment {
 	public void onViewCreated(View view, Bundle savedInstanceState) {
 		super.onViewCreated(view, savedInstanceState);
 
+
 		FragmentManager manager = this.getFragmentManager();
 		manager.beginTransaction().replace(R.id.settings_fragment_container, new PreferenceHostageFrament()).commit();
 	}