From 422db1898ca704435675259c2a80e47369f31aef Mon Sep 17 00:00:00 2001 From: Cameron Gutman Date: Sun, 8 Sep 2019 18:55:59 -0700 Subject: [PATCH] Improve manually added Steam app detection heuristic to prevent FPs on apps with "Steam" in the name --- Limelight/Database/TemporaryApp.h | 1 + Limelight/Network/AppListResponse.m | 24 ++++++++++++++++++------ 2 files changed, 19 insertions(+), 6 deletions(-) diff --git a/Limelight/Database/TemporaryApp.h b/Limelight/Database/TemporaryApp.h index b1c4d2d..62d95a6 100644 --- a/Limelight/Database/TemporaryApp.h +++ b/Limelight/Database/TemporaryApp.h @@ -13,6 +13,7 @@ @property (nullable, nonatomic, retain) NSString *id; @property (nullable, nonatomic, retain) NSString *name; +@property (nullable, nonatomic, retain) NSString *installPath; @property (nonatomic) BOOL hdrSupported; @property (nullable, nonatomic, retain) TemporaryHost *host; diff --git a/Limelight/Network/AppListResponse.m b/Limelight/Network/AppListResponse.m index 0e21352..c0d9bd0 100644 --- a/Limelight/Network/AppListResponse.m +++ b/Limelight/Network/AppListResponse.m @@ -20,6 +20,7 @@ static const char* TAG_APP = "App"; static const char* TAG_APP_TITLE = "AppTitle"; static const char* TAG_APP_ID = "ID"; static const char* TAG_HDR_SUPPORTED = "IsHdrSupported"; +static const char* TAG_APP_INSTALL_PATH = "AppInstallPath"; - (void)populateWithData:(NSData *)xml { self.data = xml; @@ -68,6 +69,7 @@ static const char* TAG_HDR_SUPPORTED = "IsHdrSupported"; NSString* appName = @""; NSString* appId = nil; NSString* hdrSupported = @"0"; + NSString* appInstallPath = nil; while (appInfoNode != NULL) { if (!xmlStrcmp(appInfoNode->name, (xmlChar*)TAG_APP_TITLE)) { xmlChar* nodeVal = xmlNodeListGetString(docPtr, appInfoNode->xmlChildrenNode, 1); @@ -87,7 +89,14 @@ static const char* TAG_HDR_SUPPORTED = "IsHdrSupported"; hdrSupported = [[NSString alloc] initWithCString:(const char*)nodeVal encoding:NSUTF8StringEncoding]; xmlFree(nodeVal); } + } else if (!xmlStrcmp(appInfoNode->name, (xmlChar*)TAG_APP_INSTALL_PATH)) { + xmlChar* nodeVal = xmlNodeListGetString(docPtr, appInfoNode->xmlChildrenNode, 1); + if (nodeVal != NULL) { + appInstallPath = [[NSString alloc] initWithCString:(const char*)nodeVal encoding:NSUTF8StringEncoding]; + xmlFree(nodeVal); + } } + appInfoNode = appInfoNode->next; } if (appId != nil) { @@ -95,6 +104,7 @@ static const char* TAG_HDR_SUPPORTED = "IsHdrSupported"; app.name = appName; app.id = appId; app.hdrSupported = [hdrSupported intValue] != 0; + app.installPath = appInstallPath; [_appList addObject:app]; } } @@ -114,12 +124,14 @@ static const char* TAG_HDR_SUPPORTED = "IsHdrSupported"; TemporaryApp* officialSteamApp = nil; TemporaryApp* manuallyAddedSteamApp = nil; for (TemporaryApp* app in _appList) { - // The official Steam app is marked as HDR supported, while manually added ones are not. - if ([app.name isEqualToString:@"Steam"] && app.hdrSupported) { - officialSteamApp = app; - } - else if ([app.name containsString:@"steam"] || [app.name containsString:@"Steam"]) { - manuallyAddedSteamApp = app; + if (app.installPath != nil && [app.installPath hasSuffix:@"\\Steam\\"]) { + // The official Steam app is marked as HDR supported, while manually added ones are not. + if ([app.name isEqualToString:@"Steam"] && app.hdrSupported) { + officialSteamApp = app; + } + else { + manuallyAddedSteamApp = app; + } } }