UPDATE: I have not tested this on ios7.
I am working on the same requirement before.
To get the purple port, you can use GSCopyPurpleNamedPort () with the packet identifier as an argument.
If you need to simulate a SpringBoard touch, use the GSGetPurpleSystemEventPort.
Using this code below, you can get the port and use it to inject the sensor system.
#import <dlfcn.h> // Framework Paths #define SBSERVPATH "/System/Library/PrivateFrameworks/SpringBoardServices.framework/SpringBoardServices" -(mach_port_t)getFrontMostAppPort { bool locked; bool passcode; mach_port_t *port; void *lib = dlopen(SBSERVPATH, RTLD_LAZY); int (*SBSSpringBoardServerPort)() = dlsym(lib, "SBSSpringBoardServerPort"); void* (*SBGetScreenLockStatus)(mach_port_t* port, bool *lockStatus, bool *passcodeEnabled) = dlsym(lib, "SBGetScreenLockStatus"); port = (mach_port_t *)SBSSpringBoardServerPort(); dlclose(lib); SBGetScreenLockStatus(port, &locked, &passcode); void *(*SBFrontmostApplicationDisplayIdentifier)(mach_port_t *port, char *result) = dlsym(lib, "SBFrontmostApplicationDisplayIdentifier"); char appId[256]; memset(appId, 0, sizeof(appId)); SBFrontmostApplicationDisplayIdentifier(port, appId); NSString * frontmostApp=[NSString stringWithFormat:@"%s",appId]; if([frontmostApp length] == 0 || locked) return GSGetPurpleSystemEventPort(); else return GSCopyPurpleNamedPort(appId); }
I tested ... this works fine on iOS 5 and 6. You may not need a lock if you do not enter it when the lock screen appears. Hope this helps.
pt2121 Apr 22 '13 at 22:04 2013-04-22 22:04
source share