From fc547b734fa26686e9c3235adc222e24cd43dfe4 Mon Sep 17 00:00:00 2001 From: Cameron Gutman Date: Sat, 28 May 2022 15:54:21 -0500 Subject: [PATCH] Fix crashes caused by calling NvHTTP with a null address --- app/src/main/java/com/limelight/PcView.java | 6 ++---- .../main/java/com/limelight/utils/ServerHelper.java | 10 ++++++---- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/app/src/main/java/com/limelight/PcView.java b/app/src/main/java/com/limelight/PcView.java index e95a3cb1..65c292ed 100644 --- a/app/src/main/java/com/limelight/PcView.java +++ b/app/src/main/java/com/limelight/PcView.java @@ -374,8 +374,7 @@ public class PcView extends Activity implements AdapterFragmentCallbacks { } private void doPair(final ComputerDetails computer) { - if (computer.state == ComputerDetails.State.OFFLINE || - ServerHelper.getCurrentAddressFromComputer(computer) == null) { + if (computer.state == ComputerDetails.State.OFFLINE || computer.activeAddress == null) { Toast.makeText(PcView.this, getResources().getString(R.string.pair_pc_offline), Toast.LENGTH_SHORT).show(); return; } @@ -512,8 +511,7 @@ public class PcView extends Activity implements AdapterFragmentCallbacks { } private void doUnpair(final ComputerDetails computer) { - if (computer.state == ComputerDetails.State.OFFLINE || - ServerHelper.getCurrentAddressFromComputer(computer) == null) { + if (computer.state == ComputerDetails.State.OFFLINE || computer.activeAddress == null) { Toast.makeText(PcView.this, getResources().getString(R.string.error_pc_offline), Toast.LENGTH_SHORT).show(); return; } diff --git a/app/src/main/java/com/limelight/utils/ServerHelper.java b/app/src/main/java/com/limelight/utils/ServerHelper.java index 7bb3350c..980e0604 100644 --- a/app/src/main/java/com/limelight/utils/ServerHelper.java +++ b/app/src/main/java/com/limelight/utils/ServerHelper.java @@ -27,7 +27,10 @@ import java.security.cert.CertificateEncodingException; public class ServerHelper { public static final String CONNECTION_TEST_SERVER = "android.conntest.moonlight-stream.org"; - public static String getCurrentAddressFromComputer(ComputerDetails computer) { + public static String getCurrentAddressFromComputer(ComputerDetails computer) throws IOException { + if (computer.activeAddress == null) { + throw new IOException("No active address for "+computer.name); + } return computer.activeAddress; } @@ -53,7 +56,7 @@ public class ServerHelper { public static Intent createStartIntent(Activity parent, NvApp app, ComputerDetails computer, ComputerManagerService.ComputerManagerBinder managerBinder) { Intent intent = new Intent(parent, Game.class); - intent.putExtra(Game.EXTRA_HOST, getCurrentAddressFromComputer(computer)); + intent.putExtra(Game.EXTRA_HOST, computer.activeAddress); intent.putExtra(Game.EXTRA_APP_NAME, app.getAppName()); intent.putExtra(Game.EXTRA_APP_ID, app.getAppId()); intent.putExtra(Game.EXTRA_APP_HDR, app.isHdrSupported()); @@ -72,8 +75,7 @@ public class ServerHelper { public static void doStart(Activity parent, NvApp app, ComputerDetails computer, ComputerManagerService.ComputerManagerBinder managerBinder) { - if (computer.state == ComputerDetails.State.OFFLINE || - ServerHelper.getCurrentAddressFromComputer(computer) == null) { + if (computer.state == ComputerDetails.State.OFFLINE || computer.activeAddress == null) { Toast.makeText(parent, parent.getResources().getString(R.string.pair_pc_offline), Toast.LENGTH_SHORT).show(); return; }