mirror of
https://github.com/moonlight-stream/moonlight-android.git
synced 2025-07-01 23:35:28 +00:00
Avoid doing client connectivity tests on the main thread
This commit is contained in:
parent
c9eddab191
commit
a413dc81c1
@ -1527,9 +1527,18 @@ public class Game extends Activity implements SurfaceHolder.Callback,
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void stageFailed(final String stage, final int portFlags, final int errorCode) {
|
public void stageFailed(final String stage, final int portFlags, final int errorCode) {
|
||||||
|
// Perform a connection test if the failure could be due to a blocked port
|
||||||
|
// This does network I/O, so don't do it on the main thread.
|
||||||
|
final int portTestResult = MoonBridge.testClientConnectivity(ServerHelper.CONNECTION_TEST_SERVER, 443, portFlags);
|
||||||
|
|
||||||
runOnUiThread(new Runnable() {
|
runOnUiThread(new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
|
if (spinner != null) {
|
||||||
|
spinner.dismiss();
|
||||||
|
spinner = null;
|
||||||
|
}
|
||||||
|
|
||||||
if (!displayedFailureDialog) {
|
if (!displayedFailureDialog) {
|
||||||
displayedFailureDialog = true;
|
displayedFailureDialog = true;
|
||||||
LimeLog.severe(stage + " failed: " + errorCode);
|
LimeLog.severe(stage + " failed: " + errorCode);
|
||||||
@ -1540,33 +1549,24 @@ public class Game extends Activity implements SurfaceHolder.Callback,
|
|||||||
}
|
}
|
||||||
|
|
||||||
String dialogText = getResources().getString(R.string.conn_error_msg) + " " + stage +" (error "+errorCode+")";
|
String dialogText = getResources().getString(R.string.conn_error_msg) + " " + stage +" (error "+errorCode+")";
|
||||||
if (portFlags != 0) {
|
if (portTestResult != MoonBridge.ML_TEST_RESULT_INCONCLUSIVE && portTestResult != 0) {
|
||||||
int ret = MoonBridge.testClientConnectivity(ServerHelper.CONNECTION_TEST_SERVER, 443, portFlags);
|
dialogText += "\n\n" + getResources().getString(R.string.nettest_text_blocked);
|
||||||
if (ret != MoonBridge.ML_TEST_RESULT_INCONCLUSIVE && ret != 0) {
|
|
||||||
dialogText += "\n\n" + getResources().getString(R.string.nettest_text_blocked);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// testClientConnectivity() can take a little while, so leave the spinner dialog up until it's done
|
|
||||||
if (spinner != null) {
|
|
||||||
spinner.dismiss();
|
|
||||||
spinner = null;
|
|
||||||
}
|
|
||||||
|
|
||||||
Dialog.displayDialog(Game.this, getResources().getString(R.string.conn_error_title), dialogText, true);
|
Dialog.displayDialog(Game.this, getResources().getString(R.string.conn_error_title), dialogText, true);
|
||||||
}
|
}
|
||||||
else {
|
|
||||||
if (spinner != null) {
|
|
||||||
spinner.dismiss();
|
|
||||||
spinner = null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void connectionTerminated(final int errorCode) {
|
public void connectionTerminated(final int errorCode) {
|
||||||
|
// Perform a connection test if the failure could be due to a blocked port
|
||||||
|
// This does network I/O, so don't do it on the main thread.
|
||||||
|
final int portTestResult = MoonBridge.testClientConnectivity(ServerHelper.CONNECTION_TEST_SERVER,
|
||||||
|
443, MoonBridge.getPortFlagsFromTerminationErrorCode(errorCode));
|
||||||
|
|
||||||
runOnUiThread(new Runnable() {
|
runOnUiThread(new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
@ -1586,16 +1586,6 @@ public class Game extends Activity implements SurfaceHolder.Callback,
|
|||||||
if (errorCode != MoonBridge.ML_ERROR_GRACEFUL_TERMINATION) {
|
if (errorCode != MoonBridge.ML_ERROR_GRACEFUL_TERMINATION) {
|
||||||
String message;
|
String message;
|
||||||
|
|
||||||
// Perform a connection test if the failure could be due to a blocked port
|
|
||||||
int portFlags = MoonBridge.getPortFlagsFromTerminationErrorCode(errorCode);
|
|
||||||
int portTestResult;
|
|
||||||
if (portFlags != 0) {
|
|
||||||
portTestResult = MoonBridge.testClientConnectivity(ServerHelper.CONNECTION_TEST_SERVER, 443, portFlags);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
portTestResult = MoonBridge.ML_TEST_RESULT_INCONCLUSIVE;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (portTestResult != MoonBridge.ML_TEST_RESULT_INCONCLUSIVE && portTestResult != 0) {
|
if (portTestResult != MoonBridge.ML_TEST_RESULT_INCONCLUSIVE && portTestResult != 0) {
|
||||||
// If we got a blocked result, that supersedes any other error message
|
// If we got a blocked result, that supersedes any other error message
|
||||||
message = getResources().getString(R.string.nettest_text_blocked);
|
message = getResources().getString(R.string.nettest_text_blocked);
|
||||||
|
@ -1 +1 @@
|
|||||||
Subproject commit 2fdcfb9429be64842d2a730801d2b5700d40d7b9
|
Subproject commit f2c1d03d8e268375de00352a1228a5669b016b61
|
Loading…
x
Reference in New Issue
Block a user