mirror of
https://github.com/moonlight-stream/moonlight-android.git
synced 2026-04-17 22:10:09 +00:00
Propagate exceptions caused by GFE response parsing errors
This commit is contained in:
@@ -326,11 +326,7 @@ public class NvHTTP {
|
|||||||
// This has some extra logic to always report unpaired if the pinned cert isn't there
|
// This has some extra logic to always report unpaired if the pinned cert isn't there
|
||||||
details.pairState = getPairState(serverInfo);
|
details.pairState = getPairState(serverInfo);
|
||||||
|
|
||||||
try {
|
details.runningGameId = getCurrentGame(serverInfo);
|
||||||
details.runningGameId = getCurrentGame(serverInfo);
|
|
||||||
} catch (NumberFormatException e) {
|
|
||||||
details.runningGameId = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
// We could reach it so it's online
|
// We could reach it so it's online
|
||||||
details.state = ComputerDetails.State.ONLINE;
|
details.state = ComputerDetails.State.ONLINE;
|
||||||
@@ -438,11 +434,7 @@ public class NvHTTP {
|
|||||||
public long getMaxLumaPixelsH264(String serverInfo) throws XmlPullParserException, IOException {
|
public long getMaxLumaPixelsH264(String serverInfo) throws XmlPullParserException, IOException {
|
||||||
String str = getXmlString(serverInfo, "MaxLumaPixelsH264");
|
String str = getXmlString(serverInfo, "MaxLumaPixelsH264");
|
||||||
if (str != null) {
|
if (str != null) {
|
||||||
try {
|
return Long.parseLong(str);
|
||||||
return Long.parseLong(str);
|
|
||||||
} catch (NumberFormatException e) {
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@@ -451,11 +443,7 @@ public class NvHTTP {
|
|||||||
public long getMaxLumaPixelsHEVC(String serverInfo) throws XmlPullParserException, IOException {
|
public long getMaxLumaPixelsHEVC(String serverInfo) throws XmlPullParserException, IOException {
|
||||||
String str = getXmlString(serverInfo, "MaxLumaPixelsHEVC");
|
String str = getXmlString(serverInfo, "MaxLumaPixelsHEVC");
|
||||||
if (str != null) {
|
if (str != null) {
|
||||||
try {
|
return Long.parseLong(str);
|
||||||
return Long.parseLong(str);
|
|
||||||
} catch (NumberFormatException e) {
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@@ -472,11 +460,7 @@ public class NvHTTP {
|
|||||||
public long getServerCodecModeSupport(String serverInfo) throws XmlPullParserException, IOException {
|
public long getServerCodecModeSupport(String serverInfo) throws XmlPullParserException, IOException {
|
||||||
String str = getXmlString(serverInfo, "ServerCodecModeSupport");
|
String str = getXmlString(serverInfo, "ServerCodecModeSupport");
|
||||||
if (str != null) {
|
if (str != null) {
|
||||||
try {
|
return Long.parseLong(str);
|
||||||
return Long.parseLong(str);
|
|
||||||
} catch (NumberFormatException e) {
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@@ -632,36 +616,23 @@ public class NvHTTP {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public int getServerMajorVersion(String serverInfo) throws XmlPullParserException, IOException {
|
public int getServerMajorVersion(String serverInfo) throws XmlPullParserException, IOException {
|
||||||
int[] appVersionQuad = getServerAppVersionQuad(serverInfo);
|
return getServerAppVersionQuad(serverInfo)[0];
|
||||||
if (appVersionQuad != null) {
|
|
||||||
return appVersionQuad[0];
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public int[] getServerAppVersionQuad(String serverInfo) throws XmlPullParserException, IOException {
|
public int[] getServerAppVersionQuad(String serverInfo) throws XmlPullParserException, IOException {
|
||||||
try {
|
String serverVersion = getServerVersion(serverInfo);
|
||||||
String serverVersion = getServerVersion(serverInfo);
|
if (serverVersion == null) {
|
||||||
if (serverVersion == null) {
|
throw new IllegalArgumentException("Missing server version field");
|
||||||
LimeLog.warning("Missing server version field");
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
String[] serverVersionSplit = serverVersion.split("\\.");
|
|
||||||
if (serverVersionSplit.length != 4) {
|
|
||||||
LimeLog.warning("Malformed server version field");
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
int[] ret = new int[serverVersionSplit.length];
|
|
||||||
for (int i = 0; i < ret.length; i++) {
|
|
||||||
ret[i] = Integer.parseInt(serverVersionSplit[i]);
|
|
||||||
}
|
|
||||||
return ret;
|
|
||||||
} catch (NumberFormatException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
|
String[] serverVersionSplit = serverVersion.split("\\.");
|
||||||
|
if (serverVersionSplit.length != 4) {
|
||||||
|
throw new IllegalArgumentException("Malformed server version field: "+serverVersion);
|
||||||
|
}
|
||||||
|
int[] ret = new int[serverVersionSplit.length];
|
||||||
|
for (int i = 0; i < ret.length; i++) {
|
||||||
|
ret[i] = Integer.parseInt(serverVersionSplit[i]);
|
||||||
|
}
|
||||||
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
final private static char[] hexArray = "0123456789ABCDEF".toCharArray();
|
final private static char[] hexArray = "0123456789ABCDEF".toCharArray();
|
||||||
|
|||||||
@@ -55,6 +55,10 @@ public class PairingManager {
|
|||||||
|
|
||||||
private static byte[] hexToBytes(String s) {
|
private static byte[] hexToBytes(String s) {
|
||||||
int len = s.length();
|
int len = s.length();
|
||||||
|
if (len % 2 != 0) {
|
||||||
|
throw new IllegalArgumentException("Illegal string length: "+len);
|
||||||
|
}
|
||||||
|
|
||||||
byte[] data = new byte[len / 2];
|
byte[] data = new byte[len / 2];
|
||||||
for (int i = 0; i < len; i += 2) {
|
for (int i = 0; i < len; i += 2) {
|
||||||
data[i / 2] = (byte) ((Character.digit(s.charAt(i), 16) << 4)
|
data[i / 2] = (byte) ((Character.digit(s.charAt(i), 16) << 4)
|
||||||
@@ -74,7 +78,7 @@ public class PairingManager {
|
|||||||
return (X509Certificate)cf.generateCertificate(new ByteArrayInputStream(certBytes));
|
return (X509Certificate)cf.generateCertificate(new ByteArrayInputStream(certBytes));
|
||||||
} catch (CertificateException e) {
|
} catch (CertificateException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
return null;
|
throw new RuntimeException(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
|||||||
Reference in New Issue
Block a user