From: Jay Freeman (saurik) Date: Sun, 12 Jul 2015 08:55:37 +0000 (-0700) Subject: Older iOS did not have SBSCopyIconImagePNGData*(). X-Git-Tag: v1.1.23~6 X-Git-Url: https://git.saurik.com/cydia.git/commitdiff_plain/c7e78d5fac975e43f71a6d0af5af7d902af21270 Older iOS did not have SBSCopyIconImagePNGData*(). --- diff --git a/MobileCydia.mm b/MobileCydia.mm index b039213a..67529fe8 100644 --- a/MobileCydia.mm +++ b/MobileCydia.mm @@ -248,6 +248,7 @@ static NSString *Cache_; [NSString stringWithFormat:@"%@/%s", Cache_, file] static void (*$SBSSetInterceptsMenuButtonForever)(bool); +static NSData *(*$SBSCopyIconImagePNGDataForDisplayIdentifier)(NSString *); static CFStringRef (*$MGCopyAnswer)(CFStringRef); @@ -7182,12 +7183,21 @@ static void HomeControllerReachabilityCallback(SCNetworkReachabilityRef reachabi if (path == nil) goto fail; path = [path stringByReplacingPercentEscapesUsingEncoding:NSUTF8StringEncoding]; - NSData *data([SBSCopyIconImagePNGDataForDisplayIdentifier(path) autorelease]); - UIImage *icon; - if (data == nil) - icon = [UIImage imageNamed:@"unknown.png"]; - else + + UIImage *icon(nil); + + if (icon == nil && $SBSCopyIconImagePNGDataForDisplayIdentifier != NULL) { + NSData *data([$SBSCopyIconImagePNGDataForDisplayIdentifier(path) autorelease]); icon = [UIImage imageWithData:data]; + } + + if (icon == nil) + if (NSString *file = SBSCopyIconImagePathForDisplayIdentifier(path)) + icon = [UIImage imageAtPath:file]; + + if (icon == nil) + icon = [UIImage imageNamed:@"unknown.png"]; + [self _returnPNGWithImage:icon forRequest:request]; } else if ([command isEqualToString:@"package-icon"]) { if (path == nil) @@ -10502,6 +10512,7 @@ int main(int argc, char *argv[]) { /* }}} */ $SBSSetInterceptsMenuButtonForever = reinterpret_cast(dlsym(RTLD_DEFAULT, "SBSSetInterceptsMenuButtonForever")); + $SBSCopyIconImagePNGDataForDisplayIdentifier = reinterpret_cast(dlsym(RTLD_DEFAULT, "SBSCopyIconImagePNGDataForDisplayIdentifier")); const char *symbol(kCFCoreFoundationVersionNumber >= 800 ? "MGGetBoolAnswer" : "GSSystemHasCapability"); BOOL (*GSSystemHasCapability)(CFStringRef) = reinterpret_cast(dlsym(RTLD_DEFAULT, symbol)); diff --git a/iPhonePrivate.h b/iPhonePrivate.h index 70eef381..95e9c002 100644 --- a/iPhonePrivate.h +++ b/iPhonePrivate.h @@ -440,7 +440,7 @@ extern "C" mach_port_t SBSSpringBoardServerPort(); extern "C" int SBBundlePathForDisplayIdentifier(mach_port_t port, const char *identifier, char *path); extern "C" NSSet *SBSCopyDisplayIdentifiers(); extern "C" NSString *SBSCopyLocalizedApplicationNameForDisplayIdentifier(NSString *); -extern "C" NSData *SBSCopyIconImagePNGDataForDisplayIdentifier(NSString *); +extern "C" NSString *SBSCopyIconImagePathForDisplayIdentifier(NSString *); extern "C" UIImage *_UIImageWithName(NSString *name); extern "C" void UISetColor(CGColorRef color); // }}}