From 35cd98c0a5a9e685cfb7589acc7cdecbd58b4b61 Mon Sep 17 00:00:00 2001 From: "Jay Freeman (saurik)" Date: Sat, 4 Mar 2017 22:21:01 -0800 Subject: Remove more of these global value cache variables. --- MobileCydia.mm | 28 ++++++---------------------- 1 file changed, 6 insertions(+), 22 deletions(-) diff --git a/MobileCydia.mm b/MobileCydia.mm index eed6edd..1b3ba02 100644 --- a/MobileCydia.mm +++ b/MobileCydia.mm @@ -641,9 +641,6 @@ static _H Font18_; static _H Font18Bold_; static _H Font22Bold_; -static NSString *SerialNumber_ = nil; -static NSString *ChipID_ = nil; -static NSString *BBSNum_ = nil; static _H UniqueID_; static _H CollationLocale_; @@ -711,7 +708,6 @@ _H Sources_; static _transient NSNumber *Version_; static time_t now_; -static NSString *Idiom_; static _H Firmware_; static NSString *Major_; @@ -4331,7 +4327,7 @@ class CydiaLogCleaner : } - (NSString *) idiom { - return (id) Idiom_ ?: [NSNull null]; + return IsWildcat_ ? @"ipad" : @"iphone"; } - (NSArray *) cells { @@ -4376,15 +4372,15 @@ class CydiaLogCleaner : } - (NSString *) bbsnum { - return (id) BBSNum_ ?: [NSNull null]; + return (id) CYHex((NSData *) CYIOGetValue("IOService:/AppleARMPE/baseband", @"snum"), false) ?: [NSNull null]; } - (NSString *) ecid { - return (id) ChipID_ ?: [NSNull null]; + return (id) [CYHex((NSData *) CYIOGetValue("IODeviceTree:/chosen", @"unique-chip-id"), true) uppercaseString] ?: [NSNull null]; } - (NSString *) serial { - return SerialNumber_; + return (NSString *) CYIOGetValue("IOService:/", @"IOPlatformSerialNumber"); } - (NSString *) role { @@ -9844,8 +9840,6 @@ int main(int argc, char *argv[]) { CyteInitialize(@"Cydia", Cydia_); UpdateExternalStatus(0); - Idiom_ = IsWildcat_ ? @"ipad" : @"iphone"; - RegEx pattern("([0-9]+\\.[0-9]+).*"); UIDevice *device([UIDevice currentDevice]); @@ -9859,12 +9853,7 @@ int main(int argc, char *argv[]) { BridgedHosts_ = [NSMutableSet setWithCapacity:4]; InsecureHosts_ = [NSMutableSet setWithCapacity:4]; - NSString *ui(@"ui/ios"); - if (Idiom_ != nil) - ui = [ui stringByAppendingString:[NSString stringWithFormat:@"~%@", Idiom_]]; - ui = [ui stringByAppendingString:[NSString stringWithFormat:@"/%@", Major_]]; - UI_ = CydiaURL(ui); - + UI_ = CydiaURL([NSString stringWithFormat:@"ui/ios~%@/%@", IsWildcat_ ? @"ipad" : @"iphone", Major_]); PackageName = reinterpret_cast(method_getImplementation(class_getInstanceMethod([Package class], @selector(cyname)))); /* Set Locale {{{ */ @@ -9966,6 +9955,7 @@ int main(int argc, char *argv[]) { void *gestalt(dlopen("/usr/lib/libMobileGestalt.dylib", RTLD_GLOBAL | RTLD_LAZY)); $MGCopyAnswer = reinterpret_cast(dlsym(gestalt, "MGCopyAnswer")); + UniqueID_ = UniqueIdentifier(device); /* System Information {{{ */ size_t size; @@ -9979,12 +9969,6 @@ int main(int argc, char *argv[]) { if (sysctlbyname("kern.maxproc", NULL, NULL, &maxproc, sizeof(maxproc)) == -1) perror("sysctlbyname(\"kern.maxproc\", #)"); } - - SerialNumber_ = (NSString *) CYIOGetValue("IOService:/", @"IOPlatformSerialNumber"); - ChipID_ = [CYHex((NSData *) CYIOGetValue("IODeviceTree:/chosen", @"unique-chip-id"), true) uppercaseString]; - BBSNum_ = CYHex((NSData *) CYIOGetValue("IOService:/AppleARMPE/baseband", @"snum"), false); - - UniqueID_ = UniqueIdentifier(device); /* }}} */ /* Load Database {{{ */ SectionMap_ = [[[NSDictionary alloc] initWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"Sections" ofType:@"plist"]] autorelease]; -- cgit v1.2.3