Plumb HTTPS port into the Game activity to avoid having to look it up again

This commit is contained in:
Cameron Gutman
2022-11-09 19:55:42 -06:00
parent fdc39f0041
commit de54b27013
4 changed files with 10 additions and 7 deletions

View File

@@ -168,6 +168,7 @@ public class Game extends Activity implements SurfaceHolder.Callback,
public static final String EXTRA_HOST = "Host"; public static final String EXTRA_HOST = "Host";
public static final String EXTRA_PORT = "Port"; public static final String EXTRA_PORT = "Port";
public static final String EXTRA_HTTPS_PORT = "HttpsPort";
public static final String EXTRA_APP_NAME = "AppName"; public static final String EXTRA_APP_NAME = "AppName";
public static final String EXTRA_APP_ID = "AppId"; public static final String EXTRA_APP_ID = "AppId";
public static final String EXTRA_UNIQUEID = "UniqueId"; public static final String EXTRA_UNIQUEID = "UniqueId";
@@ -314,6 +315,7 @@ public class Game extends Activity implements SurfaceHolder.Callback,
String host = Game.this.getIntent().getStringExtra(EXTRA_HOST); String host = Game.this.getIntent().getStringExtra(EXTRA_HOST);
int port = Game.this.getIntent().getIntExtra(EXTRA_PORT, NvHTTP.DEFAULT_HTTP_PORT); int port = Game.this.getIntent().getIntExtra(EXTRA_PORT, NvHTTP.DEFAULT_HTTP_PORT);
int httpsPort = Game.this.getIntent().getIntExtra(EXTRA_HTTPS_PORT, 0); // 0 is treated as unknown
int appId = Game.this.getIntent().getIntExtra(EXTRA_APP_ID, StreamConfiguration.INVALID_APP_ID); int appId = Game.this.getIntent().getIntExtra(EXTRA_APP_ID, StreamConfiguration.INVALID_APP_ID);
String uniqueId = Game.this.getIntent().getStringExtra(EXTRA_UNIQUEID); String uniqueId = Game.this.getIntent().getStringExtra(EXTRA_UNIQUEID);
String uuid = Game.this.getIntent().getStringExtra(EXTRA_PC_UUID); String uuid = Game.this.getIntent().getStringExtra(EXTRA_PC_UUID);
@@ -477,7 +479,7 @@ public class Game extends Activity implements SurfaceHolder.Callback,
// Initialize the connection // Initialize the connection
conn = new NvConnection(getApplicationContext(), conn = new NvConnection(getApplicationContext(),
new ComputerDetails.AddressTuple(host, port), new ComputerDetails.AddressTuple(host, port),
uniqueId, config, httpsPort, uniqueId, config,
PlatformBinding.getCryptoProvider(this), serverCert, PlatformBinding.getCryptoProvider(this), serverCert,
needsInputBatching); needsInputBatching);
controllerHandler = new ControllerHandler(this, conn, this, prefConfig); controllerHandler = new ControllerHandler(this, conn, this, prefConfig);

View File

@@ -8,6 +8,7 @@ import javax.crypto.SecretKey;
public class ConnectionContext { public class ConnectionContext {
public ComputerDetails.AddressTuple serverAddress; public ComputerDetails.AddressTuple serverAddress;
public int httpsPort;
public X509Certificate serverCert; public X509Certificate serverCert;
public StreamConfiguration streamConfig; public StreamConfiguration streamConfig;
public NvConnectionListener connListener; public NvConnectionListener connListener;

View File

@@ -43,7 +43,6 @@ import com.limelight.nvstream.jni.MoonBridge;
public class NvConnection { public class NvConnection {
// Context parameters // Context parameters
private ComputerDetails.AddressTuple host;
private LimelightCryptoProvider cryptoProvider; private LimelightCryptoProvider cryptoProvider;
private String uniqueId; private String uniqueId;
private ConnectionContext context; private ConnectionContext context;
@@ -58,21 +57,22 @@ public class NvConnection {
private short relMouseX, relMouseY, relMouseWidth, relMouseHeight; private short relMouseX, relMouseY, relMouseWidth, relMouseHeight;
private short absMouseX, absMouseY, absMouseWidth, absMouseHeight; private short absMouseX, absMouseY, absMouseWidth, absMouseHeight;
public NvConnection(Context appContext, ComputerDetails.AddressTuple host, String uniqueId, StreamConfiguration config, LimelightCryptoProvider cryptoProvider, X509Certificate serverCert, boolean batchMouseInput) public NvConnection(Context appContext, ComputerDetails.AddressTuple host, int httpsPort, String uniqueId, StreamConfiguration config, LimelightCryptoProvider cryptoProvider, X509Certificate serverCert, boolean batchMouseInput)
{ {
this.appContext = appContext; this.appContext = appContext;
this.host = host;
this.cryptoProvider = cryptoProvider; this.cryptoProvider = cryptoProvider;
this.uniqueId = uniqueId; this.uniqueId = uniqueId;
this.batchMouseInput = batchMouseInput; this.batchMouseInput = batchMouseInput;
this.context = new ConnectionContext(); this.context = new ConnectionContext();
this.context.serverAddress = host;
this.context.httpsPort = httpsPort;
this.context.streamConfig = config; this.context.streamConfig = config;
this.context.serverCert = serverCert; this.context.serverCert = serverCert;
// This is unique per connection // This is unique per connection
this.context.riKey = generateRiAesKey(); this.context.riKey = generateRiAesKey();
context.riKeyId = generateRiKeyId(); this.context.riKeyId = generateRiKeyId();
this.isMonkey = ActivityManager.isUserAMonkey(); this.isMonkey = ActivityManager.isUserAMonkey();
} }
@@ -253,7 +253,7 @@ public class NvConnection {
private boolean startApp() throws XmlPullParserException, IOException private boolean startApp() throws XmlPullParserException, IOException
{ {
NvHTTP h = new NvHTTP(context.serverAddress, 0, uniqueId, context.serverCert, cryptoProvider); NvHTTP h = new NvHTTP(context.serverAddress, context.httpsPort, uniqueId, context.serverCert, cryptoProvider);
String serverInfo = h.getServerInfo(); String serverInfo = h.getServerInfo();
@@ -415,7 +415,6 @@ public class NvConnection {
String appName = context.streamConfig.getApp().getAppName(); String appName = context.streamConfig.getApp().getAppName();
context.serverAddress = host;
context.connListener.stageStarting(appName); context.connListener.stageStarting(appName);
try { try {

View File

@@ -58,6 +58,7 @@ public class ServerHelper {
Intent intent = new Intent(parent, Game.class); Intent intent = new Intent(parent, Game.class);
intent.putExtra(Game.EXTRA_HOST, computer.activeAddress.address); intent.putExtra(Game.EXTRA_HOST, computer.activeAddress.address);
intent.putExtra(Game.EXTRA_PORT, computer.activeAddress.port); intent.putExtra(Game.EXTRA_PORT, computer.activeAddress.port);
intent.putExtra(Game.EXTRA_HTTPS_PORT, computer.httpsPort);
intent.putExtra(Game.EXTRA_APP_NAME, app.getAppName()); intent.putExtra(Game.EXTRA_APP_NAME, app.getAppName());
intent.putExtra(Game.EXTRA_APP_ID, app.getAppId()); intent.putExtra(Game.EXTRA_APP_ID, app.getAppId());
intent.putExtra(Game.EXTRA_APP_HDR, app.isHdrSupported()); intent.putExtra(Game.EXTRA_APP_HDR, app.isHdrSupported());