|
@@ -17,6 +17,8 @@ import de.tudarmstadt.informatik.hostage.system.Device;
|
|
|
*/
|
|
|
public class SettingsFragment extends UpNavigatibleFragment {
|
|
|
private TextView mPorthackText;
|
|
|
+ private Button mPorthackInstallButton;
|
|
|
+ private Button mPorthackUninstallButton;
|
|
|
|
|
|
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
|
|
super.onCreateView(inflater, container, savedInstanceState);
|
|
@@ -24,8 +26,10 @@ public class SettingsFragment extends UpNavigatibleFragment {
|
|
|
View v = inflater.inflate(R.layout.fragment_settings, container, false);
|
|
|
|
|
|
TextView rootedText = (TextView) v.findViewById(R.id.settings_device_rooted);
|
|
|
+ TextView iptablesText = (TextView) v.findViewById(R.id.settings_iptables_available);
|
|
|
mPorthackText = (TextView) v.findViewById(R.id.settings_porthack_installed);
|
|
|
- Button porthackButton = (Button) v.findViewById(R.id.settings_deploy_porthack);
|
|
|
+ mPorthackInstallButton = (Button) v.findViewById(R.id.settings_deploy_porthack);
|
|
|
+ mPorthackUninstallButton = (Button) v.findViewById(R.id.settings_uninstall_porthack);
|
|
|
|
|
|
if (Device.isRooted()) {
|
|
|
rootedText.setText(R.string.yes);
|
|
@@ -35,29 +39,52 @@ public class SettingsFragment extends UpNavigatibleFragment {
|
|
|
rootedText.setTextColor(getResources().getColor(R.color.holo_red));
|
|
|
}
|
|
|
|
|
|
+ if (Device.isPortRedirectionAvailable()) {
|
|
|
+ iptablesText.setText(R.string.yes);
|
|
|
+ iptablesText.setTextColor(getResources().getColor(R.color.holo_dark_green));
|
|
|
+ } else {
|
|
|
+ iptablesText.setText(R.string.no);
|
|
|
+ iptablesText.setTextColor(getResources().getColor(R.color.holo_red));
|
|
|
+ }
|
|
|
+
|
|
|
updatePorthackStatus();
|
|
|
|
|
|
- porthackButton.setOnClickListener(new View.OnClickListener() {
|
|
|
+ mPorthackInstallButton.setOnClickListener(new View.OnClickListener() {
|
|
|
@Override
|
|
|
public void onClick(View v) {
|
|
|
HelperUtils.deployPorthack();
|
|
|
updatePorthackStatus();
|
|
|
}
|
|
|
});
|
|
|
- porthackButton.setEnabled(Device.isRooted()); // we're only able to deploy if the device is rooted
|
|
|
+ mPorthackUninstallButton.setOnClickListener(new View.OnClickListener() {
|
|
|
+ @Override
|
|
|
+ public void onClick(View v) {
|
|
|
+ HelperUtils.uninstallPorthack();
|
|
|
+ updatePorthackStatus();
|
|
|
+ }
|
|
|
+ });
|
|
|
|
|
|
return v;
|
|
|
}
|
|
|
|
|
|
private void updatePorthackStatus() {
|
|
|
- Device.updatePorthack(); // get current situation
|
|
|
+ Device.checkCapabilities(); // get current situation
|
|
|
|
|
|
if (Device.isPorthackInstalled()) {
|
|
|
mPorthackText.setText(R.string.yes);
|
|
|
mPorthackText.setTextColor(getResources().getColor(R.color.holo_dark_green));
|
|
|
+ mPorthackInstallButton.setEnabled(false); // we're only able to deploy if the device is rooted
|
|
|
+ mPorthackInstallButton.setVisibility(View.GONE);
|
|
|
+ mPorthackUninstallButton.setEnabled(true);
|
|
|
+ mPorthackUninstallButton.setVisibility(View.VISIBLE);
|
|
|
} else {
|
|
|
mPorthackText.setText(R.string.no);
|
|
|
mPorthackText.setTextColor(getResources().getColor(R.color.holo_red));
|
|
|
+ // we're only able to deploy if the device is rooted
|
|
|
+ mPorthackInstallButton.setEnabled(Device.isRooted());
|
|
|
+ mPorthackInstallButton.setVisibility(Device.isRooted() ? View.VISIBLE : View.GONE);
|
|
|
+ mPorthackUninstallButton.setEnabled(false);
|
|
|
+ mPorthackUninstallButton.setVisibility(View.GONE);
|
|
|
}
|
|
|
}
|
|
|
|