Lock screen on device programmatically

I read other questions about the same, but everyone just says "Jailbreak" which will never be approved by Apple "," This is not possible "and" private API, GraphicsServices.framework ".

Let me clarify something, I do not do this for a jailbreak phone, I do this because the lock button on my phone is broken and I just do not want to wait 1 minute for the lock screen. So I decided that I might have an application called lockScreen at the beginning of AppDelegate.h . This does not happen in the AppStore, it is just for me.

I saw people who can use GSEventLockDevice(); when importing GSEvent.h from GraphicsServices.framework , but when I run it (both on the device and on the simulator), I get this and it will not build:

  Undefined symbols for architecture armv7s: "_GSEventLockDevice", referenced from: -[AppDelegate application:didFinishLaunchingWithOptions:] in AppDelegate.o ld: symbol(s) not found for architecture armv7s clang: error: linker command failed with exit code 1 (use -v to see invocation) 

I'm not quite sure what that means. If I delete the line GSEventLockDevice(); but still import GSEvent.h , everything will work fine. Should my device be jailbroken for work or something else?

+4
source share
3 answers

This is already authorized by someone else. You can find it on Github: https://github.com/neuroo/LockMeNow

 char *gsDylib = "/System/Library/PrivateFrameworks/GraphicsServices.framework/GraphicsServices"; void *handle = dlopen(gsDylib, RTLD_NOW); if (handle) { BOOL locked = FALSE; void (*_GSEventLockDevice)() = dlsym(handle, "GSEventLockDevice"); if (_GSEventLockDevice) { _GSEventLockDevice(); //... } dlclose(handle); //... } 
+3
source

There is no reason for an application code to lock the phone. Use "Assist Touch" in the "Accessibility" settings to complete tasks with buttons on the screen. This button is accessible on the screen (but can be easily hidden) from any place on the phone where your “lock application” is accessible only from the main screen. Check out this support article . Believe me, my lock button is broken too.

+3
source

You get a symbolic error undefined because you are not attached to the private infrastructure in your application. It should be included in the assembly step of Link Binary with Libraries .

Since GraphicsServices.framework not a public structure, it will not appear in the list of frameworks. I found this answer that gives steps for binding to a private structure. I have not tried so YMMV.

How do I add the following private frameworks to the iPhone app?

0
source

Source: https://habr.com/ru/post/1498453/


All Articles