Fix broken app launching and resuming on GFE 2.8

This commit is contained in:
Cameron Gutman 2015-11-11 16:28:58 -08:00
parent fc1c26b5d7
commit 260d716eb8
2 changed files with 15 additions and 7 deletions

View File

@ -216,8 +216,7 @@ public class NvConnection {
private boolean launchNotRunningApp(NvHTTP h, NvApp app) private boolean launchNotRunningApp(NvHTTP h, NvApp app)
throws IOException, XmlPullParserException { throws IOException, XmlPullParserException {
// Launch the app since it's not running // Launch the app since it's not running
int gameSessionId = h.launchApp(context, app.getAppId()); if (!h.launchApp(context, app.getAppId())) {
if (gameSessionId == 0) {
context.connListener.displayMessage("Failed to launch application"); context.connListener.displayMessage("Failed to launch application");
return false; return false;
} }

View File

@ -221,7 +221,7 @@ public class NvHTTP {
} }
try { try {
details.runningGameId = Integer.parseInt(getXmlString(serverInfo, "currentgame").trim()); details.runningGameId = getCurrentGame(serverInfo);
} catch (NumberFormatException e) { } catch (NumberFormatException e) {
details.runningGameId = 0; details.runningGameId = 0;
} }
@ -336,9 +336,18 @@ public class NvHTTP {
} }
public int getCurrentGame(String serverInfo) throws IOException, XmlPullParserException { public int getCurrentGame(String serverInfo) throws IOException, XmlPullParserException {
String game = getXmlString(serverInfo, "currentgame"); // GFE 2.8 started keeping currentgame set to the last game played. As a result, it no longer
// has the semantics that its name would indicate. To contain the effects of this change as much
// as possible, we'll force the current game to zero if the server isn't in a streaming session.
String serverState = getXmlString(serverInfo, "state").trim();
if (serverState != null && !serverState.endsWith("_SERVER_AVAILABLE")) {
String game = getXmlString(serverInfo, "currentgame").trim();
return Integer.parseInt(game); return Integer.parseInt(game);
} }
else {
return 0;
}
}
public NvApp getAppById(int appId) throws IOException, XmlPullParserException { public NvApp getAppById(int appId) throws IOException, XmlPullParserException {
LinkedList<NvApp> appList = getAppList(); LinkedList<NvApp> appList = getAppList();
@ -468,7 +477,7 @@ public class NvHTTP {
return new String(hexChars); return new String(hexChars);
} }
public int launchApp(ConnectionContext context, int appId) throws IOException, XmlPullParserException { public boolean launchApp(ConnectionContext context, int appId) throws IOException, XmlPullParserException {
String xmlStr = openHttpConnectionToString(baseUrlHttps + String xmlStr = openHttpConnectionToString(baseUrlHttps +
"/launch?uniqueid=" + uniqueId + "/launch?uniqueid=" + uniqueId +
"&appid=" + appId + "&appid=" + appId +
@ -478,7 +487,7 @@ public class NvHTTP {
"&rikeyid="+context.riKeyId + "&rikeyid="+context.riKeyId +
"&localAudioPlayMode=" + (context.streamConfig.getPlayLocalAudio() ? 1 : 0), false); "&localAudioPlayMode=" + (context.streamConfig.getPlayLocalAudio() ? 1 : 0), false);
String gameSession = getXmlString(xmlStr, "gamesession"); String gameSession = getXmlString(xmlStr, "gamesession");
return Integer.parseInt(gameSession); return gameSession != null && !gameSession.equals("0");
} }
public boolean resumeApp(ConnectionContext context) throws IOException, XmlPullParserException { public boolean resumeApp(ConnectionContext context) throws IOException, XmlPullParserException {