|
12 | 12 | #import <PlayTools/PlayTools-Swift.h>
|
13 | 13 | #import "PTFakeMetaTouch.h"
|
14 | 14 | #import <VideoSubscriberAccount/VideoSubscriberAccount.h>
|
| 15 | +#import <CoreMotion/CoreMotion.h> |
15 | 16 |
|
16 | 17 | __attribute__((visibility("hidden")))
|
17 | 18 | @interface PTSwizzleLoader : NSObject
|
@@ -126,6 +127,15 @@ - (void) hook_setCurrentSubscription:(VSSubscription *)currentSubscription {
|
126 | 127 | // do nothing
|
127 | 128 | }
|
128 | 129 |
|
| 130 | +- (instancetype)hook_CMMotionManager_init { |
| 131 | + CMMotionManager* motionManager = (CMMotionManager*)[self hook_CMMotionManager_init]; |
| 132 | + // The default update interval is 0, which may lead to high CPU usage |
| 133 | + motionManager.accelerometerUpdateInterval = 0.01; |
| 134 | + motionManager.deviceMotionUpdateInterval = 0.01; |
| 135 | + motionManager.gyroUpdateInterval = 0.01; |
| 136 | + return motionManager; |
| 137 | +} |
| 138 | + |
129 | 139 | - (NSString *)hook_stringByReplacingOccurrencesOfRegularExpressionPattern:(NSString *)pattern
|
130 | 140 | withTemplate:(NSString *)template
|
131 | 141 | options:(NSRegularExpressionOptions)options
|
@@ -264,6 +274,8 @@ + (void)load {
|
264 | 274 |
|
265 | 275 | [objc_getClass("VSSubscriptionRegistrationCenter") swizzleInstanceMethod:@selector(setCurrentSubscription:) withMethod:@selector(hook_setCurrentSubscription:)];
|
266 | 276 |
|
| 277 | + [objc_getClass("CMMotionManager") swizzleInstanceMethod:@selector(init) withMethod:@selector(hook_CMMotionManager_init)]; |
| 278 | + |
267 | 279 | if (PlayInfo.isUnrealEngine) {
|
268 | 280 | // Fix NSRegularExpression crash when system language is set to Chinese
|
269 | 281 | CFStringEncoding encoding = CFStringGetSystemEncoding();
|
|
0 commit comments