로고를 사용하여 MobileSubstrate를 조정해야하며, 디바이스의 모든 애플리케이션에 디바이스를 잠그기 위해 새로운 메소드를 추가하려고합니다. 근접 변경 알림 후 실행하십시오. 테스트 근접 센서가 트리거 될 때 디스플레이가 꺼져있을 때 모든 일이 - 지금까지, 내 코드는 내가 스프링 보드에서 필요로 작동하지만 장치에 설치된 다른 응용 프로그램에서모든 앱에 새로운 메소드를 추가하기 위해 MobileSubstrate를 사용하는 앱 위임을 후킹하기
#import <Foundation/Foundation.h>
#import <UIKit/UIKit.h>
#import <SpringBoard/SpringBoard.h>
#import <SpringBoard/UIApplicationDelegate.h>
#import <GraphicsServices/GSEvent.h>
#include <notify.h>
@interface suspendresume : NSObject
@property(nonatomic, readonly) BOOL proximityState;
@end
@implementation suspendresume
BOOL tweakOn;
@end
static NSString *settingsFile = @"/var/mobile/Library/Preferences/com.matchstick.suspendresume.plist";
%hook SpringBoard
-(void)applicationDidFinishLaunching:(id)application {
// Allow SpringBoard to initialise
%orig;
// Set up proximity monitoring
[[UIDevice currentDevice] setProximityMonitoringEnabled:YES];
[[UIDevice currentDevice] proximityState];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(proximityChange:) name:@"UIDeviceProximityStateDidChangeNotification" object:nil];
}
%new
// Add new code into SpringBoard
-(void)proximityChange:(NSNotification*)notification {
[[UIDevice currentDevice] setProximityMonitoringEnabled:YES];
// Check if tweak is on
NSDictionary *dict = [[NSDictionary alloc] initWithContentsOfFile:settingsFile];
tweakOn = [[dict objectForKey:@"enabled"] boolValue];
// Only run if tweak is on
if (tweakOn) {
// Get first proximity value
if ([[UIDevice currentDevice] proximityState] == YES) {
// Wait a few seconds TODO allow changing of wait interval from prefrences FIXME causes a lockup of interface whilst sleeping
[self performSelector:@selector(lockDeviceAfterDelay) withObject:nil afterDelay:1.0];
}
}
}
%new
-(void)lockDeviceAfterDelay {
// Second proximity value
if ([[UIDevice currentDevice] proximityState] == YES) {
// Lock device
GSEventLockDevice();
}
}
%end
입니다 , 장치를 잠그지 않습니다.
나는 스프링 보드와 함께이 같은 응용 프로그램에서 동일한을 달성하기 위해 UIApplicationDelegate의 -(void)applicationDidFinishLaunching:(id)application
및 UIApplication
을 활용 생각 해요,하지만이 작업을 수행하는 방법을 알아낼 수 없습니다. 이 방법에 대한
아이디어는
from this project 와서 내가 UIApplication
에서 새로운 방법/S에 내가 스프링 보드에서 실행되는 것과 동일한 코드를 추가해야합니까?를
각 응용 프로그램에 대한 근접 모니터링을 다시 설정해야하며 근접 변경 알림을받은 후에 이러한 새 메서드를 어떻게 호출해야합니까? 또한
의 full source for this is on my GitHub
제목 편집이 질문에 관한 내용을 요약하지 못했기 때문에 나는 그것을 되돌 렸습니다. 질문은 특정 iOS 프로토콜에 관한 것이므로 'App Delegate'는 그 사실을 알려주지 않았습니다. 다른 편집을 위해 고맙습니다. –
그 점을 명확히 해 주셔서 고맙습니다. 저는 그 관점에서 보지 않았기 때문에 편집으로 돌아갔습니다. –