Test network connectivity when adding a PC fails

This commit is contained in:
Cameron Gutman
2020-08-06 20:43:17 -07:00
parent 6b30ee4593
commit 7b14e54eab
2 changed files with 21 additions and 3 deletions

View File

@@ -15,7 +15,9 @@ import com.limelight.computers.ComputerManagerService;
import com.limelight.R;
import com.limelight.nvstream.http.ComputerDetails;
import com.limelight.nvstream.http.NvHTTP;
import com.limelight.nvstream.jni.MoonBridge;
import com.limelight.utils.Dialog;
import com.limelight.utils.ServerHelper;
import com.limelight.utils.SpinnerDialog;
import com.limelight.utils.UiHelper;
@@ -97,6 +99,7 @@ public class AddComputerManually extends Activity {
private void doAddPc(String host) {
boolean wrongSiteLocal = false;
boolean success;
int portTestResult;
SpinnerDialog dialog = SpinnerDialog.displayDialog(this, getResources().getString(R.string.title_add_pc),
getResources().getString(R.string.msg_add_pc), false);
@@ -114,6 +117,14 @@ public class AddComputerManually extends Activity {
if (!success){
wrongSiteLocal = isWrongSubnetSiteLocalAddress(host);
}
if (!success && !wrongSiteLocal) {
// Run the test before dismissing the spinner because it can take a few seconds.
portTestResult = MoonBridge.testClientConnectivity(ServerHelper.CONNECTION_TEST_SERVER, 443,
MoonBridge.ML_PORT_FLAG_TCP_47984 | MoonBridge.ML_PORT_FLAG_TCP_47989);
} else {
// Don't bother with the test if we succeeded or the IP address was bogus
portTestResult = MoonBridge.ML_TEST_RESULT_INCONCLUSIVE;
}
dialog.dismiss();
@@ -121,7 +132,14 @@ public class AddComputerManually extends Activity {
Dialog.displayDialog(this, getResources().getString(R.string.conn_error_title), getResources().getString(R.string.addpc_wrong_sitelocal), false);
}
else if (!success) {
Dialog.displayDialog(this, getResources().getString(R.string.conn_error_title), getResources().getString(R.string.addpc_fail), false);
String dialogText;
if (portTestResult != MoonBridge.ML_TEST_RESULT_INCONCLUSIVE && portTestResult != 0) {
dialogText = getResources().getString(R.string.nettest_text_blocked);
}
else {
dialogText = getResources().getString(R.string.addpc_fail);
}
Dialog.displayDialog(this, getResources().getString(R.string.conn_error_title), dialogText, false);
}
else {
AddComputerManually.this.runOnUiThread(new Runnable() {