From 5b575f3209cc2538d8ef0fbd9051a9230c70804b Mon Sep 17 00:00:00 2001 From: Sam Bingner Date: Thu, 16 May 2019 10:30:22 -1000 Subject: Use newer respring method --- MobileCydia.mm | 64 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ entitlements.xml | 4 ++++ 2 files changed, 68 insertions(+) diff --git a/MobileCydia.mm b/MobileCydia.mm index 93c196e..3210d92 100644 --- a/MobileCydia.mm +++ b/MobileCydia.mm @@ -33,6 +33,8 @@ #include #include +#include + #include #include @@ -274,6 +276,35 @@ static _finline void UpdateExternalStatus(uint64_t newStatus) { notify_post("com.saurik.Cydia.status"); } +static _finline pid_t launch_get_job_pid(const char * job) +{ + launch_data_t resp; + launch_data_t msg; + + msg = launch_data_alloc(LAUNCH_DATA_DICTIONARY); + if (msg == NULL) { + return -1; + } + + launch_data_dict_insert(msg, launch_data_new_string(job), LAUNCH_KEY_GETJOB); + + resp = launch_msg(msg); + launch_data_free(msg); + + if (resp == NULL) { + return -1; + } + + if (launch_data_get_type(resp) != LAUNCH_DATA_DICTIONARY) return -1; + + launch_data_t pid_data = launch_data_dict_lookup(resp, "PID"); + if (launch_data_get_type(pid_data) != LAUNCH_DATA_INTEGER) return -1; + + pid_t pid = (pid_t)launch_data_get_integer(pid_data); + launch_data_free(resp); + return pid; +} + /* NSForcedOrderingSearch doesn't work on the iPhone */ static const NSStringCompareOptions MatchCompareOptions_ = NSLiteralSearch | NSCaseInsensitiveSearch; static const NSStringCompareOptions LaxCompareOptions_ = NSNumericSearch | NSDiacriticInsensitiveSearch | NSWidthInsensitiveSearch | NSCaseInsensitiveSearch; @@ -397,6 +428,22 @@ void CYArrayInsertionSortValues(Type_ *values, size_t length, CFComparisonResult @end /* }}} */ +@interface FBSSystemService ++(id)sharedService; +-(void)sendActions:(NSSet*)actions withResult:(id)result; +@end + +typedef enum { + None = 0, + RestartRenderServer = (1 << 0), // also relaunch backboardd + SnapshotTransition = (1 << 1), + FadeToBlackTransition = (1 << 2), +} SBSRelaunchActionStyle; + +@interface SBSRelaunchAction ++(id)actionWithReason:(id)reason options:(int64_t)options targetURL:(NSURL*)url; +@end + /* C++ NSString Wrapper Cache {{{ */ static _finline CFStringRef CYStringCreate(const char *data, size_t size) { return size == 0 ? NULL : @@ -8270,6 +8317,23 @@ static void HomeControllerReachabilityCallback(SCNetworkReachabilityRef reachabi } - (void) reloadSpringBoard { + if (kCFCoreFoundationVersionNumber >= 1443) { // XXX: iOS 11.x + Class $SBSRelaunchAction = objc_getClass("SBSRelaunchAction"); + Class $FBSSystemService = objc_getClass("FBSSystemService"); + pid_t sb_pid = launch_get_job_pid("com.apple.SpringBoard"); + if ($SBSRelaunchAction && $FBSSystemService) { + id action = [$SBSRelaunchAction actionWithReason:@"respring" options:RestartRenderServer targetURL:nil]; + id sharedService = [$FBSSystemService sharedService]; + [sharedService sendActions:[NSSet setWithObject:action] withResult:nil]; + for (int i=0; i<100; i++) { + if (kill(sb_pid, 0)) { + break; + } + usleep(1000); + } + if (kill(sb_pid, 0)) sleep(5); + } + } if (kCFCoreFoundationVersionNumber >= 700) // XXX: iOS 6.x system("/usr/libexec/cydia/cydo /bin/launchctl stop com.apple.backboardd"); else diff --git a/entitlements.xml b/entitlements.xml index 2beffeb..6adc334 100644 --- a/entitlements.xml +++ b/entitlements.xml @@ -16,6 +16,10 @@ com.apple.private.skip-library-validation + com.apple.frontboard.launchapplications + + com.apple.frontboard.shutdown + com.apple.springboard.launchapplications com.apple.springboard.opensensitiveurl -- cgit v1.2.3