@@ -143,6 +143,15 @@ void initFromSwiftUI()
143143 {
144144 if (checkServer ()) {
145145 [AppDelegate addLogText: Localized (@" bootstrap server check successful" )];
146+
147+ if (isAllCTBugAppsHidden ()) {
148+ UIAlertController *alert = [UIAlertController alertControllerWithTitle: Localized (@" Jailbreak Apps is Hidden" ) message: Localized (@" Do you want to restore them now?" ) preferredStyle: UIAlertControllerStyleAlert];
149+ [alert addAction: [UIAlertAction actionWithTitle: Localized (@" NO" ) style: UIAlertActionStyleCancel handler: nil ]];
150+ [alert addAction: [UIAlertAction actionWithTitle: Localized (@" YES" ) style: UIAlertActionStyleDefault handler: ^(UIAlertAction *action){
151+ unhideAllCTBugApps ();
152+ }]];
153+ [AppDelegate showAlert: alert];
154+ }
146155 }
147156
148157 [[NSNotificationCenter defaultCenter ] addObserverForName: UIApplicationWillEnterForegroundNotification object: nil queue: nil usingBlock: ^(NSNotification * _Nonnull note) {
@@ -599,3 +608,125 @@ void resetMobilePassword()
599608 }]];
600609 [AppDelegate showAlert: alert];
601610}
611+
612+ void hideAllCTBugApps ()
613+ {
614+ UIAlertController *alert = [UIAlertController alertControllerWithTitle: Localized (@" Warning" ) message: Localized (@" This operation will make all apps installed via TrollStore/Bootstrap disappear from the Home Screen. You can restore them later via TrollStore Helper->[Refresh App Registrations] and Bootstrap->Settings->[Unhide Jailbreak Apps]" ) preferredStyle: UIAlertControllerStyleAlert];
615+ [alert addAction: [UIAlertAction actionWithTitle: Localized (@" Cancel" ) style: UIAlertActionStyleDefault handler: nil ]];
616+ [alert addAction: [UIAlertAction actionWithTitle: Localized (@" Hide" ) style: UIAlertActionStyleDestructive handler: ^(UIAlertAction *action){
617+
618+ dispatch_async (dispatch_get_global_queue (0 , 0 ), ^{
619+ [AppDelegate showHudMsg: Localized (@" Hiding All Jailbreak/TrollStore Apps..." )];
620+
621+ NSArray * allInstalledApplications = [LSApplicationWorkspace.defaultWorkspace allInstalledApplications ];
622+
623+ BOOL TSHelperFound = NO ;
624+ for (LSApplicationProxy* proxy in allInstalledApplications) {
625+ NSString * TSHelperMarker = [proxy.bundleURL.path stringByAppendingPathComponent: @" .TrollStorePersistenceHelper" ];
626+ if ([NSFileManager .defaultManager fileExistsAtPath: TSHelperMarker]) {
627+ TSHelperFound = YES ;
628+ break ;
629+ }
630+ }
631+
632+ if (!TSHelperFound) {
633+ [AppDelegate dismissHud ];
634+
635+ UIAlertController *alert = [UIAlertController alertControllerWithTitle: Localized (@" Error" ) message: Localized (@" You haven't installed TrollStore Helper yet, please install it in TrollStore->Settings first." ) preferredStyle: UIAlertControllerStyleAlert];
636+ [alert addAction: [UIAlertAction actionWithTitle: Localized (@" OK" ) style: UIAlertActionStyleDefault handler: nil ]];
637+ [AppDelegate showAlert: alert];
638+
639+ return ;
640+ }
641+
642+ for (LSApplicationProxy* proxy in allInstalledApplications)
643+ {
644+ if ([NSFileManager .defaultManager fileExistsAtPath: [proxy.bundleURL.path stringByAppendingString: @" /../_TrollStore" ]])
645+ {
646+ if ([proxy.bundleIdentifier isEqualToString: NSBundle .mainBundle.bundleIdentifier]) {
647+ continue ;
648+ }
649+
650+ NSString * log=nil ;
651+ NSString * err=nil ;
652+ int status = spawnBootstrap ((char *[]){" /usr/bin/uicache" ," -u" ,rootfsPrefix (proxy.bundleURL .path ).fileSystemRepresentation ,NULL }, &log, &err);
653+ if (status != 0 ) {
654+ [AppDelegate dismissHud ];
655+
656+ NSString * msg = [NSString stringWithFormat: @" code(%d )\n %@ \n\n stderr:\n %@ " ,status,log,err];
657+ UIAlertController *alert = [UIAlertController alertControllerWithTitle: @" " message: msg preferredStyle: UIAlertControllerStyleAlert];
658+ [alert addAction: [UIAlertAction actionWithTitle: Localized (@" OK" ) style: UIAlertActionStyleDefault handler: nil ]];
659+ [AppDelegate showAlert: alert];
660+
661+ return ;
662+ }
663+ }
664+ }
665+
666+ for (NSString * bundle in [NSFileManager .defaultManager directoryContentsAtPath: jbroot (@" /Applications" )])
667+ {
668+ NSString * bundlePath = [@" /Applications" stringByAppendingPathComponent: bundle];
669+ NSDictionary * appInfo = [NSDictionary dictionaryWithContentsOfFile: [bundlePath stringByAppendingPathComponent: @" Info.plist" ]];
670+
671+ if ([appInfo[@" CFBundleIdentifier" ] hasPrefix: @" com.apple." ] && [NSFileManager .defaultManager fileExistsAtPath: bundlePath]) {
672+ continue ;
673+ }
674+
675+ NSString * log=nil ;
676+ NSString * err=nil ;
677+ int status = spawnBootstrap ((char *[]){" /usr/bin/uicache" ," -u" ,bundlePath.fileSystemRepresentation ,NULL }, &log, &err);
678+ if (status != 0 ) {
679+ [AppDelegate dismissHud ];
680+
681+ NSString * msg = [NSString stringWithFormat: @" code(%d )\n %@ \n\n stderr:\n %@ " ,status,log,err];
682+ UIAlertController *alert = [UIAlertController alertControllerWithTitle: @" " message: msg preferredStyle: UIAlertControllerStyleAlert];
683+ [alert addAction: [UIAlertAction actionWithTitle: Localized (@" OK" ) style: UIAlertActionStyleDefault handler: nil ]];
684+ [AppDelegate showAlert: alert];
685+
686+ return ;
687+ }
688+ }
689+
690+ [AppDelegate dismissHud ];
691+
692+ [[NSString stringWithFormat: @" %llX " ,jbrand ()] writeToFile: jbroot (@" /var/mobile/.allctbugappshidden" ) atomically: YES encoding: NSUTF8StringEncoding error: nil ];
693+
694+ NSString * log=nil ;
695+ NSString * err=nil ;
696+ int status = spawnBootstrap ((char *[]){" /usr/bin/uicache" ," -u" ,rootfsPrefix (NSBundle .mainBundle .bundlePath ).fileSystemRepresentation ,NULL }, &log, &err);
697+ if (status != 0 ) {
698+ NSString * msg = [NSString stringWithFormat: @" code(%d )\n %@ \n\n stderr:\n %@ " ,status,log,err];
699+ UIAlertController *alert = [UIAlertController alertControllerWithTitle: @" " message: msg preferredStyle: UIAlertControllerStyleAlert];
700+ [alert addAction: [UIAlertAction actionWithTitle: Localized (@" OK" ) style: UIAlertActionStyleDefault handler: nil ]];
701+ [AppDelegate showAlert: alert];
702+ } else {
703+ exit (0 );
704+ }
705+ });
706+
707+ }]];
708+ [AppDelegate showAlert: alert];
709+ }
710+
711+ void unhideAllCTBugApps ()
712+ {
713+ NSString * log=nil ;
714+ NSString * err=nil ;
715+ int status = spawnBootstrap ((char *[]){" /usr/bin/uicache" ," -a" ,NULL }, &log, &err);
716+ NSString * msg = (status==0 ) ? Localized (@" Done" ) : [NSString stringWithFormat: @" code(%d )\n %@ \n\n stderr:\n %@ " ,status,log,err];
717+ UIAlertController *alert = [UIAlertController alertControllerWithTitle: @" " message: msg preferredStyle: UIAlertControllerStyleAlert];
718+ [alert addAction: [UIAlertAction actionWithTitle: Localized (@" OK" ) style: UIAlertActionStyleDefault handler: nil ]];
719+ [AppDelegate showAlert: alert];
720+
721+ [NSFileManager .defaultManager removeItemAtPath: jbroot (@" /var/mobile/.allctbugappshidden" ) error: nil ];
722+ }
723+
724+ BOOL isAllCTBugAppsHidden ()
725+ {
726+ if (!isBootstrapInstalled () || !isSystemBootstrapped ()) {
727+ return NO ;
728+ }
729+
730+ NSString * flag = [NSString stringWithContentsOfFile: jbroot (@" /var/mobile/.allctbugappshidden" ) encoding: NSUTF8StringEncoding error: nil ];
731+ return flag && [flag isEqualToString: [NSString stringWithFormat: @" %llX " ,jbrand ()]];
732+ }
0 commit comments