mirror of
https://github.com/moonlight-stream/moonlight-android.git
synced 2026-10-25 13:31:55 +00:00
Use a common cleanup function and stop input capturing after closing the connection to allow captured devices to accept the "Connection Failed" dialog
This commit is contained in:
1 parent
6677949614
commit
13b80eda8a
1 file changed
+18
-11
+18
-11
@@ -286,7 +286,7 @@ public class Game extends Activity implements SurfaceHolder.Callback,
|
|||||||
Dialog.closeDialogs();
|
Dialog.closeDialogs();
|
||||||
|
|
||||||
displayedFailureDialog = true;
|
displayedFailureDialog = true;
|
||||||
conn.stop();
|
stopConnection();
|
||||||
|
|
||||||
int averageEndToEndLat = decoderRenderer.getAverageEndToEndLatency();
|
int averageEndToEndLat = decoderRenderer.getAverageEndToEndLatency();
|
||||||
int averageDecoderLat = decoderRenderer.getAverageDecoderLatency();
|
int averageDecoderLat = decoderRenderer.getAverageDecoderLatency();
|
||||||
@@ -304,10 +304,6 @@ public class Game extends Activity implements SurfaceHolder.Callback,
|
|||||||
if (message != null) {
|
if (message != null) {
|
||||||
Toast.makeText(this, message, Toast.LENGTH_LONG).show();
|
Toast.makeText(this, message, Toast.LENGTH_LONG).show();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (evdevWatcher != null) {
|
|
||||||
evdevWatcher.shutdown();
|
|
||||||
}
|
|
||||||
|
|
||||||
finish();
|
finish();
|
||||||
}
|
}
|
||||||
@@ -572,6 +568,19 @@ public class Game extends Activity implements SurfaceHolder.Callback,
|
|||||||
@Override
|
@Override
|
||||||
public void stageComplete(Stage stage) {
|
public void stageComplete(Stage stage) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void stopConnection() {
|
||||||
|
if (connecting || connected) {
|
||||||
|
conn.stop();
|
||||||
|
connecting = connected = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Close the Evdev watcher to allow use of captured input devices
|
||||||
|
if (evdevWatcher != null) {
|
||||||
|
evdevWatcher.shutdown();
|
||||||
|
evdevWatcher = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void stageFailed(Stage stage) {
|
public void stageFailed(Stage stage) {
|
||||||
@@ -583,8 +592,7 @@ public class Game extends Activity implements SurfaceHolder.Callback,
|
|||||||
if (!displayedFailureDialog) {
|
if (!displayedFailureDialog) {
|
||||||
displayedFailureDialog = true;
|
displayedFailureDialog = true;
|
||||||
Dialog.displayDialog(this, "Connection Error", "Starting "+stage.getName()+" failed", true);
|
Dialog.displayDialog(this, "Connection Error", "Starting "+stage.getName()+" failed", true);
|
||||||
conn.stop();
|
stopConnection();
|
||||||
connecting = false;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -593,9 +601,9 @@ public class Game extends Activity implements SurfaceHolder.Callback,
|
|||||||
if (!displayedFailureDialog) {
|
if (!displayedFailureDialog) {
|
||||||
displayedFailureDialog = true;
|
displayedFailureDialog = true;
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
|
|
||||||
Dialog.displayDialog(this, "Connection Terminated", "The connection failed unexpectedly", true);
|
Dialog.displayDialog(this, "Connection Terminated", "The connection failed unexpectedly", true);
|
||||||
conn.stop();
|
stopConnection();
|
||||||
connected = false;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -657,8 +665,7 @@ public class Game extends Activity implements SurfaceHolder.Callback,
|
|||||||
@Override
|
@Override
|
||||||
public void surfaceDestroyed(SurfaceHolder holder) {
|
public void surfaceDestroyed(SurfaceHolder holder) {
|
||||||
if (connected) {
|
if (connected) {
|
||||||
conn.stop();
|
stopConnection();
|
||||||
connected = false;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user