├── .gitignore ├── AppDelegate.swift ├── DeviceController.h ├── DeviceController.m ├── LICENSE ├── LaunchScreen.storyboard ├── Makefile ├── PlistManagerUtils.swift ├── README.md ├── RebootRootHelper ├── Makefile ├── entitlements.plist └── main.m ├── RebootTools-Bridging-Header.h ├── Resources ├── AppIcon.png ├── AppIcon29x29.png ├── AppIcon29x29@2x.png ├── AppIcon29x29@3x.png ├── AppIcon40x40.png ├── AppIcon40x40@2x.png ├── AppIcon40x40@3x.png ├── AppIcon50x50.png ├── AppIcon50x50@2x.png ├── AppIcon57x57.png ├── AppIcon57x57@2x.png ├── AppIcon60x60@2x.png ├── AppIcon60x60@3x.png ├── AppIcon72x72.png ├── AppIcon72x72@2x.png ├── AppIcon76x76.png ├── AppIcon76x76@2x.png ├── Info.plist ├── LaunchScreen.storyboardc │ ├── 01J-lp-oVM-view-Ze5-6b-2t3.nib │ ├── Info.plist │ └── UIViewController-01J-lp-oVM.nib ├── RebootRootHelper ├── en.lproj │ ├── InfoPlist.strings │ └── Localizable.strings └── zh-Hans.lproj │ ├── InfoPlist.strings │ └── Localizable.strings ├── RootViewController.swift ├── SettingsUtils.swift ├── SettingsViewController.swift ├── control └── entitlements.plist /.gitignore: -------------------------------------------------------------------------------- 1 | # Xcode 2 | # 3 | # gitignore contributors: remember to update Global/Xcode.gitignore, Objective-C.gitignore & Swift.gitignore 4 | 5 | ## User settings 6 | xcuserdata/ 7 | 8 | ## Obj-C/Swift specific 9 | *.hmap 10 | 11 | ## App packaging 12 | *.ipa 13 | *.dSYM.zip 14 | *.dSYM 15 | 16 | ## Playgrounds 17 | timeline.xctimeline 18 | playground.xcworkspace 19 | 20 | # Swift Package Manager 21 | # 22 | # Add this line if you want to avoid checking in source code from Swift Package Manager dependencies. 23 | # Packages/ 24 | # Package.pins 25 | # Package.resolved 26 | # *.xcodeproj 27 | # 28 | # Xcode automatically generates this directory with a .xcworkspacedata file and xcuserdata 29 | # hence it is not needed unless you have added a package configuration file to your project 30 | # .swiftpm 31 | 32 | .build/ 33 | 34 | # CocoaPods 35 | # 36 | # We recommend against adding the Pods directory to your .gitignore. However 37 | # you should judge for yourself, the pros and cons are mentioned at: 38 | # https://guides.cocoapods.org/using/using-cocoapods.html#should-i-check-the-pods-directory-into-source-control 39 | # 40 | # Pods/ 41 | # 42 | # Add this line if you want to avoid checking in source code from the Xcode workspace 43 | # *.xcworkspace 44 | 45 | # Carthage 46 | # 47 | # Add this line if you want to avoid checking in source code from Carthage dependencies. 48 | # Carthage/Checkouts 49 | 50 | Carthage/Build/ 51 | 52 | # fastlane 53 | # 54 | # It is recommended to not store the screenshots in the git repo. 55 | # Instead, use fastlane to re-generate the screenshots whenever they are needed. 56 | # For more information about the recommended setup visit: 57 | # https://docs.fastlane.tools/best-practices/source-control/#source-control 58 | 59 | fastlane/report.xml 60 | fastlane/Preview.html 61 | fastlane/screenshots/**/*.png 62 | fastlane/test_output 63 | 64 | .theos/ 65 | packages/ 66 | .DS_Store 67 | .gitignore 68 | .idea/ 69 | -------------------------------------------------------------------------------- /AppDelegate.swift: -------------------------------------------------------------------------------- 1 | import UIKit 2 | 3 | @UIApplicationMain 4 | class AppDelegate: UIResponder, UIApplicationDelegate { 5 | 6 | var window: UIWindow? 7 | var mainViewController: RootViewController? 8 | // 加载配置文件 9 | let settingsUtils = SettingsUtils.instance 10 | // 用于存储启动时的快捷方式 11 | var pendingQuickAction: UIApplicationShortcutItem? 12 | 13 | func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]? = nil) -> Bool { 14 | window = UIWindow(frame: UIScreen.main.bounds) 15 | mainViewController = RootViewController() 16 | guard let mainVC = mainViewController else { 17 | fatalError("Failed to initialize RootViewController") 18 | } 19 | window!.rootViewController = UINavigationController(rootViewController: mainVC) 20 | window!.makeKeyAndVisible() 21 | settingsUtils.configQuickActions(application: application) 22 | 23 | // 检查是否通过快捷方式启动 24 | if let shortcutItem = launchOptions?[.shortcutItem] as? UIApplicationShortcutItem { 25 | pendingQuickAction = shortcutItem // 保存快捷方式 26 | } 27 | 28 | 29 | return true 30 | } 31 | 32 | func applicationDidBecomeActive(_ application: UIApplication) { 33 | // 处理启动时的快捷方式 34 | if let shortcutItem = pendingQuickAction { 35 | handleQuickActionFromLaunch(shortcutItem) 36 | pendingQuickAction = nil // 清除状态 37 | } 38 | } 39 | 40 | func application( 41 | _ application: UIApplication, 42 | performActionFor shortcutItem: UIApplicationShortcutItem, 43 | completionHandler: @escaping (Bool) -> Void 44 | ) { 45 | guard let navController = window?.rootViewController as? UINavigationController else { 46 | completionHandler(false) 47 | return 48 | } 49 | 50 | // 检查是否有模态视图被显示 主要用来处理设置界面打开的时候返回桌面再按快捷方式无效的问题 51 | if let presentedVC = navController.presentedViewController { 52 | print("Modal view detected. Dismissing before executing quick action.") 53 | presentedVC.dismiss(animated: true) { [weak self] in 54 | self?.handleQuickAction(shortcutItem.type, navController: navController, completionHandler: completionHandler) 55 | } 56 | } else { 57 | // 没有模态视图,直接执行快捷方式逻辑 在主界面 直接执行快捷操作 58 | handleQuickAction(shortcutItem.type, navController: navController, completionHandler: completionHandler) 59 | } 60 | } 61 | 62 | private func handleQuickActionFromLaunch(_ shortcutItem: UIApplicationShortcutItem) { 63 | guard let navController = window?.rootViewController as? UINavigationController else { 64 | print("Failed to handle quick action: NavigationController not found.") 65 | return 66 | } 67 | 68 | handleQuickAction(shortcutItem.type, navController: navController) { success in 69 | print("Quick action from launch handled: \(success)") 70 | } 71 | } 72 | 73 | private func handleQuickAction(_ actionType: String, navController: UINavigationController, completionHandler: @escaping (Bool) -> Void) { 74 | guard let quickAction = SettingsUtils.QuickActionType(rawValue: actionType) else { 75 | completionHandler(false) 76 | return 77 | } 78 | 79 | // 优先处理 CancelTimer 快捷方式 不然就没办法从桌面快捷方式取消计时器了 80 | if quickAction == .CancelTimer { 81 | SettingsUtils.instance.setEnableAction(value: false) 82 | SettingsUtils.instance.configQuickActions(application: UIApplication.shared) 83 | } 84 | 85 | // 找到 RootViewController 并执行快捷方式 86 | if let rootVC = navController.topViewController as? RootViewController { 87 | rootVC.onClickQuickAction?(actionType) 88 | completionHandler(true) 89 | } else { 90 | completionHandler(false) 91 | } 92 | } 93 | 94 | 95 | 96 | } 97 | -------------------------------------------------------------------------------- /DeviceController.h: -------------------------------------------------------------------------------- 1 | #import 2 | 3 | @interface DeviceController : NSObject 4 | 5 | - (BOOL) RebootDevice; 6 | - (void) Respring; 7 | 8 | @end -------------------------------------------------------------------------------- /DeviceController.m: -------------------------------------------------------------------------------- 1 | #import "DeviceController.h" 2 | #include 3 | #import 4 | #import 5 | #import 6 | 7 | @implementation DeviceController 8 | 9 | #define POSIX_SPAWN_PERSONA_FLAGS_OVERRIDE 1 10 | extern int posix_spawnattr_set_persona_np(const posix_spawnattr_t* __restrict, uid_t, uint32_t); 11 | extern int posix_spawnattr_set_persona_uid_np(const posix_spawnattr_t* __restrict, uid_t); 12 | extern int posix_spawnattr_set_persona_gid_np(const posix_spawnattr_t* __restrict, uid_t); 13 | 14 | - (BOOL) RebootDevice 15 | { 16 | NSString *path = [[NSBundle mainBundle] pathForResource:@"RebootRootHelper" ofType:@""]; 17 | 18 | NSArray *args = @[]; // 不需要任何额外参数 19 | NSString *stdOut = nil; 20 | NSString *stdErr = nil; 21 | 22 | if (path == nil) { 23 | return NO; 24 | } 25 | 26 | int result = spawnRoot(path, args, &stdOut, &stdErr); 27 | if (result == 0) { 28 | return YES; 29 | } 30 | 31 | return NO; 32 | } 33 | 34 | // @See https://github.com/opa334/TrollStore/blob/main/Shared/TSUtil.m#L297 35 | - (void) Respring 36 | { 37 | killall(@"SpringBoard", YES); 38 | exit(0); 39 | } 40 | 41 | // @See https://github.com/opa334/TrollStore/blob/main/Shared/TSUtil.m#L79 42 | int spawnRoot(NSString* path, NSArray* args, NSString** stdOut, NSString** stdErr) 43 | { 44 | NSMutableArray* argsM = args.mutableCopy ?: [NSMutableArray new]; 45 | [argsM insertObject:path atIndex:0]; 46 | 47 | NSUInteger argCount = [argsM count]; 48 | char **argsC = (char **)malloc((argCount + 1) * sizeof(char*)); 49 | 50 | for (NSUInteger i = 0; i < argCount; i++) 51 | { 52 | argsC[i] = strdup([[argsM objectAtIndex:i] UTF8String]); 53 | } 54 | argsC[argCount] = NULL; 55 | 56 | posix_spawnattr_t attr; 57 | posix_spawnattr_init(&attr); 58 | 59 | posix_spawnattr_set_persona_np(&attr, 99, POSIX_SPAWN_PERSONA_FLAGS_OVERRIDE); 60 | posix_spawnattr_set_persona_uid_np(&attr, 0); 61 | posix_spawnattr_set_persona_gid_np(&attr, 0); 62 | 63 | posix_spawn_file_actions_t action; 64 | posix_spawn_file_actions_init(&action); 65 | 66 | int outErr[2]; 67 | if(stdErr) 68 | { 69 | pipe(outErr); 70 | posix_spawn_file_actions_adddup2(&action, outErr[1], STDERR_FILENO); 71 | posix_spawn_file_actions_addclose(&action, outErr[0]); 72 | } 73 | 74 | int out[2]; 75 | if(stdOut) 76 | { 77 | pipe(out); 78 | posix_spawn_file_actions_adddup2(&action, out[1], STDOUT_FILENO); 79 | posix_spawn_file_actions_addclose(&action, out[0]); 80 | } 81 | 82 | pid_t task_pid; 83 | int status = -200; 84 | int spawnError = posix_spawn(&task_pid, [path UTF8String], &action, &attr, (char* const*)argsC, NULL); 85 | posix_spawnattr_destroy(&attr); 86 | for (NSUInteger i = 0; i < argCount; i++) 87 | { 88 | free(argsC[i]); 89 | } 90 | free(argsC); 91 | 92 | if(spawnError != 0) 93 | { 94 | NSLog(@"posix_spawn error %d\n", spawnError); 95 | return spawnError; 96 | } 97 | 98 | __block volatile BOOL _isRunning = YES; 99 | NSMutableString* outString = [NSMutableString new]; 100 | NSMutableString* errString = [NSMutableString new]; 101 | dispatch_semaphore_t sema = 0; 102 | dispatch_queue_t logQueue; 103 | if(stdOut || stdErr) 104 | { 105 | logQueue = dispatch_queue_create("com.opa334.TrollStore.LogCollector", NULL); 106 | sema = dispatch_semaphore_create(0); 107 | 108 | int outPipe = out[0]; 109 | int outErrPipe = outErr[0]; 110 | 111 | __block BOOL outEnabled = (BOOL)stdOut; 112 | __block BOOL errEnabled = (BOOL)stdErr; 113 | dispatch_async(logQueue, ^ 114 | { 115 | while(_isRunning) 116 | { 117 | @autoreleasepool 118 | { 119 | if(outEnabled) 120 | { 121 | [outString appendString:getNSStringFromFile(outPipe)]; 122 | } 123 | if(errEnabled) 124 | { 125 | [errString appendString:getNSStringFromFile(outErrPipe)]; 126 | } 127 | } 128 | } 129 | dispatch_semaphore_signal(sema); 130 | }); 131 | } 132 | 133 | do 134 | { 135 | if (waitpid(task_pid, &status, 0) != -1) { 136 | NSLog(@"Child status %d", WEXITSTATUS(status)); 137 | } else 138 | { 139 | perror("waitpid"); 140 | _isRunning = NO; 141 | return -222; 142 | } 143 | } while (!WIFEXITED(status) && !WIFSIGNALED(status)); 144 | 145 | _isRunning = NO; 146 | if(stdOut || stdErr) 147 | { 148 | if(stdOut) 149 | { 150 | close(out[1]); 151 | } 152 | if(stdErr) 153 | { 154 | close(outErr[1]); 155 | } 156 | 157 | // wait for logging queue to finish 158 | dispatch_semaphore_wait(sema, DISPATCH_TIME_FOREVER); 159 | 160 | if(stdOut) 161 | { 162 | *stdOut = outString.copy; 163 | } 164 | if(stdErr) 165 | { 166 | *stdErr = errString.copy; 167 | } 168 | } 169 | 170 | return WEXITSTATUS(status); 171 | } 172 | 173 | NSString* getNSStringFromFile(int fd) 174 | { 175 | NSMutableString* ms = [NSMutableString new]; 176 | ssize_t num_read; 177 | char c; 178 | if(!fd_is_valid(fd)) return @""; 179 | while((num_read = read(fd, &c, sizeof(c)))) 180 | { 181 | [ms appendString:[NSString stringWithFormat:@"%c", c]]; 182 | if(c == '\n') break; 183 | } 184 | return ms.copy; 185 | } 186 | 187 | int fd_is_valid(int fd) 188 | { 189 | return fcntl(fd, F_GETFD) != -1 || errno != EBADF; 190 | } 191 | 192 | // @See https://github.com/opa334/TrollStore/blob/main/Shared/TSUtil.m#L279 193 | void killall(NSString* processName, BOOL softly) 194 | { 195 | enumerateProcessesUsingBlock(^(pid_t pid, NSString* executablePath, BOOL* stop) 196 | { 197 | if([executablePath.lastPathComponent isEqualToString:processName]) 198 | { 199 | if(softly) 200 | { 201 | kill(pid, SIGTERM); 202 | } 203 | else 204 | { 205 | kill(pid, SIGKILL); 206 | } 207 | } 208 | }); 209 | } 210 | 211 | void enumerateProcessesUsingBlock(void (^enumerator)(pid_t pid, NSString* executablePath, BOOL* stop)) 212 | { 213 | static int maxArgumentSize = 0; 214 | if (maxArgumentSize == 0) { 215 | size_t size = sizeof(maxArgumentSize); 216 | if (sysctl((int[]){ CTL_KERN, KERN_ARGMAX }, 2, &maxArgumentSize, &size, NULL, 0) == -1) { 217 | perror("sysctl argument size"); 218 | maxArgumentSize = 4096; // Default 219 | } 220 | } 221 | int mib[3] = { CTL_KERN, KERN_PROC, KERN_PROC_ALL}; 222 | struct kinfo_proc *info; 223 | size_t length; 224 | int count; 225 | 226 | if (sysctl(mib, 3, NULL, &length, NULL, 0) < 0) 227 | return; 228 | if (!(info = malloc(length))) 229 | return; 230 | if (sysctl(mib, 3, info, &length, NULL, 0) < 0) { 231 | free(info); 232 | return; 233 | } 234 | count = length / sizeof(struct kinfo_proc); 235 | for (int i = 0; i < count; i++) { 236 | @autoreleasepool { 237 | pid_t pid = info[i].kp_proc.p_pid; 238 | if (pid == 0) { 239 | continue; 240 | } 241 | size_t size = maxArgumentSize; 242 | char* buffer = (char *)malloc(length); 243 | if (sysctl((int[]){ CTL_KERN, KERN_PROCARGS2, pid }, 3, buffer, &size, NULL, 0) == 0) { 244 | NSString* executablePath = [NSString stringWithCString:(buffer+sizeof(int)) encoding:NSUTF8StringEncoding]; 245 | 246 | BOOL stop = NO; 247 | enumerator(pid, executablePath, &stop); 248 | if(stop) 249 | { 250 | free(buffer); 251 | break; 252 | } 253 | } 254 | free(buffer); 255 | } 256 | } 257 | free(info); 258 | } 259 | 260 | @end -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Apache License 2 | Version 2.0, January 2004 3 | http://www.apache.org/licenses/ 4 | 5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 6 | 7 | 1. Definitions. 8 | 9 | "License" shall mean the terms and conditions for use, reproduction, 10 | and distribution as defined by Sections 1 through 9 of this document. 11 | 12 | "Licensor" shall mean the copyright owner or entity authorized by 13 | the copyright owner that is granting the License. 14 | 15 | "Legal Entity" shall mean the union of the acting entity and all 16 | other entities that control, are controlled by, or are under common 17 | control with that entity. For the purposes of this definition, 18 | "control" means (i) the power, direct or indirect, to cause the 19 | direction or management of such entity, whether by contract or 20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 21 | outstanding shares, or (iii) beneficial ownership of such entity. 22 | 23 | "You" (or "Your") shall mean an individual or Legal Entity 24 | exercising permissions granted by this License. 25 | 26 | "Source" form shall mean the preferred form for making modifications, 27 | including but not limited to software source code, documentation 28 | source, and configuration files. 29 | 30 | "Object" form shall mean any form resulting from mechanical 31 | transformation or translation of a Source form, including but 32 | not limited to compiled object code, generated documentation, 33 | and conversions to other media types. 34 | 35 | "Work" shall mean the work of authorship, whether in Source or 36 | Object form, made available under the License, as indicated by a 37 | copyright notice that is included in or attached to the work 38 | (an example is provided in the Appendix below). 39 | 40 | "Derivative Works" shall mean any work, whether in Source or Object 41 | form, that is based on (or derived from) the Work and for which the 42 | editorial revisions, annotations, elaborations, or other modifications 43 | represent, as a whole, an original work of authorship. For the purposes 44 | of this License, Derivative Works shall not include works that remain 45 | separable from, or merely link (or bind by name) to the interfaces of, 46 | the Work and Derivative Works thereof. 47 | 48 | "Contribution" shall mean any work of authorship, including 49 | the original version of the Work and any modifications or additions 50 | to that Work or Derivative Works thereof, that is intentionally 51 | submitted to Licensor for inclusion in the Work by the copyright owner 52 | or by an individual or Legal Entity authorized to submit on behalf of 53 | the copyright owner. For the purposes of this definition, "submitted" 54 | means any form of electronic, verbal, or written communication sent 55 | to the Licensor or its representatives, including but not limited to 56 | communication on electronic mailing lists, source code control systems, 57 | and issue tracking systems that are managed by, or on behalf of, the 58 | Licensor for the purpose of discussing and improving the Work, but 59 | excluding communication that is conspicuously marked or otherwise 60 | designated in writing by the copyright owner as "Not a Contribution." 61 | 62 | "Contributor" shall mean Licensor and any individual or Legal Entity 63 | on behalf of whom a Contribution has been received by Licensor and 64 | subsequently incorporated within the Work. 65 | 66 | 2. Grant of Copyright License. Subject to the terms and conditions of 67 | this License, each Contributor hereby grants to You a perpetual, 68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 69 | copyright license to reproduce, prepare Derivative Works of, 70 | publicly display, publicly perform, sublicense, and distribute the 71 | Work and such Derivative Works in Source or Object form. 72 | 73 | 3. Grant of Patent License. Subject to the terms and conditions of 74 | this License, each Contributor hereby grants to You a perpetual, 75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 76 | (except as stated in this section) patent license to make, have made, 77 | use, offer to sell, sell, import, and otherwise transfer the Work, 78 | where such license applies only to those patent claims licensable 79 | by such Contributor that are necessarily infringed by their 80 | Contribution(s) alone or by combination of their Contribution(s) 81 | with the Work to which such Contribution(s) was submitted. If You 82 | institute patent litigation against any entity (including a 83 | cross-claim or counterclaim in a lawsuit) alleging that the Work 84 | or a Contribution incorporated within the Work constitutes direct 85 | or contributory patent infringement, then any patent licenses 86 | granted to You under this License for that Work shall terminate 87 | as of the date such litigation is filed. 88 | 89 | 4. Redistribution. You may reproduce and distribute copies of the 90 | Work or Derivative Works thereof in any medium, with or without 91 | modifications, and in Source or Object form, provided that You 92 | meet the following conditions: 93 | 94 | (a) You must give any other recipients of the Work or 95 | Derivative Works a copy of this License; and 96 | 97 | (b) You must cause any modified files to carry prominent notices 98 | stating that You changed the files; and 99 | 100 | (c) You must retain, in the Source form of any Derivative Works 101 | that You distribute, all copyright, patent, trademark, and 102 | attribution notices from the Source form of the Work, 103 | excluding those notices that do not pertain to any part of 104 | the Derivative Works; and 105 | 106 | (d) If the Work includes a "NOTICE" text file as part of its 107 | distribution, then any Derivative Works that You distribute must 108 | include a readable copy of the attribution notices contained 109 | within such NOTICE file, excluding those notices that do not 110 | pertain to any part of the Derivative Works, in at least one 111 | of the following places: within a NOTICE text file distributed 112 | as part of the Derivative Works; within the Source form or 113 | documentation, if provided along with the Derivative Works; or, 114 | within a display generated by the Derivative Works, if and 115 | wherever such third-party notices normally appear. The contents 116 | of the NOTICE file are for informational purposes only and 117 | do not modify the License. You may add Your own attribution 118 | notices within Derivative Works that You distribute, alongside 119 | or as an addendum to the NOTICE text from the Work, provided 120 | that such additional attribution notices cannot be construed 121 | as modifying the License. 122 | 123 | You may add Your own copyright statement to Your modifications and 124 | may provide additional or different license terms and conditions 125 | for use, reproduction, or distribution of Your modifications, or 126 | for any such Derivative Works as a whole, provided Your use, 127 | reproduction, and distribution of the Work otherwise complies with 128 | the conditions stated in this License. 129 | 130 | 5. Submission of Contributions. Unless You explicitly state otherwise, 131 | any Contribution intentionally submitted for inclusion in the Work 132 | by You to the Licensor shall be under the terms and conditions of 133 | this License, without any additional terms or conditions. 134 | Notwithstanding the above, nothing herein shall supersede or modify 135 | the terms of any separate license agreement you may have executed 136 | with Licensor regarding such Contributions. 137 | 138 | 6. Trademarks. This License does not grant permission to use the trade 139 | names, trademarks, service marks, or product names of the Licensor, 140 | except as required for reasonable and customary use in describing the 141 | origin of the Work and reproducing the content of the NOTICE file. 142 | 143 | 7. Disclaimer of Warranty. Unless required by applicable law or 144 | agreed to in writing, Licensor provides the Work (and each 145 | Contributor provides its Contributions) on an "AS IS" BASIS, 146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 147 | implied, including, without limitation, any warranties or conditions 148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 149 | PARTICULAR PURPOSE. You are solely responsible for determining the 150 | appropriateness of using or redistributing the Work and assume any 151 | risks associated with Your exercise of permissions under this License. 152 | 153 | 8. Limitation of Liability. In no event and under no legal theory, 154 | whether in tort (including negligence), contract, or otherwise, 155 | unless required by applicable law (such as deliberate and grossly 156 | negligent acts) or agreed to in writing, shall any Contributor be 157 | liable to You for damages, including any direct, indirect, special, 158 | incidental, or consequential damages of any character arising as a 159 | result of this License or out of the use or inability to use the 160 | Work (including but not limited to damages for loss of goodwill, 161 | work stoppage, computer failure or malfunction, or any and all 162 | other commercial damages or losses), even if such Contributor 163 | has been advised of the possibility of such damages. 164 | 165 | 9. Accepting Warranty or Additional Liability. While redistributing 166 | the Work or Derivative Works thereof, You may choose to offer, 167 | and charge a fee for, acceptance of support, warranty, indemnity, 168 | or other liability obligations and/or rights consistent with this 169 | License. However, in accepting such obligations, You may act only 170 | on Your own behalf and on Your sole responsibility, not on behalf 171 | of any other Contributor, and only if You agree to indemnify, 172 | defend, and hold each Contributor harmless for any liability 173 | incurred by, or claims asserted against, such Contributor by reason 174 | of your accepting any such warranty or additional liability. 175 | 176 | END OF TERMS AND CONDITIONS 177 | 178 | APPENDIX: How to apply the Apache License to your work. 179 | 180 | To apply the Apache License to your work, attach the following 181 | boilerplate notice, with the fields enclosed by brackets "[]" 182 | replaced with your own identifying information. (Don't include 183 | the brackets!) The text should be enclosed in the appropriate 184 | comment syntax for the file format. We also recommend that a 185 | file or class name and description of purpose be included on the 186 | same "printed page" as the copyright notice for easier 187 | identification within third-party archives. 188 | 189 | Copyright [yyyy] [name of copyright owner] 190 | 191 | Licensed under the Apache License, Version 2.0 (the "License"); 192 | you may not use this file except in compliance with the License. 193 | You may obtain a copy of the License at 194 | 195 | http://www.apache.org/licenses/LICENSE-2.0 196 | 197 | Unless required by applicable law or agreed to in writing, software 198 | distributed under the License is distributed on an "AS IS" BASIS, 199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 200 | See the License for the specific language governing permissions and 201 | limitations under the License. 202 | -------------------------------------------------------------------------------- /LaunchScreen.storyboard: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | TARGET = iOS 2 | ARCHS := arm64 3 | TARGET = iphone:clang:latest:14.0 4 | 5 | # TARGET = simulator:clang:latest:14.0 6 | # ARCHS = x86_64 arm64 7 | 8 | INSTALL_TARGET_PROCESSES = RebootTools 9 | 10 | include $(THEOS)/makefiles/common.mk 11 | 12 | APPLICATION_NAME = RebootTools 13 | 14 | RebootTools_FILES = AppDelegate.swift RootViewController.swift SettingsViewController.swift DeviceController.m PlistManagerUtils.swift SettingsUtils.swift 15 | RebootTools_FRAMEWORKS = UIKit CoreGraphics 16 | RebootTools_RESOURCES = Resources/LaunchScreen.storyboardc 17 | $(APPLICATION_NAME)_SWIFT_BRIDGING_HEADER += $(APPLICATION_NAME)-Bridging-Header.h 18 | include $(THEOS_MAKE_PATH)/application.mk 19 | 20 | $(APPLICATION_NAME)_CODESIGN_FLAGS = -Sentitlements.plist 21 | 22 | # SUBPROJECTS += RebootRootHelper 23 | include $(THEOS_MAKE_PATH)/aggregate.mk 24 | 25 | after-package:: 26 | @echo "Renaming .ipa to .tipa..." 27 | @mv ./packages/com.developlab.RebootTools_1.2.ipa ./packages/com.developlab.RebootTools_1.2.tipa || echo "No .ipa file found." 28 | -------------------------------------------------------------------------------- /PlistManagerUtils.swift: -------------------------------------------------------------------------------- 1 | import Foundation 2 | 3 | class PlistManagerUtils { 4 | 5 | // 单例实例 6 | private static var instances: [String: PlistManagerUtils] = [:] 7 | 8 | private var plistFileURL: URL 9 | private var plistExist: Bool = false 10 | private var preferences: [String: Any] 11 | private var cachedChanges: [String: Any] = [:] 12 | private var isDirty = false 13 | 14 | // 获取实例方法(支持多实例) 15 | static func instance(for plistName: String) -> PlistManagerUtils { 16 | // 如果实例已存在,则返回现有实例 17 | if let instance = instances[plistName] { 18 | return instance 19 | } 20 | 21 | // 否则创建新的实例并存储 22 | let instance = PlistManagerUtils(plistName: plistName) 23 | instances[plistName] = instance 24 | return instance 25 | } 26 | 27 | // 初始化 PlistManager,指定 plist 文件名 28 | private init(plistName: String) { 29 | // 获取沙盒中的 Preferences 目录路径 30 | let preferencesDirectory = FileManager.default.urls(for: .libraryDirectory, in: .userDomainMask).first! 31 | let preferencesPath = preferencesDirectory.appendingPathComponent("Preferences") 32 | self.plistFileURL = preferencesPath.appendingPathComponent("\(plistName).plist") 33 | 34 | // 如果 plist 文件不存在,则创建一个空的文件 35 | if !FileManager.default.fileExists(atPath: plistFileURL.path) { 36 | preferences = [:] 37 | save() 38 | NSLog("Reboot Tools----> 创建配置文件") 39 | plistExist = false //增加一个标识,让外界知道这个配置文件是新创建的 40 | } else { 41 | self.preferences = PlistManagerUtils.loadPreferences(from: plistFileURL) 42 | NSLog("Reboot Tools----> 加载已有创建文件") 43 | plistExist = true 44 | } 45 | } 46 | 47 | // 加载 plist 文件中的数据 48 | private static func loadPreferences(from url: URL) -> [String: Any] { 49 | guard let data = try? Data(contentsOf: url), 50 | let preferences = try? PropertyListSerialization.propertyList(from: data, options: [], format: nil) as? [String: Any] else { 51 | return [:] 52 | } 53 | return preferences 54 | } 55 | 56 | // 保存数据到 plist 文件 57 | private func save() { 58 | do { 59 | let data = try PropertyListSerialization.data(fromPropertyList: preferences, format: .xml, options: 0) 60 | try data.write(to: plistFileURL) 61 | NSLog("Reboot Tools----> Save successful Plist file path: \(plistFileURL.path)") 62 | } catch { 63 | print("Reboot Tools----> Error saving preferences to plist: \(error.localizedDescription)") 64 | } 65 | } 66 | 67 | 68 | // 获取 plist 文件是否存在 69 | func isPlistExist() -> Bool { 70 | return plistExist 71 | } 72 | 73 | // 获取指定 key 对应的 Int 值 74 | func getInt(key: String, defaultValue: Int) -> Int { 75 | return preferences[key] as? Int ?? defaultValue 76 | } 77 | 78 | // 获取指定 key 对应的 Bool 值 79 | func getBool(key: String, defaultValue: Bool) -> Bool { 80 | return preferences[key] as? Bool ?? defaultValue 81 | } 82 | 83 | // 获取指定 key 对应的 String 值 84 | func getString(key: String, defaultValue: String) -> String { 85 | return preferences[key] as? String ?? defaultValue 86 | } 87 | 88 | // 获取指定 key 对应的 Float 值 89 | func getFloat(key: String, defaultValue: Float) -> Float { 90 | return preferences[key] as? Float ?? defaultValue 91 | } 92 | 93 | // 获取指定 key 对应的 Double 值 94 | func getDouble(key: String, defaultValue: Double) -> Double { 95 | return preferences[key] as? Double ?? defaultValue 96 | } 97 | 98 | // 获取指定 key 对应的 Data 值 99 | func getData(key: String, defaultValue: Data) -> Data { 100 | return preferences[key] as? Data ?? defaultValue 101 | } 102 | 103 | // 获取指定 key 对应的 URL 值 104 | func getURL(key: String, defaultValue: URL) -> URL { 105 | return preferences[key] as? URL ?? defaultValue 106 | } 107 | 108 | // 获取指定 key 对应的 Array 值 109 | func getArray(key: String, defaultValue: [Any]) -> [Any] { 110 | return preferences[key] as? [Any] ?? defaultValue 111 | } 112 | 113 | // 获取指定 key 对应的 Dictionary 值 114 | func getDictionary(key: String, defaultValue: [String: Any]) -> [String: Any] { 115 | return preferences[key] as? [String: Any] ?? defaultValue 116 | } 117 | 118 | // 设置 Int 值 119 | func setInt(key: String, value: Int) { 120 | cachedChanges[key] = value 121 | isDirty = true 122 | } 123 | 124 | // 设置 Bool 值 125 | func setBool(key: String, value: Bool) { 126 | cachedChanges[key] = value 127 | isDirty = true 128 | } 129 | 130 | // 设置 String 值 131 | func setString(key: String, value: String) { 132 | cachedChanges[key] = value 133 | isDirty = true 134 | } 135 | 136 | // 设置 Float 值 137 | func setFloat(key: String, value: Float) { 138 | cachedChanges[key] = value 139 | isDirty = true 140 | } 141 | 142 | // 设置 Double 值 143 | func setDouble(key: String, value: Double) { 144 | cachedChanges[key] = value 145 | isDirty = true 146 | } 147 | 148 | // 设置 Data 值 149 | func setData(key: String, value: Data) { 150 | cachedChanges[key] = value 151 | isDirty = true 152 | } 153 | 154 | // 设置 URL 值 155 | func setURL(key: String, value: URL) { 156 | cachedChanges[key] = value 157 | isDirty = true 158 | } 159 | 160 | // 设置 Array 值 161 | func setArray(key: String, value: [Any]) { 162 | cachedChanges[key] = value 163 | isDirty = true 164 | } 165 | 166 | // 设置 Dictionary 值 167 | func setDictionary(key: String, value: [String: Any]) { 168 | cachedChanges[key] = value 169 | isDirty = true 170 | } 171 | 172 | // 删除指定 key 的数据 173 | func remove(key: String) { 174 | cachedChanges[key] = nil 175 | isDirty = true 176 | } 177 | 178 | // 清除 plist 文件(删除整个文件) 179 | func clear() { 180 | do { 181 | try FileManager.default.removeItem(at: plistFileURL) 182 | preferences = [:] 183 | } catch { 184 | print("Reboot Tools----> Error clearing plist file: \(error.localizedDescription)") 185 | } 186 | } 187 | 188 | func commit() { 189 | self.apply() 190 | } 191 | 192 | // 将更改保存到 plist 193 | func apply() { 194 | // 只有在有修改的情况下才进行保存 195 | if isDirty { 196 | // 将所有更改合并到 preferences 中,覆盖掉已存在的相同键 197 | for (key, value) in cachedChanges { 198 | preferences[key] = value 199 | } 200 | 201 | // 执行保存操作 202 | save() 203 | 204 | // 重置缓存和脏标记 205 | cachedChanges.removeAll() 206 | isDirty = false 207 | } 208 | } 209 | 210 | } 211 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # RebootTools 2 | iOS Utils TrollStore App reboot your device 3 | **⚠️Need install via TrollStore.** 4 | Use system restart code `reboot(0);` is safe and reliable, use it with confidence. 5 | **Note: This project will NOT release/store files in parts other than the App sandbox, and will NOT include ANY URL Scheme. You can use it with confidence and will not be detected by third-party app on App Stores. For specific issues, please [view](https://bsky.app/profile/opa334.bsky.social/post/3ll7zkia24c2s).** 6 | 7 | **iOS 重启工具** 8 | **⚠️需要TrollStore权限** 9 | 系统级别重启代码`reboot(0);`安全可靠,放心使用 10 | **注意:本项目不会在除本App沙盒以外的部分释放/存储文件,并且不会包含任何URL Scheme,您可以放心使用,而不会被第三方App Store的检测到,具体问题请[查看](https://bsky.app/profile/opa334.bsky.social/post/3ll7zkia24c2s)** 11 | 12 | ## Testing 13 | I installed and tested using `TrollStore` on the following iOS versions. All iOS versions that support `TrollStore` can use this tool. 14 | 1. iOS 14.3 15 | 2. iOS 15.3.1 16 | 3. iOS 15.4.1 17 | 4. iOS 15.5 18 | 5. iOS 15.6 19 | 6. iOS 16.5 20 | 7. iPadOS 15.4.1 21 | 22 | 我在以下系统版本使用`TrollStore`安装并进行测试,所有支持`TrollStore`的系统都可以使用这个工具 23 | 1. iOS 14.3 24 | 2. iOS 15.3.1 25 | 3. iOS 15.4.1 26 | 4. iOS 15.5 27 | 5. iOS 15.6 28 | 6. iOS 16.5 29 | 7. iPadOS 15.4.1 30 | 31 | ## Build 32 | 1. Download and install [Theos](https://theos.dev/) 33 | 2. Run `make package FINALPACKAGE=1 PACKAGE_FORMAT=ipa` 34 | 35 | Full build: 36 | 1. Download and install [Theos](https://theos.dev/) 37 | 2. Enter [RebootRootHelper](https://github.com/DevelopCubeLab/RebootTools/tree/main/RebootRootHelper) directory 38 | 3. Run `make` or `run stage` to build [RebootRootHelper](https://github.com/DevelopCubeLab/RebootTools/blob/main/Resources/RebootRootHelper). This helper is core of Reboot 39 | 4. Copy `RebootRootHelper` to [Resources](https://github.com/DevelopCubeLab/RebootTools/tree/main/Resources) directory. (I have built this helper and placed it in the `Resources` directory) 40 | 5. Back to `Home directory` 41 | 6. Run `make package FINALPACKAGE=1 PACKAGE_FORMAT=ipa`(of course, you can also build deb, but I think it's not necessary) 42 | 7. You will get this `tipa` file. 43 | 44 | ## Thanks 45 | [肖博Vlog](https://m.xiaobovlog.cn/) 提供的重启设备核心代码`reboot(0);` 46 | [TrollStore](https://github.com/opa334/TrollStore) 47 | Powered by ChatGPT 4o & 4o mini 48 | icon by `SF Symbols` 49 | -------------------------------------------------------------------------------- /RebootRootHelper/Makefile: -------------------------------------------------------------------------------- 1 | TARGET := iphone:clang:latest:7.0 2 | 3 | include $(THEOS)/makefiles/common.mk 4 | 5 | TOOL_NAME = RebootRootHelper 6 | 7 | RebootRootHelper_FILES = main.m 8 | RebootRootHelper_CFLAGS = -fobjc-arc 9 | RebootRootHelper_CODESIGN_FLAGS = -Sentitlements.plist 10 | RebootRootHelper_INSTALL_PATH = /usr/local/bin 11 | 12 | include $(THEOS_MAKE_PATH)/tool.mk 13 | -------------------------------------------------------------------------------- /RebootRootHelper/entitlements.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | platform-application 5 | 6 | com.apple.private.security.container-required 7 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /RebootRootHelper/main.m: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #import 4 | 5 | int main(int argc, char *argv[], char *envp[]) { 6 | @autoreleasepool { 7 | reboot(0); 8 | return 0; 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /RebootTools-Bridging-Header.h: -------------------------------------------------------------------------------- 1 | #import "DeviceController.h" -------------------------------------------------------------------------------- /Resources/AppIcon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DevelopCubeLab/RebootTools/3f22621d32707726b9bc893dfdefabc240586a5b/Resources/AppIcon.png -------------------------------------------------------------------------------- /Resources/AppIcon29x29.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DevelopCubeLab/RebootTools/3f22621d32707726b9bc893dfdefabc240586a5b/Resources/AppIcon29x29.png -------------------------------------------------------------------------------- /Resources/AppIcon29x29@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DevelopCubeLab/RebootTools/3f22621d32707726b9bc893dfdefabc240586a5b/Resources/AppIcon29x29@2x.png -------------------------------------------------------------------------------- /Resources/AppIcon29x29@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DevelopCubeLab/RebootTools/3f22621d32707726b9bc893dfdefabc240586a5b/Resources/AppIcon29x29@3x.png -------------------------------------------------------------------------------- /Resources/AppIcon40x40.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DevelopCubeLab/RebootTools/3f22621d32707726b9bc893dfdefabc240586a5b/Resources/AppIcon40x40.png -------------------------------------------------------------------------------- /Resources/AppIcon40x40@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DevelopCubeLab/RebootTools/3f22621d32707726b9bc893dfdefabc240586a5b/Resources/AppIcon40x40@2x.png -------------------------------------------------------------------------------- /Resources/AppIcon40x40@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DevelopCubeLab/RebootTools/3f22621d32707726b9bc893dfdefabc240586a5b/Resources/AppIcon40x40@3x.png -------------------------------------------------------------------------------- /Resources/AppIcon50x50.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DevelopCubeLab/RebootTools/3f22621d32707726b9bc893dfdefabc240586a5b/Resources/AppIcon50x50.png -------------------------------------------------------------------------------- /Resources/AppIcon50x50@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DevelopCubeLab/RebootTools/3f22621d32707726b9bc893dfdefabc240586a5b/Resources/AppIcon50x50@2x.png -------------------------------------------------------------------------------- /Resources/AppIcon57x57.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DevelopCubeLab/RebootTools/3f22621d32707726b9bc893dfdefabc240586a5b/Resources/AppIcon57x57.png -------------------------------------------------------------------------------- /Resources/AppIcon57x57@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DevelopCubeLab/RebootTools/3f22621d32707726b9bc893dfdefabc240586a5b/Resources/AppIcon57x57@2x.png -------------------------------------------------------------------------------- /Resources/AppIcon60x60@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DevelopCubeLab/RebootTools/3f22621d32707726b9bc893dfdefabc240586a5b/Resources/AppIcon60x60@2x.png -------------------------------------------------------------------------------- /Resources/AppIcon60x60@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DevelopCubeLab/RebootTools/3f22621d32707726b9bc893dfdefabc240586a5b/Resources/AppIcon60x60@3x.png -------------------------------------------------------------------------------- /Resources/AppIcon72x72.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DevelopCubeLab/RebootTools/3f22621d32707726b9bc893dfdefabc240586a5b/Resources/AppIcon72x72.png -------------------------------------------------------------------------------- /Resources/AppIcon72x72@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DevelopCubeLab/RebootTools/3f22621d32707726b9bc893dfdefabc240586a5b/Resources/AppIcon72x72@2x.png -------------------------------------------------------------------------------- /Resources/AppIcon76x76.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DevelopCubeLab/RebootTools/3f22621d32707726b9bc893dfdefabc240586a5b/Resources/AppIcon76x76.png -------------------------------------------------------------------------------- /Resources/AppIcon76x76@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DevelopCubeLab/RebootTools/3f22621d32707726b9bc893dfdefabc240586a5b/Resources/AppIcon76x76@2x.png -------------------------------------------------------------------------------- /Resources/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleExecutable 6 | RebootTools 7 | CFBundleIdentifier 8 | com.developlab.RebootTools 9 | CFBundleInfoDictionaryVersion 10 | 6.0 11 | CFBundlePackageType 12 | APPL 13 | CFBundleSignature 14 | ???? 15 | CFBundleSupportedPlatforms 16 | 17 | iPhoneOS 18 | 19 | CFBundleVersion 20 | 1.0 21 | LSRequiresIPhoneOS 22 | 23 | UIDeviceFamily 24 | 25 | 1 26 | 2 27 | 28 | UIRequiredDeviceCapabilities 29 | 30 | armv7 31 | 32 | UISupportedInterfaceOrientations 33 | 34 | UIInterfaceOrientationPortrait 35 | 36 | UISupportedInterfaceOrientations~ipad 37 | 38 | UIInterfaceOrientationPortrait 39 | UIInterfaceOrientationPortraitUpsideDown 40 | UIInterfaceOrientationLandscapeLeft 41 | UIInterfaceOrientationLandscapeRight 42 | 43 | CFBundleDisplayName 44 | RebootTools 45 | UILaunchStoryboardName 46 | LaunchScreen 47 | LSMinimumSystemVersion 48 | 14.0 49 | CFBundleIcons 50 | 51 | CFBundlePrimaryIcon 52 | 53 | CFBundleIconFiles 54 | 55 | AppIcon29x29 56 | AppIcon40x40 57 | AppIcon57x57 58 | AppIcon60x60 59 | 60 | UIPrerenderedIcon 61 | 62 | 63 | 64 | CFBundleIcons~ipad 65 | 66 | CFBundlePrimaryIcon 67 | 68 | CFBundleIconFiles 69 | 70 | AppIcon29x29 71 | AppIcon40x40 72 | AppIcon57x57 73 | AppIcon60x60 74 | AppIcon50x50 75 | AppIcon72x72 76 | AppIcon76x76 77 | 78 | UIPrerenderedIcon 79 | 80 | 81 | 82 | LSApplicationCategoryType 83 | public.app-category.utilities 84 | CFBundleShortVersionString 85 | 1.2 86 | UIApplicationStateRestoration 87 | 88 | 89 | 90 | -------------------------------------------------------------------------------- /Resources/LaunchScreen.storyboardc/01J-lp-oVM-view-Ze5-6b-2t3.nib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DevelopCubeLab/RebootTools/3f22621d32707726b9bc893dfdefabc240586a5b/Resources/LaunchScreen.storyboardc/01J-lp-oVM-view-Ze5-6b-2t3.nib -------------------------------------------------------------------------------- /Resources/LaunchScreen.storyboardc/Info.plist: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DevelopCubeLab/RebootTools/3f22621d32707726b9bc893dfdefabc240586a5b/Resources/LaunchScreen.storyboardc/Info.plist -------------------------------------------------------------------------------- /Resources/LaunchScreen.storyboardc/UIViewController-01J-lp-oVM.nib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DevelopCubeLab/RebootTools/3f22621d32707726b9bc893dfdefabc240586a5b/Resources/LaunchScreen.storyboardc/UIViewController-01J-lp-oVM.nib -------------------------------------------------------------------------------- /Resources/RebootRootHelper: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DevelopCubeLab/RebootTools/3f22621d32707726b9bc893dfdefabc240586a5b/Resources/RebootRootHelper -------------------------------------------------------------------------------- /Resources/en.lproj/InfoPlist.strings: -------------------------------------------------------------------------------- 1 | "CFBundleDisplayName" = "RebootTools"; 2 | -------------------------------------------------------------------------------- /Resources/en.lproj/Localizable.strings: -------------------------------------------------------------------------------- 1 | "CFBundleDisplayName" = "RebootTools"; 2 | "Install_With_TrollStore_text" = "Already installed via TrollStore"; 3 | "Need_Install_With_TrollStore_text" = "Requires TrollStore installation"; 4 | "Reboot_Device_text" = "Reboot Device"; 5 | "Respring_text" = "Respring"; 6 | "Settings_text" = "Settings"; 7 | "Done_text" = "Done"; 8 | "Dismiss_text" = "Dismiss"; 9 | "Action_Alert" = "Are you sure you want to %@?"; 10 | "Confirm_text" = "Confirm"; 11 | "Cancel_text" = "Cancel"; 12 | "Cancel_Timer_text" = "Disable timer"; 13 | "Timer_Closed_text" = "The timer has been turned off.\nYou can reopen it in Settings"; 14 | "General_text" = "General"; 15 | "Timer_text" = "Timer"; 16 | "About_text" = "About"; 17 | "Enable_Function_text" = "Enable function"; 18 | "Home_Screen_Quick_Actions_text" = "Home Screen quick actions"; 19 | "Display_Root_Permission_text" = "Show root permission has been obtained text"; 20 | "Enable_text" = "Enable"; 21 | "Time_text" = "Time"; 22 | "Seconds_text" = "%d seconds"; 23 | "Action_text" = "Action"; 24 | "Choose_An_Action_text" = "Choose an action"; 25 | "When_Open_Application_To_Action_text" = "Automatically perform operations when launching the Application"; 26 | "Show_Alert_Before_Starting_text" = "Show alert before starting"; 27 | "Countdown_Title_text" = "Countdown for %@"; 28 | "Countdown_Message_text" = "%d seconds remaining"; 29 | "Automatic_Timer_Alert_text" = "The current selection will immediately automatically execute the operation you choose when the Application is opened next time, with no any alert.\nIf you want to disable it, you can long press the application icon to use %@ %@"; 30 | "Automatically_Action_hint" = "'%@' and '%@' can not enable together."; 31 | "Version_text" = "Version"; 32 | "Unknown_text" = "Unknown"; 33 | "Special_Thanks_text" = "Special thanks to Xiaobovlog\nProvides core code for reboot"; -------------------------------------------------------------------------------- /Resources/zh-Hans.lproj/InfoPlist.strings: -------------------------------------------------------------------------------- 1 | "CFBundleDisplayName" = "重启工具"; 2 | -------------------------------------------------------------------------------- /Resources/zh-Hans.lproj/Localizable.strings: -------------------------------------------------------------------------------- 1 | "CFBundleDisplayName" = "重启工具"; 2 | "Install_With_TrollStore_text" = "已经通过TrollStore安装"; 3 | "Need_Install_With_TrollStore_text" = "需要使用TrollStore安装"; 4 | "Reboot_Device_text" = "重启设备"; 5 | "Respring_text" = "注销"; 6 | "Settings_text" = "设置"; 7 | "Done_text" = "完成"; 8 | "Dismiss_text" = "关闭"; 9 | "Action_Alert" = "确定%@?"; 10 | "Confirm_text" = "确定"; 11 | "Cancel_text" = "取消"; 12 | "Cancel_Timer_text" = "禁用倒计时器"; 13 | "Timer_Closed_text" = "倒计时器已被禁用\n可以在设置中重新启用"; 14 | "General_text" = "通用"; 15 | "Timer_text" = "倒计时器"; 16 | "About_text" = "关于"; 17 | "Enable_Function_text" = "启用的功能"; 18 | "Home_Screen_Quick_Actions_text" = "桌面图标快捷方式"; 19 | "Display_Root_Permission_text" = "显示已获得Root授权提示"; 20 | "Enable_text" = "启用"; 21 | "Time_text" = "时间"; 22 | "Seconds_text" = "%d 秒"; 23 | "Action_text" = "执行的操作"; 24 | "Choose_An_Action_text" = "选择一个操作"; 25 | "When_Open_Application_To_Action_text" = "启动App时自动进行操作"; 26 | "Show_Alert_Before_Starting_text" = "开始操作前显示提醒"; 27 | "Countdown_Title_text" = "即将进行%@"; 28 | "Countdown_Message_text" = "剩余%d秒"; 29 | "Automatic_Timer_Alert_text" = "当前的选择在下一次打开App时会立即自动执行您选择的操作,没有任何提示\n如果需要关闭可以长按图标使用%@%@"; 30 | "Automatically_Action_hint" = "'%@'和'%@'无法同时开启"; 31 | "Version_text" = "版本"; 32 | "Unknown_text" = "未知"; 33 | "Special_Thanks_text" = "特别感谢肖博vlog\n提供重启设备核心代码"; -------------------------------------------------------------------------------- /RootViewController.swift: -------------------------------------------------------------------------------- 1 | import UIKit 2 | 3 | class RootViewController: UIViewController { 4 | 5 | // 定义一个闭包(接口)当桌面快捷方式被点击的时候调用 6 | var onClickQuickAction: ((String) -> Void)? 7 | 8 | private let settingsUtils = SettingsUtils.instance 9 | private let checkPermissionLabel = UILabel() 10 | private let respringButton = UIButton(type: .system) 11 | 12 | override func viewDidLoad() { 13 | super.viewDidLoad() 14 | 15 | self.title = NSLocalizedString("CFBundleDisplayName", comment: "") 16 | 17 | // 设置ViewController的背景颜色 18 | self.view.backgroundColor = UIColor.systemBackground 19 | 20 | // icon 21 | let iconImageView = UIImageView() 22 | 23 | if #available(iOS 15.0, *) { 24 | iconImageView.image = UIImage(systemName: "power.circle.fill") 25 | iconImageView.tintColor = UIColor(hex: "#32A5E7") 26 | } else { 27 | let appIcon = UIImage(named: "AppIcon") 28 | iconImageView.image = appIcon 29 | } 30 | // 无障碍标签 31 | iconImageView.isAccessibilityElement = true // 声明这是一个可访问性元素 32 | iconImageView.accessibilityLabel = NSLocalizedString("CFBundleDisplayName", comment: "") 33 | 34 | // 禁用自动调整大小 35 | iconImageView.translatesAutoresizingMaskIntoConstraints = false 36 | // 设置图片适应方式 37 | iconImageView.contentMode = .scaleAspectFit 38 | 39 | // 检查权限 40 | checkPermissionLabel.translatesAutoresizingMaskIntoConstraints = false 41 | checkPermissionLabel.textAlignment = .center // 设置文本居中 42 | 43 | let enable = settingsUtils.checkInstallPermission() 44 | 45 | if(enable) { 46 | checkPermissionLabel.text = NSLocalizedString("Install_With_TrollStore_text", comment: "") 47 | checkPermissionLabel.textColor = UIColor.green 48 | checkPermissionLabel.isHidden = !settingsUtils.getShowRootText() 49 | } else { 50 | checkPermissionLabel.text = NSLocalizedString("Need_Install_With_TrollStore_text", comment: "") 51 | checkPermissionLabel.textColor = UIColor.red 52 | } 53 | 54 | // 重启按钮 55 | let rebootButton = UIButton(type: .system) 56 | if #available(iOS 15.0, *) { 57 | rebootButton.configuration = .filled() 58 | rebootButton.setTitle(NSLocalizedString("Reboot_Device_text", comment: ""), for: .normal) 59 | } else { 60 | // iOS 14 及以下版本 没这效果只能硬凑了 61 | rebootButton.backgroundColor = UIColor.systemBlue 62 | rebootButton.layer.cornerRadius = 8 63 | rebootButton.clipsToBounds = true 64 | rebootButton.setTitle(NSLocalizedString("Reboot_Device_text", comment: ""), for: .normal) 65 | rebootButton.setTitleColor(.white, for: .normal) 66 | if !enable { 67 | // 禁用状态按钮的样子 照顾一下iOS14 用户 但是又没权限的情况,貌似基本不存在 68 | rebootButton.backgroundColor = UIColor.lightGray 69 | rebootButton.setTitleColor(.darkGray, for: .normal) 70 | } 71 | } 72 | 73 | rebootButton.translatesAutoresizingMaskIntoConstraints = false 74 | // 添加点击事件 75 | rebootButton.addTarget(self, action: #selector(onClickRebootButton), for: .touchUpInside) 76 | rebootButton.isEnabled = enable // 无权限的时候不允许点击 77 | 78 | // Respring 79 | respringButton.setTitle(NSLocalizedString("Respring_text", comment: ""), for: .normal) 80 | respringButton.translatesAutoresizingMaskIntoConstraints = false 81 | respringButton.addTarget(self, action: #selector(onClickRespringButton), for: .touchUpInside) 82 | respringButton.isEnabled = enable // 无权限的时候不允许点击 83 | respringButton.isHidden = !settingsUtils.getEnableRespringFunction() 84 | 85 | // 添加设置项 86 | let settingsButton = UIButton(type: .system) 87 | settingsButton.setTitle(NSLocalizedString("Settings_text", comment: ""), for: .normal) 88 | settingsButton.translatesAutoresizingMaskIntoConstraints = false 89 | settingsButton.addTarget(self, action: #selector(onClickSettingsButton), for: .touchUpInside) 90 | // 设置图标 91 | let settingsButtonIcon = UIImage(systemName: "gearshape") 92 | settingsButton.setImage(settingsButtonIcon, for: .normal) 93 | // 调整图标和文本之间的间距 94 | settingsButton.imageEdgeInsets = UIEdgeInsets(top: 0, left: -5, bottom: 0, right: 0) 95 | 96 | // 向View中添加控件 97 | self.view.addSubview(iconImageView) 98 | self.view.addSubview(checkPermissionLabel) 99 | self.view.addSubview(rebootButton) 100 | self.view.addSubview(respringButton) 101 | self.view.addSubview(settingsButton) 102 | 103 | // AutoLayout 104 | NSLayoutConstraint.activate([ 105 | iconImageView.widthAnchor.constraint(equalToConstant: 100), // 设置宽度 106 | iconImageView.heightAnchor.constraint(equalToConstant: 100), // 设置高度 107 | iconImageView.centerXAnchor.constraint(equalTo: self.view.centerXAnchor), // 水平居中 108 | iconImageView.topAnchor.constraint(equalTo: self.view.topAnchor, constant: 100), 109 | 110 | checkPermissionLabel.centerXAnchor.constraint(equalTo: self.view.centerXAnchor), // 水平居中 111 | checkPermissionLabel.topAnchor.constraint(equalTo: iconImageView.bottomAnchor, constant: 30), // 在 iconImageView 底部,间隔 20 点 112 | checkPermissionLabel.leadingAnchor.constraint(equalTo: self.view.leadingAnchor, constant: 20), // 左侧边距 113 | checkPermissionLabel.trailingAnchor.constraint(equalTo: self.view.trailingAnchor, constant: -20), // 右侧边距 114 | 115 | rebootButton.centerXAnchor.constraint(equalTo: self.view.centerXAnchor), // 水平居中 116 | rebootButton.heightAnchor.constraint(equalToConstant: 50), 117 | rebootButton.topAnchor.constraint(equalTo: checkPermissionLabel.bottomAnchor, constant: 30), 118 | rebootButton.leadingAnchor.constraint(equalTo: self.view.leadingAnchor, constant: 50), // 左侧边距 119 | rebootButton.trailingAnchor.constraint(equalTo: self.view.trailingAnchor, constant: -50), // 右侧边距 120 | 121 | respringButton.centerXAnchor.constraint(equalTo: self.view.centerXAnchor), // 水平居中 122 | respringButton.heightAnchor.constraint(equalToConstant: 50), 123 | respringButton.topAnchor.constraint(equalTo: rebootButton.bottomAnchor, constant: 20), 124 | respringButton.leadingAnchor.constraint(equalTo: self.view.leadingAnchor, constant: 50), // 左侧边距 125 | respringButton.trailingAnchor.constraint(equalTo: self.view.trailingAnchor, constant: -50), // 右侧边距 126 | 127 | settingsButton.centerXAnchor.constraint(equalTo: self.view.centerXAnchor), // 水平居中 128 | settingsButton.heightAnchor.constraint(equalToConstant: 50), 129 | settingsButton.topAnchor.constraint(equalTo: respringButton.bottomAnchor, constant: 30), 130 | settingsButton.leadingAnchor.constraint(equalTo: self.view.leadingAnchor, constant: 50), // 左侧边距 131 | settingsButton.trailingAnchor.constraint(equalTo: self.view.trailingAnchor, constant: -50) // 右侧边距 132 | ]) 133 | 134 | } 135 | 136 | override func viewWillAppear(_ animated: Bool) { 137 | super.viewWillAppear(animated) 138 | 139 | // 桌面快捷方式的回调 140 | onClickQuickAction = { [weak self] actionType in 141 | 142 | guard let quickAction = SettingsUtils.QuickActionType(rawValue: actionType) else { 143 | NSLog("Invalid quick action type: \(actionType)") 144 | return 145 | } 146 | 147 | switch quickAction { 148 | case .Reboot: 149 | self?.onClickRebootButton() 150 | case .Respring: 151 | self?.onClickRespringButton() 152 | case .CancelTimer: 153 | self?.onClickCloseTimerQuickAction() 154 | } 155 | } 156 | 157 | // 打开app时的自动操作 158 | if settingsUtils.getEnableAction() && settingsUtils.getOpenApplicationAction() { 159 | let action = settingsUtils.getAction() 160 | switch action { 161 | case .Reboot: 162 | self.onClickRebootButton() 163 | case .Respring: 164 | self.onClickRespringButton() 165 | } 166 | } 167 | } 168 | 169 | @objc func onClickRebootButton() { 170 | 171 | if settingsUtils.getShowAlertBeforeAction() { 172 | // 创建 UIAlertController 173 | let alertController = UIAlertController(title: nil, message: String.localizedStringWithFormat(NSLocalizedString("Action_Alert", comment: ""), NSLocalizedString("Reboot_Device_text", comment: "")), preferredStyle: .alert) 174 | 175 | // 创建 "确定" 按钮(红色) 176 | let confirmAction = UIAlertAction(title: NSLocalizedString("Confirm_text", comment: ""), style: .destructive) { _ in 177 | self.rebootDevice() 178 | } 179 | 180 | // 创建 "取消" 按钮 181 | let cancelAction = UIAlertAction(title: NSLocalizedString("Cancel_text", comment: ""), style: .cancel) { _ in 182 | // 183 | } 184 | 185 | // 添加按钮到 UIAlertController 186 | alertController.addAction(confirmAction) 187 | alertController.addAction(cancelAction) 188 | 189 | // 显示弹窗 190 | self.present(alertController, animated: true, completion: nil) 191 | } else { 192 | self.rebootDevice() 193 | } 194 | 195 | } 196 | 197 | private func rebootDevice() { 198 | let time = settingsUtils.getTime() 199 | if settingsUtils.getEnableAction() && time > 0 { 200 | showCountdownAlert(actionName: NSLocalizedString("Reboot_Device_text", comment: ""), countdownSeconds: time) { 201 | //计时器结束的操作 202 | let deviceController = DeviceController() 203 | deviceController.rebootDevice() 204 | } 205 | } else { 206 | let deviceController = DeviceController() 207 | deviceController.rebootDevice() 208 | } 209 | 210 | } 211 | 212 | @objc func onClickRespringButton() { 213 | 214 | if settingsUtils.getShowAlertBeforeAction() { 215 | // 创建 UIAlertController 216 | let alertController = UIAlertController(title: nil, message: String.localizedStringWithFormat(NSLocalizedString("Action_Alert", comment: ""), NSLocalizedString("Respring_text", comment: "")), preferredStyle: .alert) 217 | 218 | // 创建 "确定" 按钮(红色) 219 | let confirmAction = UIAlertAction(title: NSLocalizedString("Confirm_text", comment: ""), style: .destructive) { _ in 220 | self.respring() 221 | } 222 | 223 | // 创建 "取消" 按钮 224 | let cancelAction = UIAlertAction(title: NSLocalizedString("Cancel_text", comment: ""), style: .cancel) { _ in 225 | // 226 | } 227 | 228 | // 添加按钮到 UIAlertController 229 | alertController.addAction(confirmAction) 230 | alertController.addAction(cancelAction) 231 | 232 | // 显示弹窗 233 | self.present(alertController, animated: true, completion: nil) 234 | } else { 235 | self.respring() 236 | } 237 | 238 | } 239 | 240 | private func respring() { 241 | let time = settingsUtils.getTime() 242 | if settingsUtils.getEnableAction() && time > 0 { 243 | showCountdownAlert(actionName: NSLocalizedString("Respring_text", comment: ""), countdownSeconds: time) { 244 | //计时器结束的操作 245 | let deviceController = DeviceController() 246 | deviceController.respring() 247 | } 248 | } else { 249 | let deviceController = DeviceController() 250 | deviceController.respring() 251 | } 252 | 253 | } 254 | 255 | @objc func onClickSettingsButton() { 256 | let settingsViewController = SettingsViewController() 257 | // 注册监听器 258 | settingsViewController.onSettingsChanged = { [weak self] in 259 | self?.updateUI() 260 | } 261 | // 嵌入到导航控制器 262 | let navController = UINavigationController(rootViewController: settingsViewController) 263 | // 设置导航栏完成按钮 264 | let doneButton = UIBarButtonItem(title: NSLocalizedString("Done_text", comment: ""), style: .done, target: self, action: #selector(onClickDoneButton)) 265 | settingsViewController.navigationItem.rightBarButtonItem = doneButton 266 | // 设置模态视图的显示样式 267 | navController.modalPresentationStyle = .pageSheet 268 | navController.modalTransitionStyle = .coverVertical 269 | 270 | // 显示带导航栏的 SettingsViewController 271 | present(navController, animated: true, completion: nil) 272 | 273 | } 274 | 275 | @objc func onClickDoneButton() { 276 | // 关闭模态视图 277 | dismiss(animated: true, completion: nil) 278 | } 279 | 280 | private func showCountdownAlert(actionName: String, countdownSeconds: Int, action: @escaping () -> Void) { 281 | guard countdownSeconds > 0 else { 282 | print("Invalid countdownSeconds: \(countdownSeconds). It should be greater than 0.") 283 | return 284 | } 285 | 286 | // 初始化倒计时变量 287 | var remainingSeconds = countdownSeconds 288 | var timer: Timer? 289 | 290 | // 创建 UIAlertController 291 | let alertController = UIAlertController( 292 | title: String.localizedStringWithFormat(NSLocalizedString("Countdown_Title_text", comment: ""), actionName), 293 | message: String.localizedStringWithFormat(NSLocalizedString("Countdown_Message_text", comment: ""), remainingSeconds), 294 | preferredStyle: .alert 295 | ) 296 | 297 | // 添加取消按钮 298 | let cancelAction = UIAlertAction(title: NSLocalizedString("Cancel_text", comment: ""), style: .destructive) { _ in 299 | timer?.invalidate() // 停止计时器 300 | } 301 | alertController.addAction(cancelAction) 302 | 303 | // 显示弹窗 304 | DispatchQueue.main.async { 305 | self.present(alertController, animated: true, completion: nil) 306 | } 307 | 308 | // 创建 Timer,倒计时 309 | timer = Timer.scheduledTimer(withTimeInterval: 1.0, repeats: true) { _ in 310 | guard remainingSeconds > 0 else { // 确保倒计时不为负数 311 | timer?.invalidate() 312 | return 313 | } 314 | 315 | remainingSeconds -= 1 316 | DispatchQueue.main.async { 317 | alertController.message = String.localizedStringWithFormat(NSLocalizedString("Countdown_Message_text", comment: ""), remainingSeconds) 318 | } 319 | 320 | // 倒计时结束,执行操作 321 | if remainingSeconds <= 0 { 322 | timer?.invalidate() // 停止计时器 323 | DispatchQueue.main.async { 324 | alertController.dismiss(animated: true, completion: nil) // 关闭弹窗 325 | action() // 执行操作 326 | } 327 | } 328 | } 329 | } 330 | 331 | 332 | private func updateUI() { // 因为设置更改 更新界面 333 | checkPermissionLabel.isHidden = !settingsUtils.getShowRootText() 334 | respringButton.isHidden = !settingsUtils.getEnableRespringFunction() 335 | } 336 | 337 | private func onClickCloseTimerQuickAction() { 338 | settingsUtils.setEnableAction(value: false) 339 | // 显示一个弹窗 提示用户倒计时器已被禁用 340 | let alertController = UIAlertController(title: nil, message: NSLocalizedString("Timer_Closed_text", comment: ""), preferredStyle: .alert) 341 | let dismissAction = UIAlertAction(title: NSLocalizedString("Dismiss_text", comment: ""), style: .cancel) { _ in 342 | // 343 | } 344 | // 添加按钮到 UIAlertController 345 | alertController.addAction(dismissAction) 346 | // 显示弹窗 347 | self.present(alertController, animated: true, completion: nil) 348 | settingsUtils.configQuickActions(application: UIApplication.shared) 349 | } 350 | } 351 | 352 | extension UIColor { 353 | convenience init(hex: String) { 354 | var hexSanitized = hex.trimmingCharacters(in: .whitespacesAndNewlines) 355 | hexSanitized = hexSanitized.replacingOccurrences(of: "#", with: "") 356 | 357 | var rgb: UInt64 = 0 358 | Scanner(string: hexSanitized).scanHexInt64(&rgb) 359 | 360 | let red = CGFloat((rgb & 0xFF0000) >> 16) / 255.0 361 | let green = CGFloat((rgb & 0x00FF00) >> 8) / 255.0 362 | let blue = CGFloat(rgb & 0x0000FF) / 255.0 363 | 364 | self.init(red: red, green: green, blue: blue, alpha: 1.0) 365 | } 366 | } 367 | -------------------------------------------------------------------------------- /SettingsUtils.swift: -------------------------------------------------------------------------------- 1 | import UIKit 2 | 3 | class SettingsUtils { 4 | // 单例实例 5 | static let instance = SettingsUtils() 6 | 7 | // 私有的 PlistManagerUtils 实例,用于管理特定的 plist 文件 8 | private let plistManager: PlistManagerUtils 9 | 10 | // 操作的枚举 11 | enum ActionType: Int { // 0=重启 1=注销 12 | case Reboot = 0 13 | case Respring = 1 14 | } 15 | 16 | enum QuickActionType: String { 17 | case Reboot = "com.developLab.RebootTools.Reboot" 18 | case Respring = "com.developLab.RebootTools.Respring" 19 | case CancelTimer = "com.developLab.RebootTools.CancelTimer" 20 | } 21 | 22 | // 私有初始化方法 23 | private init() { 24 | // 使用 PlistManagerUtils 管理 "settings.plist" 25 | NSLog("Reboot Tools----> SettingsUtils initialized") 26 | self.plistManager = PlistManagerUtils.instance(for: "Settings") 27 | if !self.plistManager.isPlistExist() {// 检查配置文件是否存在,不存在的话则创建默认配置 28 | setDefaultSettings() 29 | } 30 | } 31 | 32 | private func setDefaultSettings() { 33 | 34 | if self.plistManager.isPlistExist() { 35 | return 36 | } 37 | 38 | self.plistManager.setBool(key: "ShowAlertBeforeAction", value: true) 39 | self.plistManager.setBool(key: "ShowRootText", value: true) 40 | self.plistManager.setBool(key: "RespringFunction", value: true) 41 | self.plistManager.setBool(key: "HomeQuickAction", value: true) 42 | self.plistManager.setBool(key: "EnableAction", value: false) 43 | self.plistManager.setInt(key: "Time", value: 5) 44 | self.plistManager.setInt(key: "Action", value: ActionType.Reboot.rawValue) 45 | self.plistManager.setBool(key: "OpenApplicationAction", value: false) 46 | NSLog("Reboot Tools----> 写入默认设置") 47 | //保存 48 | self.plistManager.apply() 49 | 50 | } 51 | 52 | // 给外界的get和set方法 53 | func getShowAlertBeforeAction() -> Bool { 54 | return self.plistManager.getBool(key: "ShowAlertBeforeAction", defaultValue: true) 55 | } 56 | 57 | func setShowAlertBeforeAction(value: Bool) { 58 | self.plistManager.setBool(key: "ShowAlertBeforeAction", value: value) 59 | self.plistManager.apply() 60 | } 61 | 62 | func getShowRootText() -> Bool { 63 | return self.plistManager.getBool(key: "ShowRootText", defaultValue: true) 64 | } 65 | 66 | func setShowRootText(value: Bool) { 67 | self.plistManager.setBool(key: "ShowRootText", value: value) 68 | self.plistManager.apply() 69 | } 70 | 71 | func getEnableRespringFunction() -> Bool { 72 | return self.plistManager.getBool(key: "RespringFunction", defaultValue: true) 73 | } 74 | 75 | func setEnableRespringFunction(value: Bool) { 76 | self.plistManager.setBool(key: "RespringFunction", value: value) 77 | self.plistManager.apply() 78 | } 79 | 80 | func getHomeQuickAction() -> Bool { 81 | return self.plistManager.getBool(key: "HomeQuickAction", defaultValue: true) 82 | } 83 | 84 | func setHomeQuickAction(value: Bool) { 85 | self.plistManager.setBool(key: "HomeQuickAction", value: value) 86 | self.plistManager.apply() 87 | } 88 | 89 | func getEnableAction() -> Bool { 90 | return self.plistManager.getBool(key: "EnableAction", defaultValue: false) 91 | } 92 | 93 | func setEnableAction(value: Bool) { 94 | self.plistManager.setBool(key: "EnableAction", value: value) 95 | self.plistManager.apply() 96 | } 97 | 98 | func getTime() -> Int { 99 | var value = self.plistManager.getInt(key: "Time", defaultValue: 5) 100 | if value < 0 { 101 | value = 0 102 | } 103 | if value > 15 { 104 | value = 15 105 | } 106 | return value 107 | } 108 | 109 | func setTime(value: Int) { 110 | var time = value 111 | if time < 0 { 112 | time = 0 113 | } 114 | if time > 15 { 115 | time = 15 116 | } 117 | self.plistManager.setInt(key: "Time", value: time) 118 | self.plistManager.apply() 119 | } 120 | 121 | func getAction() -> ActionType { 122 | let action = self.plistManager.getInt(key: "Action", defaultValue: ActionType.Reboot.rawValue) 123 | return ActionType(rawValue: action) ?? .Reboot 124 | } 125 | 126 | func setAction(value: ActionType) { 127 | self.plistManager.setInt(key: "Action", value: value.rawValue) 128 | self.plistManager.apply() 129 | } 130 | 131 | func getOpenApplicationAction() -> Bool { 132 | return self.plistManager.getBool(key: "OpenApplicationAction", defaultValue: true) 133 | } 134 | 135 | func setOpenApplicationAction(value: Bool) { 136 | self.plistManager.setBool(key: "OpenApplicationAction", value: value) 137 | self.plistManager.apply() 138 | } 139 | 140 | // 检查Root权限的方法 141 | func checkInstallPermission() -> Bool { 142 | let path = "/var/mobile/Library/Preferences" 143 | let writeable = access(path, W_OK) == 0 144 | return writeable 145 | } 146 | 147 | // 配置桌面快捷方式 148 | func configQuickActions(application: UIApplication) { 149 | 150 | // Action的数组 151 | var currentShortcuts: [UIApplicationShortcutItem] = [] 152 | if getHomeQuickAction() { 153 | 154 | let rebootAction = UIApplicationShortcutItem( 155 | type: SettingsUtils.QuickActionType.Reboot.rawValue, 156 | localizedTitle: NSLocalizedString("Reboot_Device_text", comment: ""), 157 | localizedSubtitle: nil, 158 | icon: UIApplicationShortcutIcon(systemImageName: "arrow.clockwise"), 159 | userInfo: nil 160 | ) 161 | currentShortcuts.append(rebootAction) 162 | 163 | if getEnableRespringFunction() { 164 | let respringAction = UIApplicationShortcutItem( 165 | type: SettingsUtils.QuickActionType.Respring.rawValue, 166 | localizedTitle: NSLocalizedString("Respring_text", comment: ""), 167 | localizedSubtitle: nil, 168 | icon: UIApplicationShortcutIcon(systemImageName: "r.square.on.square"), 169 | userInfo: nil 170 | ) 171 | currentShortcuts.append(respringAction) 172 | } 173 | 174 | } 175 | 176 | if getEnableAction() && getOpenApplicationAction() { 177 | let cancelTimerAction = UIApplicationShortcutItem( 178 | type: SettingsUtils.QuickActionType.CancelTimer.rawValue, 179 | localizedTitle: NSLocalizedString("Cancel_Timer_text", comment: ""), 180 | localizedSubtitle: nil, 181 | icon: UIApplicationShortcutIcon(systemImageName: "xmark.circle"), 182 | userInfo: nil 183 | ) 184 | currentShortcuts.append(cancelTimerAction) 185 | } 186 | 187 | UIApplication.shared.shortcutItems = currentShortcuts 188 | 189 | } 190 | 191 | } 192 | -------------------------------------------------------------------------------- /SettingsViewController.swift: -------------------------------------------------------------------------------- 1 | import UIKit 2 | 3 | class SettingsViewController: UIViewController, UITableViewDelegate, UITableViewDataSource { 4 | 5 | let versionCode = "1.2" 6 | var onSettingsChanged: (() -> Void)? // 一个回调 7 | 8 | var tableView = UITableView(frame: .zero, style: .insetGrouped) 9 | private let settingsUtils = SettingsUtils.instance 10 | private var hasRootPermission = false //用于存储是否是有Root权限 11 | 12 | // 每个分组的小标题 13 | let sectionTitles = [ 14 | NSLocalizedString("General_text", comment: ""), 15 | NSLocalizedString("Enable_Function_text", comment: ""), 16 | NSLocalizedString("Timer_text", comment: ""), 17 | NSLocalizedString("About_text", comment: "") 18 | ] 19 | 20 | // 存储设置项 21 | let sections = [ 22 | [NSLocalizedString("Show_Alert_Before_Starting_text", comment: ""), NSLocalizedString("Display_Root_Permission_text", comment: "")], 23 | [NSLocalizedString("Respring_text", comment: ""), NSLocalizedString("Home_Screen_Quick_Actions_text", comment: "")], 24 | [NSLocalizedString("Enable_text", comment: ""), NSLocalizedString("Time_text", comment: ""), NSLocalizedString("When_Open_Application_To_Action_text", comment: ""), NSLocalizedString("Action_text", comment: "")], 25 | // [String(localized: "Version_text"),"Github"] 26 | [NSLocalizedString("Version_text", comment: ""),"GitHub", NSLocalizedString("Special_Thanks_text", comment: "")] 27 | ] 28 | 29 | enum SwitchTag: Int { 30 | case ShowAlertBeforeAction = 0 31 | case ShowRootText = 1 32 | case RespringFunction = 2 33 | case HomeQuickAction = 3 34 | case EnableAction = 4 35 | case OpenApplicationAction = 5 36 | } 37 | 38 | override func viewDidLoad() { 39 | super.viewDidLoad() 40 | 41 | // 设置视图标题 42 | self.title = NSLocalizedString("Settings_text", comment: "") 43 | // 检查Root权限 44 | hasRootPermission = settingsUtils.checkInstallPermission() 45 | 46 | // iOS 15 之后的版本使用新的UITableView样式 47 | if #available(iOS 15.0, *) { 48 | tableView = UITableView(frame: .zero, style: .insetGrouped) 49 | } else { 50 | tableView = UITableView(frame: .zero, style: .grouped) 51 | } 52 | 53 | // 设置表格视图的代理和数据源 54 | tableView.delegate = self 55 | tableView.dataSource = self 56 | 57 | // 注册表格单元格 58 | tableView.register(UITableViewCell.self, forCellReuseIdentifier: "cell") 59 | 60 | // 将表格视图添加到主视图 61 | view.addSubview(tableView) 62 | 63 | // 设置表格视图的布局 64 | tableView.translatesAutoresizingMaskIntoConstraints = false 65 | NSLayoutConstraint.activate([ 66 | tableView.topAnchor.constraint(equalTo: view.topAnchor), 67 | tableView.leftAnchor.constraint(equalTo: view.leftAnchor), 68 | tableView.rightAnchor.constraint(equalTo: view.rightAnchor), 69 | tableView.bottomAnchor.constraint(equalTo: view.bottomAnchor) 70 | ]) 71 | } 72 | 73 | // MARK: - UITableViewDataSource 74 | 75 | func numberOfSections(in tableView: UITableView) -> Int { 76 | return sections.count 77 | } 78 | 79 | func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int { 80 | return sections[section].count 81 | } 82 | 83 | func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell { 84 | var cell = tableView.dequeueReusableCell(withIdentifier: "cell", for: indexPath) 85 | 86 | // 2. 重置 Cell 状态 解决经典列表复用bug 87 | cell.textLabel?.text = nil 88 | cell.detailTextLabel?.text = nil 89 | cell.textLabel?.textColor = .label 90 | cell.accessoryView = nil 91 | cell.accessoryType = .none 92 | cell.selectionStyle = .none 93 | cell.isUserInteractionEnabled = true 94 | 95 | // 设置单元格的文本 96 | cell.textLabel?.text = sections[indexPath.section][indexPath.row] 97 | cell.textLabel?.numberOfLines = 0 // 允许文本过长时换行 98 | cell.selectionStyle = .none // 禁用选中效果 99 | 100 | switch indexPath.section { 101 | case 0, 1: 102 | // 创建 UISwitch 控件 103 | let switchView = UISwitch(frame: .zero) 104 | switchView.addTarget(self, action: #selector(self.switchChanged(_:)), for: .valueChanged) 105 | switchView.isEnabled = true 106 | // 根据不同的设置项初始化开关状态 107 | if indexPath.section == 0 { 108 | if indexPath.row == 0 { 109 | switchView.tag = SwitchTag.ShowAlertBeforeAction.rawValue 110 | switchView.isOn = settingsUtils.getShowAlertBeforeAction() 111 | } else if indexPath.row == 1 { 112 | switchView.tag = SwitchTag.ShowRootText.rawValue 113 | if !hasRootPermission { // 没有Root权限的用户,不允许关闭无权限的提示 114 | settingsUtils.setShowRootText(value: true) // 强制显示 防止某些用户(可能只有我会这样测试)从有Root权限变成没有权限 115 | cell.textLabel?.textColor = .lightGray //文本变成灰色 116 | switchView.isEnabled = false // 禁用开关 117 | cell.isUserInteractionEnabled = false 118 | } 119 | switchView.isOn = settingsUtils.getShowRootText() 120 | } 121 | } else if indexPath.section == 1 { 122 | if indexPath.row == 0 { 123 | switchView.tag = SwitchTag.RespringFunction.rawValue 124 | switchView.isOn = settingsUtils.getEnableRespringFunction() 125 | } else if indexPath.row == 1 { 126 | switchView.tag = SwitchTag.HomeQuickAction.rawValue 127 | if !hasRootPermission { // 检查用户是否有Root权限 128 | settingsUtils.setHomeQuickAction(value: false) // 无Root 强制关闭桌面快捷方式 129 | settingsUtils.configQuickActions(application: UIApplication.shared) // 强制移除掉快捷方式 防止某些用户(可能只有我会这样测试)从有Root权限变成没有权限 130 | cell.textLabel?.textColor = .lightGray //文本变成灰色 131 | switchView.isEnabled = false // 禁用开关 132 | cell.isUserInteractionEnabled = false 133 | } 134 | if settingsUtils.getEnableAction() && settingsUtils.getOpenApplicationAction() { // 检查是否与其他功能冲突 135 | cell.textLabel?.textColor = .lightGray //文本变成灰色 136 | switchView.isEnabled = false //Switch开关禁用 137 | cell.isUserInteractionEnabled = false 138 | } else { 139 | cell.textLabel?.textColor = .label //文本正常 140 | switchView.isEnabled = true 141 | cell.isUserInteractionEnabled = true 142 | } 143 | 144 | switchView.isOn = settingsUtils.getHomeQuickAction() 145 | 146 | } 147 | } 148 | 149 | cell.accessoryView = switchView 150 | case 2: // 倒计时器的设置 151 | if indexPath.row == 0 { // Enable 152 | let switchView = UISwitch(frame: .zero) 153 | switchView.tag = SwitchTag.EnableAction.rawValue 154 | switchView.addTarget(self, action: #selector(self.switchChanged(_:)), for: .valueChanged) 155 | switchView.isOn = settingsUtils.getEnableAction() 156 | cell.accessoryView = switchView 157 | } else if indexPath.row == 1 { // 设置时间 158 | // 添加 UIStepper 159 | cell = UITableViewCell(style: .value1, reuseIdentifier: "cell") 160 | cell.textLabel?.text = sections[indexPath.section][indexPath.row] 161 | cell.detailTextLabel?.text = String.localizedStringWithFormat(NSLocalizedString("Seconds_text", comment: "Time in seconds"), settingsUtils.getTime()) // 默认值 162 | let stepper = UIStepper() 163 | stepper.minimumValue = 0 // 最小值 164 | stepper.maximumValue = 15 // 最大值 165 | stepper.value = Double(settingsUtils.getTime()) // 初始值 166 | stepper.stepValue = 1 // 每次加减步长 167 | // 添加事件监听 168 | stepper.addTarget(self, action: #selector(self.timerValueChanged(_:)), for: .valueChanged) 169 | 170 | // 设置 UIStepper 为 cell 的 accessoryView 171 | cell.accessoryView = stepper 172 | cell.selectionStyle = .none //没有点击cell的效果 173 | } else if indexPath.row == 2 { 174 | let switchView = UISwitch(frame: .zero) 175 | switchView.tag = SwitchTag.OpenApplicationAction.rawValue 176 | switchView.addTarget(self, action: #selector(self.switchChanged(_:)), for: .valueChanged) 177 | if !hasRootPermission { 178 | settingsUtils.setOpenApplicationAction(value: false) // 无Root权限 禁止打开app就执行操作 179 | cell.textLabel?.textColor = .lightGray //文本变成灰色 180 | switchView.isEnabled = false // 禁用开关 181 | cell.isUserInteractionEnabled = false 182 | } else { 183 | switchView.isOn = settingsUtils.getOpenApplicationAction() 184 | } 185 | if !settingsUtils.getEnableAction() { // 判断是否打开了 启用 开关 186 | cell.textLabel?.textColor = .lightGray //文本变成灰色 187 | switchView.isEnabled = false // 禁用开关 188 | cell.isUserInteractionEnabled = false 189 | } else { 190 | cell.textLabel?.textColor = .label //文本变成灰色 191 | switchView.isEnabled = true // 禁用开关 192 | cell.isUserInteractionEnabled = true 193 | } 194 | 195 | cell.accessoryView = switchView 196 | } else if indexPath.row == 3 { 197 | cell = UITableViewCell(style: .value1, reuseIdentifier: "cell") 198 | if settingsUtils.getEnableRespringFunction() { // 判断是否开启了注销功能 199 | cell.accessoryType = .disclosureIndicator // 添加右侧箭头 200 | cell.detailTextLabel?.textColor = .secondaryLabel // 默认浅灰色 201 | } else { 202 | cell.selectionStyle = .none 203 | cell.accessoryType = .none 204 | cell.textLabel?.textColor = .lightGray //文本变成灰色 205 | } 206 | if !settingsUtils.getEnableAction() { // 判断是否打开了 启用 开关 207 | cell.textLabel?.textColor = .lightGray //文本变成灰色 208 | cell.isUserInteractionEnabled = false 209 | cell.detailTextLabel?.textColor = .tertiaryLabel // 更浅的灰色 210 | } else { 211 | cell.textLabel?.textColor = .label //文本变成灰色 212 | cell.isUserInteractionEnabled = true 213 | } 214 | cell.textLabel?.text = sections[indexPath.section][indexPath.row] 215 | // cell.isUserInteractionEnabled = settingsUtils.getOpenApplicationAction() 216 | // 设置当前选择的item 217 | let action = settingsUtils.getAction() 218 | switch action { 219 | case .Reboot: 220 | cell.detailTextLabel?.text = NSLocalizedString("Reboot_Device_text", comment: "") 221 | case .Respring: 222 | cell.detailTextLabel?.text = NSLocalizedString("Respring_text", comment: "") 223 | } 224 | } 225 | case 3: 226 | if indexPath.row == 0 { 227 | cell = UITableViewCell(style: .value1, reuseIdentifier: "cell") 228 | cell.textLabel?.text = sections[indexPath.section][indexPath.row] 229 | let version = Bundle.main.infoDictionary?["CFBundleShortVersionString"] as? String ?? NSLocalizedString("Unknown_text", comment: "") 230 | if version != versionCode { // 判断版本号是不是有人篡改 231 | cell.detailTextLabel?.text = versionCode 232 | } else { 233 | cell.detailTextLabel?.text = version 234 | } 235 | cell.selectionStyle = .none 236 | cell.accessoryType = .none 237 | } else if indexPath.row == 1 || indexPath.row == 2 { 238 | cell.accessoryType = .disclosureIndicator 239 | cell.selectionStyle = .default // 启用选中效果 240 | } 241 | 242 | default: break 243 | 244 | } 245 | 246 | return cell 247 | } 248 | 249 | 250 | 251 | // MARK: - UISwitch 事件处理 252 | @objc func switchChanged(_ sender: UISwitch) { 253 | 254 | guard let switchTag = SwitchTag(rawValue: sender.tag) else { 255 | return 256 | } 257 | 258 | switch switchTag { 259 | case SwitchTag.ShowAlertBeforeAction: 260 | settingsUtils.setShowAlertBeforeAction(value: sender.isOn) 261 | checkAutomaticaEnableAlert() 262 | case SwitchTag.ShowRootText: 263 | settingsUtils.setShowRootText(value: sender.isOn) 264 | case SwitchTag.RespringFunction: 265 | settingsUtils.setEnableRespringFunction(value: sender.isOn) 266 | // 刷新桌面快捷图标 267 | settingsUtils.configQuickActions(application: UIApplication.shared) 268 | // 判断执行的操作是否是Respring 269 | if !settingsUtils.getEnableRespringFunction() && settingsUtils.getAction() == .Respring { 270 | self.settingsUtils.setAction(value: SettingsUtils.ActionType.Reboot)// 修改默认设置 271 | } 272 | // 刷新执行的操作的item 273 | tableView.reloadRows(at: [IndexPath(row: 3, section: 2)], with: .none) 274 | case SwitchTag.HomeQuickAction: 275 | settingsUtils.setHomeQuickAction(value: sender.isOn) 276 | settingsUtils.configQuickActions(application: UIApplication.shared) 277 | case SwitchTag.EnableAction: 278 | settingsUtils.setEnableAction(value: sender.isOn) 279 | settingsUtils.configQuickActions(application: UIApplication.shared) 280 | checkFunctionConflict() 281 | checkAutomaticaEnableAlert() 282 | // 刷新子项目 283 | tableView.reloadRows(at: [IndexPath(row: 2, section: 2)], with: .none) 284 | tableView.reloadRows(at: [IndexPath(row: 3, section: 2)], with: .none) 285 | case SwitchTag.OpenApplicationAction: 286 | settingsUtils.setOpenApplicationAction(value: sender.isOn) 287 | settingsUtils.configQuickActions(application: UIApplication.shared) 288 | checkFunctionConflict() 289 | checkAutomaticaEnableAlert() 290 | } 291 | } 292 | 293 | @objc func timerValueChanged(_ sender: UIStepper) { 294 | // 找到 UIStepper 所在的单元格 295 | if let cell = sender.superview as? UITableViewCell { 296 | // 更新 detailTextLabel 显示当前值 297 | settingsUtils.setTime(value: Int(sender.value)) 298 | checkAutomaticaEnableAlert() //检查是否是全自动化 299 | cell.detailTextLabel?.text = String.localizedStringWithFormat(NSLocalizedString("Seconds_text", comment: ""), Int(sender.value)) 300 | } 301 | } 302 | 303 | // MARK: - UITableViewDelegate 点击item的事件 304 | func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) { 305 | if indexPath.section == 2 && indexPath.row == 3 { 306 | if settingsUtils.getEnableRespringFunction() && settingsUtils.getEnableAction() { 307 | let actionSheet = UIAlertController(title: NSLocalizedString("Choose_An_Action_text", comment: ""), message: nil, preferredStyle: .actionSheet) 308 | let options = [NSLocalizedString("Reboot_Device_text", comment: ""), NSLocalizedString("Respring_text", comment: "")] 309 | 310 | // 添加选项 311 | for (index, option) in options.enumerated() { 312 | let action = UIAlertAction(title: option, style: .default) { _ in 313 | if index == 0 { 314 | self.settingsUtils.setAction(value: SettingsUtils.ActionType.Reboot) 315 | } else { 316 | self.settingsUtils.setAction(value: SettingsUtils.ActionType.Respring) 317 | } 318 | tableView.reloadRows(at: [indexPath], with: .none) // 更新单元格显示 319 | } 320 | actionSheet.addAction(action) 321 | } 322 | 323 | // 添加取消按钮 324 | let cancelAction = UIAlertAction(title: NSLocalizedString("Cancel_text", comment: ""), style: .cancel) { _ in 325 | tableView.reloadRows(at: [indexPath], with: .none) // 取消时刷新单元格 取消动画 326 | } 327 | actionSheet.addAction(cancelAction) 328 | 329 | // 显示弹窗 330 | if let popover = actionSheet.popoverPresentationController { 331 | // 处理 iPad 的情况 332 | popover.sourceView = tableView 333 | popover.sourceRect = tableView.rectForRow(at: indexPath) 334 | popover.permittedArrowDirections = .any 335 | } 336 | 337 | present(actionSheet, animated: true, completion: nil) 338 | } 339 | 340 | } else if indexPath.section == 3 && indexPath.row == 1 { 341 | tableView.deselectRow(at: indexPath, animated: true) 342 | if let url = URL(string: "https://github.com/DevelopCubeLab/RebootTools") { 343 | UIApplication.shared.open(url, options: [:], completionHandler: nil) 344 | } 345 | } else if indexPath.section == 3 && indexPath.row == 2 { 346 | tableView.deselectRow(at: indexPath, animated: true) 347 | if let url = URL(string: "https://m.xiaobovlog.cn/") { 348 | UIApplication.shared.open(url, options: [:], completionHandler: nil) 349 | } 350 | } 351 | } 352 | 353 | // MARK: - 设置每个分组的标题 354 | func tableView(_ tableView: UITableView, titleForHeaderInSection section: Int) -> String? { 355 | return sectionTitles[section] 356 | } 357 | 358 | func tableView(_ tableView: UITableView, titleForFooterInSection section: Int) -> String? { 359 | // 可以为分组设置尾部文本,如果没有尾部可以返回 nil 360 | if section == 2 { 361 | return String.localizedStringWithFormat(NSLocalizedString("Automatically_Action_hint", comment: ""), NSLocalizedString("When_Open_Application_To_Action_text", comment: ""),NSLocalizedString("Home_Screen_Quick_Actions_text", comment: "")) 362 | } 363 | return nil 364 | } 365 | 366 | // 界面关闭的时候让主界面知道设置改变了 然后更新一下对应的功能是否开启 367 | override func viewWillDisappear(_ animated: Bool) { 368 | super.viewWillDisappear(animated) 369 | onSettingsChanged?() 370 | } 371 | 372 | private func checkFunctionConflict() { 373 | if settingsUtils.getEnableAction() && settingsUtils.getOpenApplicationAction() { 374 | settingsUtils.setHomeQuickAction(value: false) 375 | settingsUtils.configQuickActions(application: UIApplication.shared) 376 | } 377 | tableView.reloadRows(at: [IndexPath(row: 1, section: 1)], with: .none) 378 | } 379 | 380 | private func checkAutomaticaEnableAlert() { 381 | if !settingsUtils.getShowAlertBeforeAction() && settingsUtils.getEnableAction() && 382 | settingsUtils.getOpenApplicationAction() && settingsUtils.getTime() == 0 { 383 | // 显示一个弹窗 提示用户当前操作的取消方法 384 | let alertController = UIAlertController(title: nil, message: String.localizedStringWithFormat(NSLocalizedString("Automatic_Timer_Alert_text", comment: ""), NSLocalizedString("Home_Screen_Quick_Actions_text", comment: ""),NSLocalizedString("Cancel_Timer_text", comment: "")), preferredStyle: .alert) 385 | let dismissAction = UIAlertAction(title: NSLocalizedString("Dismiss_text", comment: ""), style: .cancel) { _ in 386 | // 387 | } 388 | // 添加按钮到 UIAlertController 389 | alertController.addAction(dismissAction) 390 | // 显示弹窗 391 | self.present(alertController, animated: true, completion: nil) 392 | settingsUtils.configQuickActions(application: UIApplication.shared) 393 | } 394 | } 395 | } 396 | -------------------------------------------------------------------------------- /control: -------------------------------------------------------------------------------- 1 | Package: com.developlab.reboottools 2 | Name: RebootTools 3 | Version: 1.2 4 | Architecture: iphoneos-arm 5 | Description: TrollStore app reboot your device. 6 | Maintainer: developlab 7 | Author: developlab 8 | Section: Utilities 9 | Depends: firmware (>= 14.0) | ${LIBSWIFT} 10 | -------------------------------------------------------------------------------- /entitlements.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | get-task-allow 6 | 7 | platform-application 8 | 9 | com.apple.private.security.no-sandbox 10 | 11 | com.apple.private.persona-mgmt 12 | 13 | com.apple.private.security.storage.AppDataContainers 14 | 15 | 16 | 17 | --------------------------------------------------------------------------------