@@ -168,21 +168,44 @@ int enableForApp(NSString* bundlePath)
168168
169169 if ([bundlePath hasPrefix: @" /Applications/" ])
170170 {
171- if ([fm fileExistsAtPath: jbroot (bundlePath)])
172- ASSERT ([fm removeItemAtPath: jbroot (bundlePath) error: nil ]);
171+ BOOL noregister = NO ;
173172
174- ASSERT ([fm copyItemAtPath: bundlePath toPath: jbroot (bundlePath) error: nil ] );
173+ NSString * newBundlePath = jbroot (bundlePath);
175174
176- ASSERT ([fm createSymbolicLinkAtPath: [jbroot (bundlePath) stringByAppendingString: @" /.jbroot" ] withDestinationPath: jbroot (@" /" ) error: nil ]);
175+ if (@available (iOS 16.0 , *))
176+ {
177+ noregister = YES ;
178+
179+ /*
180+ newBundlePath = [@"/.sysroot/" stringByAppendingString:bundlePath];
181+
182+ if(![fm fileExistsAtPath:jbroot(@"/.sysroot/Applications")]) {
183+ NSDictionary* attr = @{NSFilePosixPermissions:@(0755), NSFileOwnerAccountID:@(0), NSFileGroupOwnerAccountID:@(0)};
184+ ASSERT([fm createDirectoryAtPath:jbroot(@"/.sysroot/Applications") withIntermediateDirectories:YES attributes:attr error:nil]);
185+ }//*/
186+ }
187+
188+ if ([fm fileExistsAtPath: newBundlePath])
189+ ASSERT ([fm removeItemAtPath: newBundlePath error: nil ]);
190+
191+ ASSERT ([fm copyItemAtPath: bundlePath toPath: newBundlePath error: nil ]);
192+
193+ ASSERT ([fm createSymbolicLinkAtPath: [newBundlePath stringByAppendingString: @" /.jbroot" ] withDestinationPath: jbroot (@" /" ) error: nil ]);
177194
178195 NSString * log=nil ;
179196 NSString * err=nil ;
180- if (spawn_bootstrap_binary ((char *[]){" /usr/bin/uicache" ," -p" , bundlePath.UTF8String , NULL }, &log, &err) != 0 ) {
197+ if (spawn_bootstrap_binary ((char *[]){" /usr/bin/uicache" ," -p" , newBundlePath.fileSystemRepresentation , NULL }, &log, &err) != 0 )
198+ {
181199 STRAPLOG (" %@\n ERR:%@" , log, err);
182- AppInfo* app = [AppInfo appWithBundleIdentifier: appInfo[@" CFBundleIdentifier" ]];
183- if (app && [app.bundleURL.path hasPrefix: @" /Applications/" ]) {
184- ASSERT ([fm removeItemAtPath: bundlePath error: nil ]);
200+
201+ if (!noregister)
202+ {
203+ AppInfo* app = [AppInfo appWithBundleIdentifier: appInfo[@" CFBundleIdentifier" ]];
204+ if (app && [app.bundleURL.path hasPrefix: @" /Applications/" ]) {
205+ ASSERT ([fm removeItemAtPath: newBundlePath error: nil ]);
206+ }
185207 }
208+
186209 ABORT ();
187210 }
188211 }
@@ -194,7 +217,7 @@ int enableForApp(NSString* bundlePath)
194217
195218 NSString * log=nil ;
196219 NSString * err=nil ;
197- if (spawn_bootstrap_binary ((char *[]){" /usr/bin/uicache" ," -s" ," -p" , rootfsPrefix (bundlePath).UTF8String , NULL }, &log, &err) != 0 ) {
220+ if (spawn_bootstrap_binary ((char *[]){" /usr/bin/uicache" ," -s" ," -p" , rootfsPrefix (bundlePath).fileSystemRepresentation , NULL }, &log, &err) != 0 ) {
198221 STRAPLOG (" %@\n ERR:%@" , log, err);
199222 ABORT ();
200223 }
@@ -207,7 +230,7 @@ int enableForApp(NSString* bundlePath)
207230
208231 NSString * log=nil ;
209232 NSString * err=nil ;
210- if (spawn_bootstrap_binary ((char *[]){" /usr/bin/uicache" ," -s" ," -p" , rootfsPrefix (bundlePath).UTF8String , NULL }, &log, &err) != 0 ) {
233+ if (spawn_bootstrap_binary ((char *[]){" /usr/bin/uicache" ," -s" ," -p" , rootfsPrefix (bundlePath).fileSystemRepresentation , NULL }, &log, &err) != 0 ) {
211234 STRAPLOG (" %@\n ERR:%@" , log, err);
212235 ABORT ();
213236 }
@@ -225,19 +248,28 @@ int disableForApp(NSString* bundlePath)
225248 NSDictionary * appInfo = [NSDictionary dictionaryWithContentsOfFile: [bundlePath stringByAppendingPathComponent: @" Info.plist" ]];
226249 if (!appInfo) return -1 ;
227250
228- if (![bundlePath hasPrefix: @" /Applications/" ] && [bundlePath containsString: @" /Applications/" ])
251+ if ([bundlePath hasPrefix: @" /Applications/" ]) {
252+ NSString * resignedBundlePath = jbroot (bundlePath);
253+ if ([fm fileExistsAtPath: resignedBundlePath]) {
254+ ASSERT ([fm removeItemAtPath: resignedBundlePath error: nil ]);
255+ }
256+ NSString * resignedBundlePath2 = jbroot ([@" /.sysroot/" stringByAppendingString: bundlePath]);
257+ if ([fm fileExistsAtPath: resignedBundlePath2]) {
258+ ASSERT ([fm removeItemAtPath: resignedBundlePath2 error: nil ]);
259+ }
260+ }
261+ else if (![bundlePath hasPrefix: @" /Applications/" ] && [bundlePath containsString: @" /Applications/" ])
229262 {
230263 ASSERT ([fm removeItemAtPath: bundlePath error: nil ]);
231264
232265 NSString * sysPath = [@" /Applications/" stringByAppendingString: bundlePath.lastPathComponent];
233- ASSERT (spawn_bootstrap_binary ((char *[]){" /usr/bin/uicache" ," -p" , rootfsPrefix (sysPath).UTF8String , NULL }, nil , nil ) == 0 );
266+ ASSERT (spawn_bootstrap_binary ((char *[]){" /usr/bin/uicache" ," -p" , rootfsPrefix (sysPath).fileSystemRepresentation , NULL }, nil , nil ) == 0 );
234267 }
235268 else if ([appInfo[@" CFBundleIdentifier" ] hasPrefix: @" com.apple." ] || hasTrollstoreMarker (bundlePath.fileSystemRepresentation ))
236269 {
237-
238270 ASSERT (restoreApp (bundlePath) == 0 );
239271
240- ASSERT (spawn_bootstrap_binary ((char *[]){" /usr/bin/uicache" ," -s" ," -p" , rootfsPrefix (bundlePath).UTF8String , NULL }, nil , nil ) == 0 );
272+ ASSERT (spawn_bootstrap_binary ((char *[]){" /usr/bin/uicache" ," -s" ," -p" , rootfsPrefix (bundlePath).fileSystemRepresentation , NULL }, nil , nil ) == 0 );
241273 }
242274 else
243275 {
@@ -251,9 +283,9 @@ int disableForApp(NSString* bundlePath)
251283 if (encryptedApp && backupVersion.intValue >=1 ) return 0 ;
252284
253285 // unregister or respring to keep app's icon on home screen
254- ASSERT (spawn_bootstrap_binary ((char *[]){" /usr/bin/uicache" ," -u" , rootfsPrefix (bundlePath).UTF8String , NULL }, nil , nil ) == 0 );
286+ ASSERT (spawn_bootstrap_binary ((char *[]){" /usr/bin/uicache" ," -u" , rootfsPrefix (bundlePath).fileSystemRepresentation , NULL }, nil , nil ) == 0 );
255287 // come back
256- ASSERT (spawn_bootstrap_binary ((char *[]){" /usr/bin/uicache" ," -p" , rootfsPrefix (bundlePath).UTF8String , NULL }, nil , nil ) == 0 );
288+ ASSERT (spawn_bootstrap_binary ((char *[]){" /usr/bin/uicache" ," -p" , rootfsPrefix (bundlePath).fileSystemRepresentation , NULL }, nil , nil ) == 0 );
257289 }
258290
259291 return 0 ;
0 commit comments