├── ShakeShield.plist ├── README.md ├── Makefile ├── control ├── LICENSE ├── .github └── workflows │ └── release.yml ├── ShakeShield.x └── .gitignore /ShakeShield.plist: -------------------------------------------------------------------------------- 1 | { Filter = { Bundles = ( "com.apple.UIKit" ); }; } 2 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # ShakeShield 2 | Shield the accelerometer within 15 seconds 3 | -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | export PACKAGE_VERSION := 1.0 2 | 3 | TARGET := iphone:clang:16.5:14.0 4 | ARCHS := arm64 5 | 6 | include $(THEOS)/makefiles/common.mk 7 | 8 | TWEAK_NAME := ShakeShield 9 | 10 | ShakeShield_FILES += ShakeShield.x 11 | ShakeShield_CFLAGS += -fobjc-arc 12 | 13 | include $(THEOS_MAKE_PATH)/tweak.mk 14 | -------------------------------------------------------------------------------- /control: -------------------------------------------------------------------------------- 1 | Package: io.github.huami1314 2 | Name: Shake Shield 3 | Version: 1.0.1 4 | Architecture: iphoneos-arm 5 | Description: Save and restore the layout of your icons. 6 | Maintainer: huami. <99124359+huami1314@users.noreply.github.com> 7 | Author: huami. <99124359+huami1314@users.noreply.github.com> 8 | Section: Tweaks 9 | Depends: firmware (>= 14.0), mobilesubstrate 10 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2024 huami. 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /.github/workflows/release.yml: -------------------------------------------------------------------------------- 1 | name: CI 2 | 3 | on: [push] 4 | 5 | jobs: 6 | build: 7 | runs-on: macos-latest 8 | 9 | steps: 10 | - uses: actions/checkout@v3 11 | with: 12 | submodules: true 13 | 14 | - name: Check cache 15 | run: | 16 | echo upstream_heads=`git ls-remote https://github.com/theos/theos | head -n 1 | cut -f 1`-`git ls-remote https://github.com/theos/sdks | head -n 1 | cut -f 1` >> $GITHUB_ENV 17 | 18 | - name: Use cache 19 | id: cache 20 | uses: actions/cache@v3 21 | with: 22 | path: ${{ github.workspace }}/theos 23 | key: ${{ runner.os }}-${{ env.upstream_heads }} 24 | 25 | - name: Prepare Theos 26 | uses: Randomblock1/theos-action@main 27 | 28 | - name: Build package 29 | run: | 30 | rm -f packages/* 31 | make package FINALPACKAGE=1 32 | make package THEOS_PACKAGE_SCHEME=rootless FINALPACKAGE=1 33 | 34 | - name: Upload specific All packages 35 | uses: actions/upload-artifact@v4.3.3 36 | with: 37 | name: ShakeShield 38 | path: | 39 | ${{ github.workspace }}/.theos/obj/debug/*.dylib
 40 | ${{ github.workspace }}/Packages/*.deb 41 | -------------------------------------------------------------------------------- /ShakeShield.x: -------------------------------------------------------------------------------- 1 | @import UIKit; 2 | @import CoreMotion; 3 | 4 | static NSTimeInterval gAppLaunchedAt = 0; 5 | static BOOL gShouldBlockShakeGesture = YES; 6 | 7 | static BOOL shouldBlockShakeGesture() { 8 | if (!gShouldBlockShakeGesture) { 9 | return NO; 10 | } 11 | gShouldBlockShakeGesture = ([NSDate timeIntervalSinceReferenceDate] - gAppLaunchedAt < 15.0); 12 | return gShouldBlockShakeGesture; 13 | } 14 | 15 | %hook UIWindow 16 | 17 | - (void)motionBegan:(UIEventSubtype)motion withEvent:(UIEvent *)event { 18 | if (motion == UIEventSubtypeMotionShake && shouldBlockShakeGesture()) { 19 | return; 20 | } 21 | %orig; 22 | } 23 | 24 | - (void)motionEnded:(UIEventSubtype)motion withEvent:(UIEvent *)event { 25 | if (motion == UIEventSubtypeMotionShake && shouldBlockShakeGesture()) { 26 | return; 27 | } 28 | %orig; 29 | } 30 | 31 | - (void)motionCancelled:(UIEventSubtype)motion withEvent:(UIEvent *)event { 32 | if (motion == UIEventSubtypeMotionShake && shouldBlockShakeGesture()) { 33 | return; 34 | } 35 | %orig; 36 | } 37 | 38 | %end 39 | 40 | %hook UIResponder 41 | 42 | - (void)motionBegan:(UIEventSubtype)motion withEvent:(UIEvent *)event { 43 | if (motion == UIEventSubtypeMotionShake && shouldBlockShakeGesture()) { 44 | return; 45 | } 46 | %orig; 47 | } 48 | 49 | - (void)motionEnded:(UIEventSubtype)motion withEvent:(UIEvent *)event { 50 | if (motion == UIEventSubtypeMotionShake && shouldBlockShakeGesture()) { 51 | return; 52 | } 53 | %orig; 54 | } 55 | 56 | - (void)motionCancelled:(UIEventSubtype)motion withEvent:(UIEvent *)event { 57 | if (motion == UIEventSubtypeMotionShake && shouldBlockShakeGesture()) { 58 | return; 59 | } 60 | %orig; 61 | } 62 | 63 | %end 64 | 65 | %hook CMMotionManager 66 | 67 | - (CMGyroData *)gyroData { 68 | if (shouldBlockShakeGesture()) { 69 | return nil; 70 | } 71 | return %orig; 72 | } 73 | 74 | - (void)startAccelerometerUpdates { 75 | if (shouldBlockShakeGesture()) { 76 | return; 77 | } 78 | %orig; 79 | } 80 | 81 | - (void)startAccelerometerUpdatesToQueue:(id)queue withHandler:(id)handler { 82 | if (shouldBlockShakeGesture()) { 83 | return; 84 | } 85 | %orig; 86 | } 87 | 88 | - (void)startDeviceMotionUpdates { 89 | if (shouldBlockShakeGesture()) { 90 | return; 91 | } 92 | %orig; 93 | } 94 | 95 | - (void)startDeviceMotionUpdatesToQueue:(id)queue withHandler:(id)handler { 96 | if (shouldBlockShakeGesture()) { 97 | return; 98 | } 99 | %orig; 100 | } 101 | 102 | - (void)startGyroUpdates { 103 | if (shouldBlockShakeGesture()) { 104 | return; 105 | } 106 | %orig; 107 | } 108 | 109 | - (void)startGyroUpdatesToQueue:(id)queue withHandler:(id)handler { 110 | if (shouldBlockShakeGesture()) { 111 | return; 112 | } 113 | %orig; 114 | } 115 | 116 | - (BOOL)isAccelerometerActive { 117 | if (shouldBlockShakeGesture()) { 118 | return NO; 119 | } 120 | return %orig; 121 | } 122 | 123 | - (BOOL)isDeviceMotionActive { 124 | if (shouldBlockShakeGesture()) { 125 | return NO; 126 | } 127 | return %orig; 128 | } 129 | 130 | - (BOOL)isGyroActive { 131 | if (shouldBlockShakeGesture()) { 132 | return NO; 133 | } 134 | return %orig; 135 | } 136 | 137 | - (CMAccelerometerData *)accelerometerData { 138 | if (shouldBlockShakeGesture()) { 139 | return nil; 140 | } 141 | return %orig; 142 | } 143 | 144 | %end 145 | 146 | %ctor { 147 | gAppLaunchedAt = [NSDate timeIntervalSinceReferenceDate]; 148 | #if DEBUG 149 | NSLog(@"[ShakeShield] launched at: %.3f", gAppLaunchedAt); 150 | #endif 151 | } 152 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .theos 2 | packages 3 | 4 | # Created by https://www.toptal.com/developers/gitignore/api/swift,xcode,macos 5 | # Edit at https://www.toptal.com/developers/gitignore?templates=swift,xcode,macos 6 | 7 | ### macOS ### 8 | # General 9 | .DS_Store 10 | .AppleDouble 11 | .LSOverride 12 | 13 | # Icon must end with two \r 14 | Icon 15 | 16 | 17 | # Thumbnails 18 | ._* 19 | 20 | # Files that might appear in the root of a volume 21 | .DocumentRevisions-V100 22 | .fseventsd 23 | .Spotlight-V100 24 | .TemporaryItems 25 | .Trashes 26 | .VolumeIcon.icns 27 | .com.apple.timemachine.donotpresent 28 | 29 | # Directories potentially created on remote AFP share 30 | .AppleDB 31 | .AppleDesktop 32 | Network Trash Folder 33 | Temporary Items 34 | .apdisk 35 | 36 | ### macOS Patch ### 37 | # iCloud generated files 38 | *.icloud 39 | 40 | ### Swift ### 41 | # Xcode 42 | # 43 | # gitignore contributors: remember to update Global/Xcode.gitignore, Objective-C.gitignore & Swift.gitignore 44 | 45 | ## User settings 46 | xcuserdata/ 47 | 48 | ## compatibility with Xcode 8 and earlier (ignoring not required starting Xcode 9) 49 | *.xcscmblueprint 50 | *.xccheckout 51 | 52 | ## compatibility with Xcode 3 and earlier (ignoring not required starting Xcode 4) 53 | build/ 54 | DerivedData/ 55 | *.moved-aside 56 | *.pbxuser 57 | !default.pbxuser 58 | *.mode1v3 59 | !default.mode1v3 60 | *.mode2v3 61 | !default.mode2v3 62 | *.perspectivev3 63 | !default.perspectivev3 64 | 65 | ## Obj-C/Swift specific 66 | *.hmap 67 | 68 | ## App packaging 69 | *.ipa 70 | *.dSYM.zip 71 | *.dSYM 72 | 73 | ## Playgrounds 74 | timeline.xctimeline 75 | playground.xcworkspace 76 | 77 | # Swift Package Manager 78 | # Add this line if you want to avoid checking in source code from Swift Package Manager dependencies. 79 | # Packages/ 80 | # Package.pins 81 | # Package.resolved 82 | # *.xcodeproj 83 | # Xcode automatically generates this directory with a .xcworkspacedata file and xcuserdata 84 | # hence it is not needed unless you have added a package configuration file to your project 85 | # .swiftpm 86 | 87 | .build/ 88 | 89 | # CocoaPods 90 | # We recommend against adding the Pods directory to your .gitignore. However 91 | # you should judge for yourself, the pros and cons are mentioned at: 92 | # https://guides.cocoapods.org/using/using-cocoapods.html#should-i-check-the-pods-directory-into-source-control 93 | # Pods/ 94 | # Add this line if you want to avoid checking in source code from the Xcode workspace 95 | # *.xcworkspace 96 | 97 | # Carthage 98 | # Add this line if you want to avoid checking in source code from Carthage dependencies. 99 | # Carthage/Checkouts 100 | 101 | Carthage/Build/ 102 | 103 | # Accio dependency management 104 | Dependencies/ 105 | .accio/ 106 | 107 | # fastlane 108 | # It is recommended to not store the screenshots in the git repo. 109 | # Instead, use fastlane to re-generate the screenshots whenever they are needed. 110 | # For more information about the recommended setup visit: 111 | # https://docs.fastlane.tools/best-practices/source-control/#source-control 112 | 113 | fastlane/report.xml 114 | fastlane/Preview.html 115 | fastlane/screenshots/**/*.png 116 | fastlane/test_output 117 | 118 | # Code Injection 119 | # After new code Injection tools there's a generated folder /iOSInjectionProject 120 | # https://github.com/johnno1962/injectionforxcode 121 | 122 | iOSInjectionProject/ 123 | 124 | ### Xcode ### 125 | 126 | ## Xcode 8 and earlier 127 | 128 | ### Xcode Patch ### 129 | *.xcodeproj/* 130 | !*.xcodeproj/project.pbxproj 131 | !*.xcodeproj/xcshareddata/ 132 | !*.xcodeproj/project.xcworkspace/ 133 | !*.xcworkspace/contents.xcworkspacedata 134 | /*.gcno 135 | **/xcshareddata/WorkspaceSettings.xcsettings 136 | 137 | # End of https://www.toptal.com/developers/gitignore/api/swift,xcode,macos 138 | 139 | --------------------------------------------------------------------------------