我试图通过LSApplicationWorkspace安装应用程序后重新加载图标缓存。应用程序安装,但我必须执行" uicache"在mobileterminal中重新加载跳板缓存。有没有办法以编程方式执行此操作?顺便说一下,应用程序ISN' T以root身份运行。
目前,我有以下代码重新加载跳板图标缓存,但它不起作用:
remove("/var/mobile/Library/Caches/com.apple.mobile.installation.plist");
remove("/var/mobile/Library/Caches/com.apple.springboard-imagecache-icons");
remove("/var/mobile/Library/Caches/com.apple.springboard-imagecache-icons.plist");
remove("/var/mobile/Library/Caches/com.apple.springboard-imagecache-smallicons");
remove("/var/mobile/Library/Caches/com.apple.springboard-imagecache-smallicons.plist");
remove("/var/mobile/Library/Caches/SpringBoardIconCache");
remove("/var/mobile/Library/Caches/SpringBoardIconCache-small");
remove("/var/mobile/Library/Caches/com.apple.IconsCache");
// find ios 8 version:
NSString *cache_path = @"/var/mobile/Library/Caches/";
NSArray *conts = [[NSFileManager defaultManager] contentsOfDirectoryAtPath:cache_path error:nil];
for (NSString *filefolder in conts) {
if ([filefolder containsString:@"com.apple.LaunchServices"]) {
NSString *newpath = [cache_path stringByAppendingPathComponent:filefolder];
remove([newpath UTF8String]);
}
}
// build the args list
Class __LSApplicationWorkspace = objc_getClass("LSApplicationWorkspace");
[(LSApplicationWorkspace *)[__LSApplicationWorkspace defaultWorkspace] invalidateIconCache:nil];
[(LSApplicationWorkspace *)[__LSApplicationWorkspace defaultWorkspace] registerApplication:[NSURL fileURLWithPath:bundlePath]];
int didNotify = notify_post("com.apple.mobile.application_installed");
NSLog(@"Did Notify: %i",didNotify);
// remove temp.app:
if ([[NSFileManager defaultManager] fileExistsAtPath:bundlePath]) {
[[NSFileManager defaultManager] removeItemAtPath:bundlePath error:nil];
}
答案 0 :(得分:0)
如果有人有兴趣,我找到了我的问题的临时解决方案。我创建了一个额外的应用程序(以root身份运行),它将与原始应用程序分开安装。通过将以下内容添加到Info.plist中,我使用户对该应用程序不可见:
<key>SBAppTags</key>
<array>
<string>hidden</string>
</array>
使用URL Schemes调用“Reload”函数。
虽然另一种选择可能是创建LaunchDaemon或MobileSubstrate扩展。我找不到将缓存作为“移动”用户重新加载的方法。